ML-Motivators commited on
Commit
107b85f
Β·
verified Β·
1 Parent(s): bfaeb8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +265 -179
app.py CHANGED
@@ -1,9 +1,6 @@
1
- # Import spaces first to control GPU initialization
2
- import spaces
3
-
4
- # Now import other packages
5
- import torch
6
  import gradio as gr
 
 
7
  from PIL import Image
8
  from src.tryon_pipeline import StableDiffusionXLInpaintPipeline as TryonPipeline
9
  from src.unet_hacked_garmnet import UNet2DConditionModel as UNet2DConditionModel_ref
@@ -14,218 +11,307 @@ from transformers import (
14
  CLIPTextModel,
15
  CLIPTextModelWithProjection,
16
  )
17
- from diffusers import DDPMScheduler, AutoencoderKL
18
  from typing import List
 
 
19
  import os
20
  from transformers import AutoTokenizer
 
21
  import numpy as np
22
  from utils_mask import get_mask_location
23
  from torchvision import transforms
24
  import apply_net
25
  from preprocess.humanparsing.run_parsing import Parsing
26
  from preprocess.openpose.run_openpose import OpenPose
27
- from detectron2.data.detection_utils import convert_PIL_to_numpy, _apply_exif_orientation
28
  from torchvision.transforms.functional import to_pil_image
29
 
30
- # Rest of your code remains the same...
31
-
32
 
33
- # Function to convert a PIL image to a binary mask
34
  def pil_to_binary_mask(pil_image, threshold=0):
35
- np_image = np.array(pil_image.convert("L"))
36
- mask = (np_image > threshold).astype(np.uint8) * 255
37
- return Image.fromarray(mask)
 
 
 
 
 
 
 
 
38
 
39
 
40
- # Base paths for pre-trained models and examples
41
  base_path = 'yisol/IDM-VTON'
42
  example_path = os.path.join(os.path.dirname(__file__), 'example')
43
 
44
- # Load the UNet model for try-on
45
- unet = UNet2DConditionModel.from_pretrained(base_path, subfolder="unet", torch_dtype=torch.float16)
 
 
 
46
  unet.requires_grad_(False)
47
-
48
- # Load tokenizers and other required models
49
- tokenizer_one = AutoTokenizer.from_pretrained(base_path, subfolder="tokenizer", use_fast=False)
50
- tokenizer_two = AutoTokenizer.from_pretrained(base_path, subfolder="tokenizer_2", use_fast=False)
 
 
 
 
 
 
 
 
51
  noise_scheduler = DDPMScheduler.from_pretrained(base_path, subfolder="scheduler")
52
- text_encoder_one = CLIPTextModel.from_pretrained(base_path, subfolder="text_encoder", torch_dtype=torch.float16)
53
- text_encoder_two = CLIPTextModelWithProjection.from_pretrained(base_path, subfolder="text_encoder_2", torch_dtype=torch.float16)
54
- image_encoder = CLIPVisionModelWithProjection.from_pretrained(base_path, subfolder="image_encoder", torch_dtype=torch.float16)
55
- vae = AutoencoderKL.from_pretrained(base_path, subfolder="vae", torch_dtype=torch.float16)
56
- UNet_Encoder = UNet2DConditionModel_ref.from_pretrained(base_path, subfolder="unet_encoder", torch_dtype=torch.float16)
57
 
58
- # Load parsing and openpose models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  parsing_model = Parsing(0)
60
  openpose_model = OpenPose(0)
61
 
62
- # Freeze the parameters of the models to avoid gradients
63
  UNet_Encoder.requires_grad_(False)
64
  image_encoder.requires_grad_(False)
65
  vae.requires_grad_(False)
66
  unet.requires_grad_(False)
67
  text_encoder_one.requires_grad_(False)
68
  text_encoder_two.requires_grad_(False)
 
 
 
 
 
 
69
 
70
- # Image transformation function
71
- tensor_transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize([0.5], [0.5])])
72
-
73
- # Initialize the pipeline for try-on
74
  pipe = TryonPipeline.from_pretrained(
75
- base_path,
76
- unet=unet,
77
- vae=vae,
78
- feature_extractor=CLIPImageProcessor(),
79
- text_encoder=text_encoder_one,
80
- text_encoder_2=text_encoder_two,
81
- tokenizer=tokenizer_one,
82
- tokenizer_2=tokenizer_two,
83
- scheduler=noise_scheduler,
84
- image_encoder=image_encoder,
85
- torch_dtype=torch.float16,
86
  )
