Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,15 +127,17 @@ class process:
|
|
| 127 |
ckpt = os.path.join("models", opt.base_model)
|
| 128 |
pl_sd = read_state_dict(ckpt)
|
| 129 |
if "state_dict" in pl_sd:
|
| 130 |
-
|
| 131 |
else:
|
| 132 |
-
|
| 133 |
-
self.sd_model.load_state_dict(
|
|
|
|
| 134 |
self.base_model = opt.base_model
|
| 135 |
if self.base_model!='v1-5-pruned-emaonly.ckpt' and self.base_model!='sd-v1-4.ckpt':
|
| 136 |
vae_sd = torch.load(os.path.join('models', 'anything-v4.0.vae.pt'), map_location="cuda")
|
| 137 |
st = vae_sd["state_dict"]
|
| 138 |
self.sd_model.first_stage_model.load_state_dict(st, strict=False)
|
|
|
|
| 139 |
|
| 140 |
with torch.inference_mode(), \
|
| 141 |
self.sd_model.ema_scope(), \
|
|
@@ -304,7 +306,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 304 |
label=f"Input type for drawing",
|
| 305 |
interactive=True,
|
| 306 |
value="Nothing")
|
| 307 |
-
im1 = gr.Image(source='canvas', tool='color-sketch', label='Pay attention to adjusting stylus thickness!', visible=False)
|
| 308 |
im2 = im1
|
| 309 |
cond_weight = gr.Slider(
|
| 310 |
label="Condition weight",
|
|
|
|
| 127 |
ckpt = os.path.join("models", opt.base_model)
|
| 128 |
pl_sd = read_state_dict(ckpt)
|
| 129 |
if "state_dict" in pl_sd:
|
| 130 |
+
pl_sd = pl_sd["state_dict"]
|
| 131 |
else:
|
| 132 |
+
pl_sd = pl_sd
|
| 133 |
+
self.sd_model.load_state_dict(pl_sd, strict=False)
|
| 134 |
+
del pl_sd
|
| 135 |
self.base_model = opt.base_model
|
| 136 |
if self.base_model!='v1-5-pruned-emaonly.ckpt' and self.base_model!='sd-v1-4.ckpt':
|
| 137 |
vae_sd = torch.load(os.path.join('models', 'anything-v4.0.vae.pt'), map_location="cuda")
|
| 138 |
st = vae_sd["state_dict"]
|
| 139 |
self.sd_model.first_stage_model.load_state_dict(st, strict=False)
|
| 140 |
+
del st
|
| 141 |
|
| 142 |
with torch.inference_mode(), \
|
| 143 |
self.sd_model.ema_scope(), \
|
|
|
|
| 306 |
label=f"Input type for drawing",
|
| 307 |
interactive=True,
|
| 308 |
value="Nothing")
|
| 309 |
+
im1 = gr.Image(source='canvas', tool='color-sketch', label='Pay attention to adjusting stylus thickness!', visible=False)
|
| 310 |
im2 = im1
|
| 311 |
cond_weight = gr.Slider(
|
| 312 |
label="Condition weight",
|