Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,13 +137,15 @@ def start_tryon(person_img, pose_img, mask_img, cloth_img, garment_des, denoise_
|
|
| 137 |
# Prepare pose image (already uploaded)
|
| 138 |
pose_img = pose_img.resize((768, 1024))
|
| 139 |
|
| 140 |
-
|
| 141 |
-
prompt = f"model is wearing {garment_des}"
|
| 142 |
-
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
|
| 143 |
|
| 144 |
# Embedding generation for prompts
|
| 145 |
with torch.no_grad():
|
| 146 |
with torch.cuda.amp.autocast():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
(
|
| 148 |
prompt_embeds,
|
| 149 |
negative_prompt_embeds,
|
|
@@ -155,9 +157,19 @@ def start_tryon(person_img, pose_img, mask_img, cloth_img, garment_des, denoise_
|
|
| 155 |
do_classifier_free_guidance=True,
|
| 156 |
negative_prompt=negative_prompt,
|
| 157 |
)
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
num_images_per_prompt=1,
|
| 162 |
do_classifier_free_guidance=False,
|
| 163 |
negative_prompt=negative_prompt,
|
|
@@ -216,7 +228,6 @@ with image_blocks as demo:
|
|
| 216 |
seed = gr.Number(label="Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
| 217 |
|
| 218 |
with gr.Column():
|
| 219 |
-
masked_img = gr.Image(label="Masked Image Output", elem_id="masked-img", show_share_button=False)
|
| 220 |
image_out = gr.Image(label="Output Image", elem_id="output-img", show_share_button=False)
|
| 221 |
|
| 222 |
try_button = gr.Button(value="Try-on")
|
|
|
|
| 137 |
# Prepare pose image (already uploaded)
|
| 138 |
pose_img = pose_img.resize((768, 1024))
|
| 139 |
|
| 140 |
+
|
|
|
|
|
|
|
| 141 |
|
| 142 |
# Embedding generation for prompts
|
| 143 |
with torch.no_grad():
|
| 144 |
with torch.cuda.amp.autocast():
|
| 145 |
+
# Generate text embeddings for garment description
|
| 146 |
+
prompt = f"model is wearing {garment_des}"
|
| 147 |
+
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
|
| 148 |
+
with torch.inference_mode():
|
| 149 |
(
|
| 150 |
prompt_embeds,
|
| 151 |
negative_prompt_embeds,
|
|
|
|
| 157 |
do_classifier_free_guidance=True,
|
| 158 |
negative_prompt=negative_prompt,
|
| 159 |
)
|
| 160 |
+
prompt = "a photo of " + garment_des
|
| 161 |
+
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
|
| 162 |
+
if not isinstance(prompt, List):
|
| 163 |
+
prompt = [prompt] * 1
|
| 164 |
+
if not isinstance(negative_prompt, List):
|
| 165 |
+
negative_prompt = [negative_prompt] * 1
|
| 166 |
+
with torch.inference_mode():
|
| 167 |
+
prompt_embeds_cloth,
|
| 168 |
+
_,
|
| 169 |
+
_,
|
| 170 |
+
_,
|
| 171 |
+
)= pipe.encode_prompt(
|
| 172 |
+
prompt,
|
| 173 |
num_images_per_prompt=1,
|
| 174 |
do_classifier_free_guidance=False,
|
| 175 |
negative_prompt=negative_prompt,
|
|
|
|
| 228 |
seed = gr.Number(label="Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
| 229 |
|
| 230 |
with gr.Column():
|
|
|
|
| 231 |
image_out = gr.Image(label="Output Image", elem_id="output-img", show_share_button=False)
|
| 232 |
|
| 233 |
try_button = gr.Button(value="Try-on")
|