87
  pipe.unet_encoder = UNet_Encoder
88
 
89
-
90
- # Main function for try-on with error handling
91
  @spaces.GPU
92
- def start_tryon(dict, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed):
93
- try:
94
- device = "cuda"
95
-
96
- # Prepare the device and models for computation
97
- openpose_model.preprocessor.body_estimation.model.to(device)
98
- pipe.to(device)
99
- pipe.unet_encoder.to(device)
100
-
101
- # Prepare the images
102
- garm_img = garm_img.convert("RGB").resize((768, 1024))
103
- human_img_orig = dict["background"].convert("RGB")
104
-
105
- # Handle cropping if needed
106
- if is_checked_crop:
107
- width, height = human_img_orig.size
108
- target_width = int(min(width, height * (3 / 4)))
109
- target_height = int(min(height, width * (4 / 3)))
110
- left = (width - target_width) / 2
111
- top = (height - target_height) / 2
112
- right = (width + target_width) / 2
113
- bottom = (height + target_height) / 2
114
- cropped_img = human_img_orig.crop((left, top, right, bottom))
115
- crop_size = cropped_img.size
116
- human_img = cropped_img.resize((768, 1024))
117
- else:
118
- human_img = human_img_orig.resize((768, 1024))
119
-
120
- # Apply masking if selected
121
- if is_checked:
122
- keypoints = openpose_model(human_img.resize((384, 512)))
123
- model_parse, _ = parsing_model(human_img.resize((384, 512)))
124
- mask, mask_gray = get_mask_location('hd', "upper_body", model_parse, keypoints)
125
- mask = mask.resize((768, 1024))
126
- else:
127
- mask = pil_to_binary_mask(dict['layers'][0].convert("RGB").resize((768, 1024)))
128
-
129
- mask_gray = (1 - transforms.ToTensor()(mask)) * tensor_transform(human_img)
130
- mask_gray = to_pil_image((mask_gray + 1.0) / 2.0)
131
-
132
- # Apply pose estimation
133
- human_img_arg = _apply_exif_orientation(human_img.resize((384, 512)))
134
- human_img_arg = convert_PIL_to_numpy(human_img_arg, format="BGR")
135
-
136
- args = apply_net.create_argument_parser().parse_args(
137
- ('show', './configs/densepose_rcnn_R_50_FPN_s1x.yaml', './ckpt/densepose/model_final_162be9.pkl', 'dp_segm', '-v', '--opts', 'MODEL.DEVICE', 'cuda')
138
- )
139
- pose_img = args.func(args, human_img_arg)
140
- pose_img = pose_img[:, :, ::-1]
141
- pose_img = Image.fromarray(pose_img).resize((768, 1024))
142
-
143
- # Generate the try-on image
144
- with torch.no_grad():
145
- with torch.cuda.amp.autocast():
146
  prompt = "model is wearing " + garment_des
147
  negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
