Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def predict_clothing(images):
|
|
44 |
|
45 |
|
46 |
@spaces.GPU(duration=180)
|
47 |
-
def generate_image(img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model,
|
48 |
use_input_image_size_as_output, max_input_image_size, randomize_seed, guidance_scale=3):
|
49 |
|
50 |
print()
|
@@ -57,10 +57,10 @@ def generate_image(img1, img2, img3, height, width, img_guidance_scale, inferenc
|
|
57 |
wears = predict_clothing(input_images[1:])
|
58 |
if len(wears)==1:
|
59 |
dress = wears[0]
|
60 |
-
text = f"""
|
61 |
elif len(wears)==2:
|
62 |
topwear, bottomwear = wears[0], wears[1]
|
63 |
-
text = f"""
|
64 |
The {topwear} is in <img><|image_2|></img>. The {bottomwear} is in <img><|image_3|></img>."""
|
65 |
else:
|
66 |
input_images = None
|
@@ -103,8 +103,8 @@ def run_for_examples(img1, img2, img3, height, width, img_guidance_scale, seed,
|
|
103 |
offload_model = False
|
104 |
|
105 |
text = "According to the following examples, generate an output for the input.\nInput: <img><|image_1|></img>\nOutput: <img><|image_2|></img>\n\nInput: <img><|image_3|></img>\nOutput:"
|
106 |
-
return generate_image(
|
107 |
-
|
108 |
|
109 |
|
110 |
description = """
|
@@ -140,9 +140,9 @@ with gr.Blocks() as demo:
|
|
140 |
|
141 |
with gr.Row():
|
142 |
with gr.Column():
|
143 |
-
|
144 |
-
max_input_image_size = gr.Slider(label="max_input_image_size", minimum=128, maximum=2048, value=1024, step=16)
|
145 |
|
|
|
146 |
height_input = gr.Slider(label="Height", minimum=128, maximum=1024, value=512, step=16)
|
147 |
width_input = gr.Slider(label="Width", minimum=128, maximum=1024, value=512, step=16)
|
148 |
|
@@ -154,6 +154,8 @@ with gr.Blocks() as demo:
|
|
154 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
155 |
|
156 |
with gr.Column():
|
|
|
|
|
157 |
img_guidance_scale_input = gr.Slider(label="img_guidance_scale", minimum=1.0, maximum=2.0, value=1.6, step=0.1)
|
158 |
|
159 |
separate_cfg_infer = gr.Checkbox(
|
@@ -176,7 +178,7 @@ with gr.Blocks() as demo:
|
|
176 |
# click
|
177 |
generate_button.click(
|
178 |
generate_image,
|
179 |
-
inputs=[image_input_1, image_input_2, image_input_3, height_input, width_input, img_guidance_scale_input, num_inference_steps,
|
180 |
seed_input, separate_cfg_infer, offload_model, use_input_image_size_as_output, max_input_image_size, randomize_seed,],
|
181 |
outputs=output_image,
|
182 |
)
|
|
|
44 |
|
45 |
|
46 |
@spaces.GPU(duration=180)
|
47 |
+
def generate_image(category, img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model,
|
48 |
use_input_image_size_as_output, max_input_image_size, randomize_seed, guidance_scale=3):
|
49 |
|
50 |
print()
|
|
|
57 |
wears = predict_clothing(input_images[1:])
|
58 |
if len(wears)==1:
|
59 |
dress = wears[0]
|
60 |
+
text = f"""The {category} in <img><|image_1|></img> is wearing a {dress}. The {dress} is in <img><|image_2|></img>."""
|
61 |
elif len(wears)==2:
|
62 |
topwear, bottomwear = wears[0], wears[1]
|
63 |
+
text = f"""The {category} in <img><|image_1|></img> is wearing a {topwear} and a {bottomwear}.
|
64 |
The {topwear} is in <img><|image_2|></img>. The {bottomwear} is in <img><|image_3|></img>."""
|
65 |
else:
|
66 |
input_images = None
|
|
|
103 |
offload_model = False
|
104 |
|
105 |
text = "According to the following examples, generate an output for the input.\nInput: <img><|image_1|></img>\nOutput: <img><|image_2|></img>\n\nInput: <img><|image_3|></img>\nOutput:"
|
106 |
+
return generate_image(img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed, separate_cfg_infer,
|
107 |
+
offload_model, use_input_image_size_as_output, max_input_image_size, randomize_seed)
|
108 |
|
109 |
|
110 |
description = """
|
|
|
140 |
|
141 |
with gr.Row():
|
142 |
with gr.Column():
|
143 |
+
category = gr.Radio(["man", "woman", "boy", "girl"], label="Category", info="Choose one category from the following")
|
|
|
144 |
|
145 |
+
# sliders
|
146 |
height_input = gr.Slider(label="Height", minimum=128, maximum=1024, value=512, step=16)
|
147 |
width_input = gr.Slider(label="Width", minimum=128, maximum=1024, value=512, step=16)
|
148 |
|
|
|
154 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
155 |
|
156 |
with gr.Column():
|
157 |
+
max_input_image_size = gr.Slider(label="max_input_image_size", minimum=128, maximum=2048, value=1024, step=16)
|
158 |
+
|
159 |
img_guidance_scale_input = gr.Slider(label="img_guidance_scale", minimum=1.0, maximum=2.0, value=1.6, step=0.1)
|
160 |
|
161 |
separate_cfg_infer = gr.Checkbox(
|
|
|
178 |
# click
|
179 |
generate_button.click(
|
180 |
generate_image,
|
181 |
+
inputs=[category, image_input_1, image_input_2, image_input_3, height_input, width_input, img_guidance_scale_input, num_inference_steps,
|
182 |
seed_input, separate_cfg_infer, offload_model, use_input_image_size_as_output, max_input_image_size, randomize_seed,],
|
183 |
outputs=output_image,
|
184 |
)
|