Update app.py
Browse files
app.py
CHANGED
@@ -73,14 +73,14 @@ def process(
|
|
73 |
):
|
74 |
if not input_text:
|
75 |
gr.Info("Please enter a text prompt.")
|
76 |
-
return None, None
|
77 |
input_text = "A military COR3 "+input_text
|
78 |
image = input_image_editor['background']
|
79 |
mask = input_image_editor['layers'][0]
|
80 |
|
81 |
if not image:
|
82 |
gr.Info("Please upload an image.")
|
83 |
-
return None, None
|
84 |
|
85 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
86 |
resized_image = image.resize((width, height), Image.LANCZOS)
|
@@ -96,13 +96,14 @@ def process(
|
|
96 |
image=resized_image,
|
97 |
width=width,
|
98 |
height=height,
|
|
|
99 |
strength=strength_slider,
|
100 |
generator=generator,
|
101 |
joint_attention_kwargs={"scale": 1.2},
|
102 |
num_inference_steps=num_inference_steps_slider
|
103 |
-
)
|
104 |
print('INFERENCE DONE')
|
105 |
-
return result,
|
106 |
|
107 |
#resized_mask = mask.resize((width, height), Image.LANCZOS)
|
108 |
|
@@ -128,10 +129,9 @@ with gr.Blocks() as demo:
|
|
128 |
input_image_editor_component = gr.ImageEditor(
|
129 |
label='Image',
|
130 |
type='pil',
|
131 |
-
sources=["upload"
|
132 |
image_mode='RGB',
|
133 |
-
layers=False
|
134 |
-
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"))
|
135 |
|
136 |
with gr.Row():
|
137 |
input_text_component = gr.Text(
|
@@ -180,9 +180,13 @@ with gr.Blocks() as demo:
|
|
180 |
with gr.Column():
|
181 |
output_image_component = gr.Image(
|
182 |
type='pil', image_mode='RGB', label='Generated image', format="png")
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
186 |
|
187 |
submit_button_component.click(
|
188 |
fn=process,
|
@@ -196,7 +200,9 @@ with gr.Blocks() as demo:
|
|
196 |
],
|
197 |
outputs=[
|
198 |
output_image_component,
|
199 |
-
|
|
|
|
|
200 |
]
|
201 |
)
|
202 |
|
|
|
73 |
):
|
74 |
if not input_text:
|
75 |
gr.Info("Please enter a text prompt.")
|
76 |
+
return None, None, None, None
|
77 |
input_text = "A military COR3 "+input_text
|
78 |
image = input_image_editor['background']
|
79 |
mask = input_image_editor['layers'][0]
|
80 |
|
81 |
if not image:
|
82 |
gr.Info("Please upload an image.")
|
83 |
+
return None, None, None, None
|
84 |
|
85 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
86 |
resized_image = image.resize((width, height), Image.LANCZOS)
|
|
|
96 |
image=resized_image,
|
97 |
width=width,
|
98 |
height=height,
|
99 |
+
num_images_per_prompt =4,
|
100 |
strength=strength_slider,
|
101 |
generator=generator,
|
102 |
joint_attention_kwargs={"scale": 1.2},
|
103 |
num_inference_steps=num_inference_steps_slider
|
104 |
+
)
|
105 |
print('INFERENCE DONE')
|
106 |
+
return result.images[0], result.images[1], result.images[2], result.images[3]
|
107 |
|
108 |
#resized_mask = mask.resize((width, height), Image.LANCZOS)
|
109 |
|
|
|
129 |
input_image_editor_component = gr.ImageEditor(
|
130 |
label='Image',
|
131 |
type='pil',
|
132 |
+
sources=["upload"],
|
133 |
image_mode='RGB',
|
134 |
+
layers=False
|
|
|
135 |
|
136 |
with gr.Row():
|
137 |
input_text_component = gr.Text(
|
|
|
180 |
with gr.Column():
|
181 |
output_image_component = gr.Image(
|
182 |
type='pil', image_mode='RGB', label='Generated image', format="png")
|
183 |
+
output_image_component2 = gr.Image(
|
184 |
+
type='pil', image_mode='RGB', label='Generated image', format="png")
|
185 |
+
output_image_component3 = gr.Image(
|
186 |
+
type='pil', image_mode='RGB', label='Generated image', format="png")
|
187 |
+
output_image_component4 = gr.Image(
|
188 |
+
type='pil', image_mode='RGB', label='Generated image', format="png")
|
189 |
+
|
190 |
|
191 |
submit_button_component.click(
|
192 |
fn=process,
|
|
|
200 |
],
|
201 |
outputs=[
|
202 |
output_image_component,
|
203 |
+
output_image_component2,
|
204 |
+
output_image_component3,
|
205 |
+
output_image_component4
|
206 |
]
|
207 |
)
|
208 |
|