148
- prompt_embeds, negative_prompt_embeds, pooled_prompt_embeds, negative_pooled_prompt_embeds = pipe.encode_prompt(
149
- prompt, num_images_per_prompt=1, do_classifier_free_guidance=True, negative_prompt=negative_prompt
150
- )
151
-
152
- # Cloth prompt embedding
153
- prompt = "a photo of " + garment_des
154
- prompt_embeds_c, _, _, _ = pipe.encode_prompt(
155
- prompt, num_images_per_prompt=1, do_classifier_free_guidance=False, negative_prompt=negative_prompt
156
- )
157
-
158
- # Convert pose image and garment to tensors
159
- pose_img = tensor_transform(pose_img).unsqueeze(0).to(device, torch.float16)
160
- garm_tensor = tensor_transform(garm_img).unsqueeze(0).to(device, torch.float16)
161
- generator = torch.Generator(device).manual_seed(seed) if seed is not None else None
162
-
163
- # Run the pipeline
164
- images = pipe(
165
- prompt_embeds=prompt_embeds.to(device, torch.float16),
166
- negative_prompt_embeds=negative_prompt_embeds.to(device, torch.float16),
167
- pooled_prompt_embeds=pooled_prompt_embeds.to(device, torch.float16),
168
- negative_pooled_prompt_embeds=negative_pooled_prompt_embeds.to(device, torch.float16),
169
- num_inference_steps=denoise_steps,
170
- generator=generator,
171
- strength=1.0,
172
- pose_img=pose_img.to(device, torch.float16),
173
- text_embeds_cloth=prompt_embeds_c.to(device, torch.float16),
174
- cloth=garm_tensor.to(device, torch.float16),
175
- mask_image=mask,
176
- image=human_img,
177
- height=1024,
178
- width=768,
179
- ip_adapter_image=garm_img.resize((768, 1024)),
180
- guidance_scale=2.0,
181
- )[0]
182
-
183
- if is_checked_crop:
184
- out_img = images[0].resize(crop_size)
185
- human_img_orig.paste(out_img, (int(left), int(top)))
186
- return human_img_orig, mask_gray
187
- else:
188
- return images[0], mask_gray
189
-
190
- except Exception as e:
191
- print(f"Error during try-on: {e}")
192
- return None, None
193
-
194
-
195
- # Gradio interface setup
196
- garm_list = os.listdir(os.path.join(example_path, "cloth"))
197
- garm_list_path = [os.path.join(example_path, "cloth", garm) for garm in garm_list]
198
- human_list = os.listdir(os.path.join(example_path, "human"))
199
- human_list_path = [os.path.join(example_path, "human", human) for human in human_list]
200
- human_ex_list = [{"background": ex_human, "layers": None, "composite": None} for ex_human in human_list_path]
201
-
202
- # Gradio blocks UI
203
- with gr.Blocks() as image_blocks:
204
- with gr.Column():
205
- with gr.Row():
206
- # imgs = gr.Image(source='upload', type="pil", label='Person Image')
207
- imgs = gr.Image(type="pil", label='Person Image') # Remove the 'source' argument
208
- is_checked = gr.Checkbox(label="Check if mask needed")
209
- is_checked_crop = gr.Checkbox(label="Check to crop")
210
- ex_img = gr.Examples(inputs=imgs, examples_per_page=9, examples=human_ex_list)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  with gr.Column():
212
- garm_img = gr.Image(source='upload', type="pil", label='Cloth')
213
- garment_des = gr.Textbox(label="Garment Description", value='garment,shirt')
214
- ex_garm = gr.Examples(inputs=garm_img, examples_per_page=9, examples=garm_list_path)
215
- with gr.Row():
216
- denoise_steps = gr.Slider(label="denoise steps", minimum=1, maximum=50, step=1, value=25)
217
- seed = gr.Slider(label="Seed (for reproducible results)", minimum=0, maximum=2147483647, step=1)
218
- with gr.Row():
219
- try_button = gr.Button("Try it on")
220
- with gr.Row():
221
- out_img = gr.Image(label="Generated tryon output")
222
- masked_img = gr.Image(label="Mask")
223
-
224
- try_button.click(
225
- start_tryon,
226
- inputs=[imgs, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed],
227
- outputs=[out_img, masked_img]
228
- )
229
 
230
- # Launch Gradio app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  image_blocks.launch(server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+
3
+
4
  from PIL import Image
5
  from src.tryon_pipeline import StableDiffusionXLInpaintPipeline as TryonPipeline
6
  from src.unet_hacked_garmnet import UNet2DConditionModel as UNet2DConditionModel_ref
 
11
  CLIPTextModel,
12
  CLIPTextModelWithProjection,
13
  )
14
+ from diffusers import DDPMScheduler,AutoencoderKL
15
  from typing import List
16
+
17
+ import torch
18
  import os
19
  from transformers import AutoTokenizer
20
+ import spaces
21
  import numpy as np
22
  from utils_mask import get_mask_location
23
  from torchvision import transforms
24
  import apply_net
25
  from preprocess.humanparsing.run_parsing import Parsing
26
  from preprocess.openpose.run_openpose import OpenPose
27
+ from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_orientation
28
  from torchvision.transforms.functional import to_pil_image
29
 
 
 
30
 
 
31
  def pil_to_binary_mask(pil_image, threshold=0):
