Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -240,7 +240,7 @@ class main():
|
|
240 |
return image
|
241 |
|
242 |
@spaces.GPU
|
243 |
-
def invert(image, mask, pcs=10000, epochs=400, weight_decay = 1e-10, lr=1e-1):
|
244 |
|
245 |
del unet
|
246 |
del network
|
@@ -305,7 +305,7 @@ class main():
|
|
305 |
|
306 |
|
307 |
@spaces.GPU
|
308 |
-
def run_inversion(dict, pcs, epochs, weight_decay,lr):
|
309 |
init_image = dict["image"].convert("RGB").resize((512, 512))
|
310 |
mask = dict["mask"].convert("RGB").resize((512, 512))
|
311 |
network = invert([init_image], mask, pcs, epochs, weight_decay,lr)
|
@@ -323,10 +323,8 @@ class main():
|
|
323 |
|
324 |
|
325 |
@spaces.GPU
|
326 |
-
def file_upload(file):
|
327 |
-
|
328 |
-
del network
|
329 |
-
|
330 |
proj = torch.load(file.name).to(device)
|
331 |
|
332 |
#pad to 10000 Principal components to keep everything consistent
|
@@ -447,17 +445,17 @@ with gr.Blocks(css="style.css") as demo:
|
|
447 |
|
448 |
|
449 |
|
450 |
-
invert_button.click(fn=model.run_inversion
|
451 |
inputs=[input_image, pcs, epochs, weight_decay,lr],
|
452 |
outputs = [input_image, file_output])
|
453 |
|
454 |
|
455 |
-
sample.click(fn=model.sample_then_run
|
456 |
|
457 |
submit.click(
|
458 |
-
fn=model.edit_inference
|
459 |
)
|
460 |
-
file_input.change(fn=model.file_upload
|
461 |
|
462 |
|
463 |
|
|
|
240 |
return image
|
241 |
|
242 |
@spaces.GPU
|
243 |
+
def invert(self, image, mask, pcs=10000, epochs=400, weight_decay = 1e-10, lr=1e-1):
|
244 |
|
245 |
del unet
|
246 |
del network
|
|
|
305 |
|
306 |
|
307 |
@spaces.GPU
|
308 |
+
def run_inversion(self, dict, pcs, epochs, weight_decay,lr):
|
309 |
init_image = dict["image"].convert("RGB").resize((512, 512))
|
310 |
mask = dict["mask"].convert("RGB").resize((512, 512))
|
311 |
network = invert([init_image], mask, pcs, epochs, weight_decay,lr)
|
|
|
323 |
|
324 |
|
325 |
@spaces.GPU
|
326 |
+
def file_upload(self, file):
|
327 |
+
|
|
|
|
|
328 |
proj = torch.load(file.name).to(device)
|
329 |
|
330 |
#pad to 10000 Principal components to keep everything consistent
|
|
|
445 |
|
446 |
|
447 |
|
448 |
+
invert_button.click(fn=model.run_inversion,
|
449 |
inputs=[input_image, pcs, epochs, weight_decay,lr],
|
450 |
outputs = [input_image, file_output])
|
451 |
|
452 |
|
453 |
+
sample.click(fn=model.sample_then_run, outputs=[input_image, file_output])
|
454 |
|
455 |
submit.click(
|
456 |
+
fn=model.edit_inference, inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3, a4], outputs=[gallery]
|
457 |
)
|
458 |
+
file_input.change(fn=model.file_upload, inputs=file_input, outputs = gallery)
|
459 |
|
460 |
|
461 |
|