Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ pipe = ImagicStableDiffusionPipeline.from_pretrained(
|
|
21 |
|
22 |
generator = torch.Generator("cuda").manual_seed(0)
|
23 |
|
24 |
-
def infer(prompt, init_image):
|
25 |
init_image = Image.open(init_image).convert("RGB")
|
26 |
init_image = init_image.resize((256, 256))
|
27 |
|
@@ -33,7 +33,7 @@ def infer(prompt, init_image):
|
|
33 |
num_inference_steps=50,
|
34 |
generator=generator,
|
35 |
text_embedding_optimization_steps=500,
|
36 |
-
model_fine_tuning_optimization_steps=
|
37 |
|
38 |
# with torch.no_grad():
|
39 |
# torch.cuda.empty_cache()
|
@@ -118,17 +118,17 @@ with gr.Blocks(css=css) as block:
|
|
118 |
|
119 |
prompt_input = gr.Textbox(label="Target text", placeholder="Describe the image with what you want to change about the subject")
|
120 |
image_init = gr.Image(source="upload", type="filepath",label="Input Image")
|
121 |
-
|
122 |
submit_btn = gr.Button("Train")
|
123 |
|
124 |
image_output = gr.Image(label="Edited image")
|
125 |
|
126 |
-
examples=[['a sitting dog','imagic-dog.png'], ['a photo of a bird spreading wings','imagic-bird.png']]
|
127 |
ex = gr.Examples(examples=examples, fn=infer, inputs=[prompt_input,image_init], outputs=[image_output], cache_examples=False, run_on_click=False)
|
128 |
|
129 |
|
130 |
gr.HTML(article)
|
131 |
|
132 |
-
submit_btn.click(fn=infer, inputs=[prompt_input,image_init], outputs=[image_output])
|
133 |
|
134 |
block.queue(max_size=12).launch(show_api=False)
|
|
|
21 |
|
22 |
generator = torch.Generator("cuda").manual_seed(0)
|
23 |
|
24 |
+
def infer(prompt, init_image, trn_steps):
|
25 |
init_image = Image.open(init_image).convert("RGB")
|
26 |
init_image = init_image.resize((256, 256))
|
27 |
|
|
|
33 |
num_inference_steps=50,
|
34 |
generator=generator,
|
35 |
text_embedding_optimization_steps=500,
|
36 |
+
model_fine_tuning_optimization_steps=trn_steps)
|
37 |
|
38 |
# with torch.no_grad():
|
39 |
# torch.cuda.empty_cache()
|
|
|
118 |
|
119 |
prompt_input = gr.Textbox(label="Target text", placeholder="Describe the image with what you want to change about the subject")
|
120 |
image_init = gr.Image(source="upload", type="filepath",label="Input Image")
|
121 |
+
trn_steps = gr.Slider(250, 1000, value=500)
|
122 |
submit_btn = gr.Button("Train")
|
123 |
|
124 |
image_output = gr.Image(label="Edited image")
|
125 |
|
126 |
+
examples=[['a sitting dog','imagic-dog.png', 250], ['a photo of a bird spreading wings','imagic-bird.png',250]]
|
127 |
ex = gr.Examples(examples=examples, fn=infer, inputs=[prompt_input,image_init], outputs=[image_output], cache_examples=False, run_on_click=False)
|
128 |
|
129 |
|
130 |
gr.HTML(article)
|
131 |
|
132 |
+
submit_btn.click(fn=infer, inputs=[prompt_input,image_init,trn_steps], outputs=[image_output])
|
133 |
|
134 |
block.queue(max_size=12).launch(show_api=False)
|