32
+ np_image = np.array(pil_image)
33
+ grayscale_image = Image.fromarray(np_image).convert("L")
34
+ binary_mask = np.array(grayscale_image) > threshold
35
+ mask = np.zeros(binary_mask.shape, dtype=np.uint8)
36
+ for i in range(binary_mask.shape[0]):
37
+ for j in range(binary_mask.shape[1]):
38
+ if binary_mask[i,j] == True :
39
+ mask[i,j] = 1
40
+ mask = (mask*255).astype(np.uint8)
41
+ output_mask = Image.fromarray(mask)
42
+ return output_mask
43
 
44
 
 
45
  base_path = 'yisol/IDM-VTON'
46
  example_path = os.path.join(os.path.dirname(__file__), 'example')
47
 
48
+ unet = UNet2DConditionModel.from_pretrained(
49
+ base_path,
50
+ subfolder="unet",
51
+ torch_dtype=torch.float16,
52
+ )
53
  unet.requires_grad_(False)
54
+ tokenizer_one = AutoTokenizer.from_pretrained(
55
+ base_path,
56
+ subfolder="tokenizer",
57
+ revision=None,
58
+ use_fast=False,
59
+ )
60
+ tokenizer_two = AutoTokenizer.from_pretrained(
61
+ base_path,
62
+ subfolder="tokenizer_2",
63
+ revision=None,
64
+ use_fast=False,
65
+ )
66
  noise_scheduler = DDPMScheduler.from_pretrained(base_path, subfolder="scheduler")
 
 
 
 
 
67
 
68
+ text_encoder_one = CLIPTextModel.from_pretrained(
69
+ base_path,
70
+ subfolder="text_encoder",
71
+ torch_dtype=torch.float16,
72
+ )
73
+ text_encoder_two = CLIPTextModelWithProjection.from_pretrained(
74
+ base_path,
75
+ subfolder="text_encoder_2",
76
+ torch_dtype=torch.float16,
77
+ )
78
+ image_encoder = CLIPVisionModelWithProjection.from_pretrained(
79
+ base_path,
80
+ subfolder="image_encoder",
81
+ torch_dtype=torch.float16,
82
+ )
83
+ vae = AutoencoderKL.from_pretrained(base_path,
84
+ subfolder="vae",
85
+ torch_dtype=torch.float16,
86
+ )
87
+
88
+ # "stabilityai/stable-diffusion-xl-base-1.0",
89
+ UNet_Encoder = UNet2DConditionModel_ref.from_pretrained(
90
+ base_path,
91
+ subfolder="unet_encoder",
92
+ torch_dtype=torch.float16,
93
+ )
94
+
95
  parsing_model = Parsing(0)
96
  openpose_model = OpenPose(0)
97
 
 
98
  UNet_Encoder.requires_grad_(False)
99
  image_encoder.requires_grad_(False)
100
  vae.requires_grad_(False)
101
  unet.requires_grad_(False)
102
  text_encoder_one.requires_grad_(False)
103
  text_encoder_two.requires_grad_(False)
104
+ tensor_transfrom = transforms.Compose(
105
+ [
106
+ transforms.ToTensor(),
107
+ transforms.Normalize([0.5], [0.5]),
108
+ ]
109
+ )
110
 
 
 
 
 
111
  pipe = TryonPipeline.from_pretrained(
112
+ base_path,
113
+ unet=unet,
114
+ vae=vae,
115
+ feature_extractor= CLIPImageProcessor(),
116
+ text_encoder = text_encoder_one,
117
+ text_encoder_2 = text_encoder_two,
118
+ tokenizer = tokenizer_one,
119
+ tokenizer_2 = tokenizer_two,
120
+ scheduler = noise_scheduler,
121
+ image_encoder=image_encoder,
122
+ torch_dtype=torch.float16,
123
  )
124
  pipe.unet_encoder = UNet_Encoder
125
 
 
 
126
  @spaces.GPU
