Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -62,12 +62,11 @@ torch.cuda.empty_cache()
|
|
62 |
def process(input_image_editor, mask_image, input_text, strength, seed, randomize_seed, num_inference_steps, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
|
63 |
if not input_text:
|
64 |
raise gr.Error("Please enter a text prompt.")
|
65 |
-
|
|
|
66 |
image = input_image_editor['background']
|
67 |
-
|
68 |
if not image:
|
69 |
raise gr.Error("Please upload an image.")
|
70 |
-
|
71 |
width, height = image.size
|
72 |
|
73 |
if randomize_seed:
|
@@ -79,7 +78,8 @@ def process(input_image_editor, mask_image, input_text, strength, seed, randomiz
|
|
79 |
strength=strength, num_inference_steps=num_inference_steps, generator=generator,
|
80 |
guidance_scale=guidance_scale).images[0]
|
81 |
|
82 |
-
|
|
|
83 |
|
84 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
85 |
gr.Markdown(MARKDOWN)
|
@@ -132,13 +132,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
132 |
submit_button_component = gr.Button(
|
133 |
value='Inpaint', variant='primary')
|
134 |
with gr.Column(scale=1):
|
135 |
-
output_image_component = gr.Image(
|
136 |
-
|
137 |
-
output_mask_component = gr.Image(
|
138 |
-
type='pil', image_mode='RGB', label='Generated Mask')
|
139 |
with gr.Accordion("Debug Info", open=False):
|
140 |
output_seed = gr.Number(label="Used Seed")
|
141 |
-
gr.Textbox(
|
142 |
|
143 |
submit_button_component.click(
|
144 |
fn=process,
|
|
|
62 |
def process(input_image_editor, mask_image, input_text, strength, seed, randomize_seed, num_inference_steps, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
|
63 |
if not input_text:
|
64 |
raise gr.Error("Please enter a text prompt.")
|
65 |
+
item = gemini_predict(input_text)
|
66 |
+
|
67 |
image = input_image_editor['background']
|
|
|
68 |
if not image:
|
69 |
raise gr.Error("Please upload an image.")
|
|
|
70 |
width, height = image.size
|
71 |
|
72 |
if randomize_seed:
|
|
|
78 |
strength=strength, num_inference_steps=num_inference_steps, generator=generator,
|
79 |
guidance_scale=guidance_scale).images[0]
|
80 |
|
81 |
+
|
82 |
+
return result, mask_image, seed, item
|
83 |
|
84 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
85 |
gr.Markdown(MARKDOWN)
|
|
|
132 |
submit_button_component = gr.Button(
|
133 |
value='Inpaint', variant='primary')
|
134 |
with gr.Column(scale=1):
|
135 |
+
output_image_component = gr.Image(type='pil', image_mode='RGB', label='Generated Image')
|
136 |
+
output_mask_component = gr.Image(type='pil', image_mode='RGB', label='Generated Mask')
|
|
|
|
|
137 |
with gr.Accordion("Debug Info", open=False):
|
138 |
output_seed = gr.Number(label="Used Seed")
|
139 |
+
identified_item = gr.Textbox(label="Gemini predicted item")
|
140 |
|
141 |
submit_button_component.click(
|
142 |
fn=process,
|