Spaces:
Running
on
Zero
Running
on
Zero
catch error
Browse files
app.py
CHANGED
@@ -16,26 +16,30 @@ def sanitize_prompt(prompt):
|
|
16 |
|
17 |
@spaces.GPU(duration=180)
|
18 |
def process_images(image, image2=None,prompt="a girl",inpaint_model="black-forest-labs/FLUX.1-schnell",strength=0.75,seed=0):
|
19 |
-
|
20 |
-
|
21 |
-
if
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
return output
|
41 |
|
@@ -77,7 +81,7 @@ with demo_blocks as demo:
|
|
77 |
with gr.Row():
|
78 |
prompt = gr.Textbox(label="Prompt",value="a eyes closed girl,shut eyes",placeholder="Your prompt (what you want in place of what is erased)", elem_id="prompt")
|
79 |
|
80 |
-
btn = gr.Button("
|
81 |
|
82 |
image_mask = gr.Image(sources=['upload','clipboard'], elem_id="mask_upload", type="pil", label="Mask_Upload",height=400, value=None)
|
83 |
with gr.Accordion(label="Advanced Settings", open=False):
|
|
|
16 |
|
17 |
@spaces.GPU(duration=180)
|
18 |
def process_images(image, image2=None,prompt="a girl",inpaint_model="black-forest-labs/FLUX.1-schnell",strength=0.75,seed=0):
|
19 |
+
try:
|
20 |
+
# I'm not sure when this happen
|
21 |
+
if not isinstance(image, dict):
|
22 |
+
if image2 == None:
|
23 |
+
print("empty mask")
|
24 |
+
return image
|
25 |
+
else:
|
26 |
+
image = dict({'background': image, 'layers': [image2]})
|
27 |
|
28 |
+
if image2!=None:
|
29 |
+
#print("use image2")
|
30 |
+
mask = image2
|
31 |
+
else:
|
32 |
+
if len(image['layers']) == 0:
|
33 |
+
print("empty mask")
|
34 |
+
return image
|
35 |
+
print("use layer")
|
36 |
+
mask = image['layers'][0]
|
37 |
|
38 |
|
39 |
+
output = flux1_img2img.process_image(image["background"],mask,prompt,inpaint_model,strength,seed)
|
40 |
+
except Exception as e:
|
41 |
+
print(f"An error occurred: {e}")
|
42 |
+
gr.Error(e)
|
43 |
|
44 |
return output
|
45 |
|
|
|
81 |
with gr.Row():
|
82 |
prompt = gr.Textbox(label="Prompt",value="a eyes closed girl,shut eyes",placeholder="Your prompt (what you want in place of what is erased)", elem_id="prompt")
|
83 |
|
84 |
+
btn = gr.Button("Img2Img", elem_id="run_button",variant="primary")
|
85 |
|
86 |
image_mask = gr.Image(sources=['upload','clipboard'], elem_id="mask_upload", type="pil", label="Mask_Upload",height=400, value=None)
|
87 |
with gr.Accordion(label="Advanced Settings", open=False):
|