127
+ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_steps,seed):
128
+ device = "cuda"
129
+
130
+ openpose_model.preprocessor.body_estimation.model.to(device)
131
+ pipe.to(device)
132
+ pipe.unet_encoder.to(device)
133
+
134
+ garm_img= garm_img.convert("RGB").resize((768,1024))
135
+ human_img_orig = dict["background"].convert("RGB")
136
+
137
+ if is_checked_crop:
138
+ width, height = human_img_orig.size
139
+ target_width = int(min(width, height * (3 / 4)))
140
+ target_height = int(min(height, width * (4 / 3)))
141
+ left = (width - target_width) / 2
142
+ top = (height - target_height) / 2
143
+ right = (width + target_width) / 2
144
+ bottom = (height + target_height) / 2
145
+ cropped_img = human_img_orig.crop((left, top, right, bottom))
146
+ crop_size = cropped_img.size
147
+ human_img = cropped_img.resize((768,1024))
148
+ else:
149
+ human_img = human_img_orig.resize((768,1024))
150
+
151
+
152
+ if is_checked:
153
+ keypoints = openpose_model(human_img.resize((384,512)))
154
+ model_parse, _ = parsing_model(human_img.resize((384,512)))
155
+ mask, mask_gray = get_mask_location('hd', "upper_body", model_parse, keypoints)
156
+ mask = mask.resize((768,1024))
157
+ else:
158
+ mask = pil_to_binary_mask(dict['layers'][0].convert("RGB").resize((768, 1024)))
159
+ # mask = transforms.ToTensor()(mask)
160
+ # mask = mask.unsqueeze(0)
161
+ mask_gray = (1-transforms.ToTensor()(mask)) * tensor_transfrom(human_img)
162
+ mask_gray = to_pil_image((mask_gray+1.0)/2.0)
163
+
164
+
165
+ human_img_arg = _apply_exif_orientation(human_img.resize((384,512)))
166
+ human_img_arg = convert_PIL_to_numpy(human_img_arg, format="BGR")
167
+
168
+
169
+
170
+ args = apply_net.create_argument_parser().parse_args(('show', './configs/densepose_rcnn_R_50_FPN_s1x.yaml', './ckpt/densepose/model_final_162be9.pkl', 'dp_segm', '-v', '--opts', 'MODEL.DEVICE', 'cuda'))
171
+ # verbosity = getattr(args, "verbosity", None)
172
+ pose_img = args.func(args,human_img_arg)
173
+ pose_img = pose_img[:,:,::-1]
174
+ pose_img = Image.fromarray(pose_img).resize((768,1024))
175
+
176
+ with torch.no_grad():
177
+ # Extract the images
178
+ with torch.cuda.amp.autocast():
179
+ with torch.no_grad():
 
180
  prompt = "model is wearing " + garment_des
181
  negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
182
+ with torch.inference_mode():
183
+ (
184
+ prompt_embeds,
185
+ negative_prompt_embeds,
186
+ pooled_prompt_embeds,
187
+ negative_pooled_prompt_embeds,
188
+ ) = pipe.encode_prompt(
189
+ prompt,
190
+ num_images_per_prompt=1,
191
+ do_classifier_free_guidance=True,
192
+ negative_prompt=negative_prompt,
193
+ )
194
+
195
+ prompt = "a photo of " + garment_des
196
+ negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
197
+ if not isinstance(prompt, List):
198
+ prompt = [prompt] * 1
199
+ if not isinstance(negative_prompt, List):
200
+ negative_prompt = [negative_prompt] * 1
201
+ with torch.inference_mode():
202
+ (
203
+ prompt_embeds_c,
204
+ _,
205
+ _,
206
+ _,
207
+ ) = pipe.encode_prompt(
208
+ prompt,
209
+ num_images_per_prompt=1,
210
+ do_classifier_free_guidance=False,
211
+ negative_prompt=negative_prompt,
212
+ )
213
+
214
+
215
+
216
+ pose_img = tensor_transfrom(pose_img).unsqueeze(0).to(device,torch.float16)
217
+ garm_tensor = tensor_transfrom(garm_img).unsqueeze(0).to(device,torch.float16)
218
+ generator = torch.Generator(device).manual_seed(seed) if seed is not None else None
219
+ images = pipe(
220
+ prompt_embeds=prompt_embeds.to(device,torch.float16),
221
+ negative_prompt_embeds=negative_prompt_embeds.to(device,torch.float16),
222
+ pooled_prompt_embeds=pooled_prompt_embeds.to(device,torch.float16),
223
+ negative_pooled_prompt_embeds=negative_pooled_prompt_embeds.to(device,torch.float16),
224
+ num_inference_steps=denoise_steps,
225
+ generator=generator,
226
+ strength = 1.0,
227
+ pose_img = pose_img.to(device,torch.float16),
228
+ text_embeds_cloth=prompt_embeds_c.to(device,torch.float16),
229
+ cloth = garm_tensor.to(device,torch.float16),
230
+ mask_image=mask,
231
+ image=human_img,
232
+ height=1024,
233
+ width=768,
234
+ ip_adapter_image = garm_img.resize((768,1024)),
235
+ guidance_scale=2.0,
236
+ )[0]
237
+
238
+ if is_checked_crop:
239
+ out_img = images[0].resize(crop_size)
240
+ human_img_orig.paste(out_img, (int(left), int(top)))
241
+ return human_img_orig, mask_gray
242
+ else:
243
+ return images[0], mask_gray
244
+ # return images[0], mask_gray
245
+
246
+ garm_list = os.listdir(os.path.join(example_path,"cloth"))
247
+ garm_list_path = [os.path.join(example_path,"cloth",garm) for garm in garm_list]
248
+
249
+ human_list = os.listdir(os.path.join(example_path,"human"))
250
+ human_list_path = [os.path.join(example_path,"human",human) for human in human_list]
251
+
252
+ human_ex_list = []
253
+ for ex_human in human_list_path:
254
+ ex_dict= {}
255
+ ex_dict['background'] = ex_human
256
+ ex_dict['layers'] = None
257
+ ex_dict['composite'] = None
258
+ human_ex_list.append(ex_dict)
259
+
260
+ ##default human
261
+
262
+
263
+ image_blocks = gr.Blocks().queue()
264
+ with image_blocks as demo:
265
+ gr.Markdown("## IDM-VTON πŸ‘•πŸ‘”πŸ‘š")
266
+ # gr.Markdown("Virtual Try-on with your image and garment image. Check out the [source codes](https://github.com/yisol/IDM-VTON) and the [model](https://huggingface.co/yisol/IDM-VTON)")
267
+ with gr.Row():
268
  with gr.Column():
269
+ imgs = gr.ImageEditor(sources='upload', type="pil", label='Human. Mask with pen or use auto-masking', interactive=True)
270
+ with gr.Row():
271
+ is_checked = gr.Checkbox(label="Yes", info="Use auto-generated mask (Takes 5 seconds)",value=True)
272
+ with gr.Row():
273
+ is_checked_crop = gr.Checkbox(label="Yes", info="Use auto-crop & resizing",value=False)
274
+
275
+ example = gr.Examples(
276
+ inputs=imgs,
277
+ examples_per_page=10,
278
+ examples=human_ex_list
279
+ )
 
 
 
 
 
 
280
 
281
+ with gr.Column():
282
+ garm_img = gr.Image(label="Garment", sources='upload', type="pil")
283
+ with gr.Row(elem_id="prompt-container"):
284
+ with gr.Row():
285
+ prompt = gr.Textbox(placeholder="Description of garment ex) Short Sleeve Round Neck T-shirts", show_label=False, elem_id="prompt")
286
+ example = gr.Examples(
287
+ inputs=garm_img,
288
+ examples_per_page=8,
289
+ examples=garm_list_path)
290
+ with gr.Column():
291
+ # image_out = gr.Image(label="Output", elem_id="output-img", height=400)
292
+ masked_img = gr.Image(label="Masked image output", elem_id="masked-img",show_share_button=False)
293
+ with gr.Column():
294
+ # image_out = gr.Image(label="Output", elem_id="output-img", height=400)
295
+ image_out = gr.Image(label="Output", elem_id="output-img",show_share_button=False)
296
+
297
+
298
+
299
+
300
+ with gr.Column():
301
+ try_button = gr.Button(value="Try-on")
302
+ with gr.Accordion(label="Advanced Settings", open=False):
303
+ with gr.Row():
304
+ denoise_steps = gr.Number(label="Denoising Steps", minimum=20, maximum=40, value=30, step=1)
305
+ seed = gr.Number(label="Seed", minimum=-1, maximum=2147483647, step=1, value=42)
306
+
307
+
308
+
309
+ try_button.click(fn=start_tryon, inputs=[imgs, garm_img, prompt, is_checked,is_checked_crop, denoise_steps, seed], outputs=[image_out,masked_img], api_name='tryon')
310
+
311
+
312
+
313
+
314
+ image_blocks.launch(share=True)
315
  image_blocks.launch(server_name="0.0.0.0", server_port=7860)
316
+
317
+