Spaces:
Runtime error
Runtime error
Ubuntu
commited on
Commit
ยท
3bc69b8
1
Parent(s):
129f40a
improved inference time
Browse files- .gitignore +21 -0
- app.py +242 -0
- app2.py +391 -0
- checkpoints/openpose/ckpts/body_pose_model.pth +3 -0
- debugging_setps.txt +47 -0
- nohup.out +286 -0
- ootd/inference_ootd.py +3 -0
- ootd/inference_ootd_dc.py +1 -0
- ootd/pipelines_ootd/__pycache__/attention_garm.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/attention_vton.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/pipeline_ootd.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/transformer_garm_2d.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/transformer_vton_2d.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/unet_garm_2d_blocks.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/unet_garm_2d_condition.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/unet_vton_2d_blocks.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/__pycache__/unet_vton_2d_condition.cpython-310.pyc +0 -0
- ootd/pipelines_ootd/pipeline_ootd.py +4 -0
- preprocess/humanparsing/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
- preprocess/humanparsing/datasets/__pycache__/simple_extractor_dataset.cpython-310.pyc +0 -0
- preprocess/humanparsing/run_parsing.py +14 -3
- preprocess/humanparsing/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- preprocess/humanparsing/utils/__pycache__/transforms.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/__pycache__/util.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/__init__.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/body.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/face.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/hand.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/model.cpython-310.pyc +0 -0
- preprocess/openpose/annotator/openpose/__pycache__/util.cpython-310.pyc +0 -0
- preprocess/openpose/model_8.png +0 -0
- preprocess/openpose/run_openpose.py +15 -5
- ps.txt +1 -0
- requirements.txt +2 -1
- run/cloths_db.py +133 -0
- run/gradio_ootd copy_backup.py +380 -0
- run/gradio_ootd.py +221 -142
- test_df.py +24 -0
.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ootd/__pycache__/
|
2 |
+
preprocess/humanparsing/__pycache__/
|
3 |
+
preprocess/openpose/__pycache__/
|
4 |
+
run/__pycache__/
|
5 |
+
face_mask_image.png
|
6 |
+
keypose.png
|
7 |
+
mask_gray_resized.png
|
8 |
+
mask_resized.png
|
9 |
+
masked_vton_img.png
|
10 |
+
model_parse_image.png
|
11 |
+
run/examples/model/male/femal_s_34_test.png
|
12 |
+
run/examples/model/male/femal_s_34.png
|
13 |
+
run/examples/model/male/female.png
|
14 |
+
run/examples/model/male/male_2.png
|
15 |
+
run/examples/model/male/male_2xl_47_5.png
|
16 |
+
run/examples/model/male/male_large_42.png
|
17 |
+
run/examples/model/male/male_medium_40.png
|
18 |
+
run/examples/model/male/male_side.png
|
19 |
+
run/examples/model/male/male_small_38.png
|
20 |
+
run/examples/model/male/male_small.png
|
21 |
+
run/examples/model/male/male_xl_45.png
|
app.py
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify,send_file, Response
|
2 |
+
from flask_cors import CORS
|
3 |
+
import logging
|
4 |
+
import gc
|
5 |
+
import os
|
6 |
+
from io import BytesIO
|
7 |
+
from pathlib import Path
|
8 |
+
import sys
|
9 |
+
import torch
|
10 |
+
from PIL import Image, ImageOps
|
11 |
+
import numpy as np
|
12 |
+
from run.utils_ootd import get_mask_location
|
13 |
+
from run.cloths_db import cloths_map, modeL_db
|
14 |
+
|
15 |
+
from preprocess.openpose.run_openpose import OpenPose
|
16 |
+
from preprocess.humanparsing.run_parsing import Parsing
|
17 |
+
from ootd.inference_ootd_dc import OOTDiffusionDC
|
18 |
+
|
19 |
+
PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute()
|
20 |
+
sys.path.insert(0, str(PROJECT_ROOT))
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
#run python garbage collector and nvidia cuda clear memory
|
25 |
+
gc.collect()
|
26 |
+
torch.cuda.empty_cache()
|
27 |
+
|
28 |
+
|
29 |
+
# Setup Flask server
|
30 |
+
app = Flask(__name__)
|
31 |
+
CORS(app, origins="*") # Enable CORS for the entire app
|
32 |
+
|
33 |
+
|
34 |
+
logger = logging.getLogger()
|
35 |
+
|
36 |
+
|
37 |
+
openpose_model = OpenPose(0)
|
38 |
+
parsing_model_dc = Parsing(0)
|
39 |
+
ootd_model_dc = OOTDiffusionDC(0)
|
40 |
+
|
41 |
+
example_path = os.path.join(os.path.dirname(__file__), 'examples')
|
42 |
+
garment_path = os.path.join(os.path.dirname(__file__), 'examples','garment')
|
43 |
+
|
44 |
+
openpose_model.preprocessor.body_estimation.model.to('cuda')
|
45 |
+
|
46 |
+
ootd_model_dc.pipe.to('cuda')
|
47 |
+
ootd_model_dc.image_encoder.to('cuda')
|
48 |
+
ootd_model_dc.text_encoder.to('cuda')
|
49 |
+
|
50 |
+
category_dict = ['upperbody', 'lowerbody', 'dress']
|
51 |
+
category_dict_utils = ['upper_body', 'lower_body', 'dresses']
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
# Ensure this directory exists
|
56 |
+
UPLOAD_FOLDER = 'temp_images'
|
57 |
+
if not os.path.exists(UPLOAD_FOLDER):
|
58 |
+
os.makedirs(UPLOAD_FOLDER)
|
59 |
+
|
60 |
+
|
61 |
+
def process_dc(vton_img, garm_img, category):
|
62 |
+
model_type = 'dc'
|
63 |
+
|
64 |
+
# if category == 'Upper-body':
|
65 |
+
# category = 0
|
66 |
+
# elif category == 'Lower-body':
|
67 |
+
# category = 1
|
68 |
+
# else:
|
69 |
+
# category = 2
|
70 |
+
|
71 |
+
with torch.no_grad():
|
72 |
+
# openpose_model.preprocessor.body_estimation.model.to('cuda')
|
73 |
+
# ootd_model_dc.pipe.to('cuda')
|
74 |
+
# ootd_model_dc.image_encoder.to('cuda')
|
75 |
+
# ootd_model_dc.text_encoder.to('cuda')
|
76 |
+
|
77 |
+
garm_img = Image.open(garm_img).convert('RGB').resize((768, 1024))
|
78 |
+
vton_img = Image.open(vton_img).convert('RGB').resize((768, 1024))
|
79 |
+
keypoints = openpose_model(vton_img.resize((384, 512)))
|
80 |
+
|
81 |
+
print(len(keypoints["pose_keypoints_2d"]))
|
82 |
+
print(keypoints["pose_keypoints_2d"])
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
left_point = keypoints["pose_keypoints_2d"][2]
|
87 |
+
right_point = keypoints["pose_keypoints_2d"][5]
|
88 |
+
|
89 |
+
neck_point = keypoints["pose_keypoints_2d"][1]
|
90 |
+
hip_point = keypoints["pose_keypoints_2d"][8]
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
print(f'left shoulder - {left_point}')
|
95 |
+
print(f'right shoulder - {right_point}')
|
96 |
+
|
97 |
+
# #find disctance using Euclidian distance
|
98 |
+
shoulder_width_pixels = round(np.sqrt( np.power((right_point[0]-left_point[0]),2) + np.power((right_point[1]-left_point[1]),2)),2)
|
99 |
+
|
100 |
+
height_pixels = round(np.sqrt( np.power((neck_point[0]-hip_point[0]),2) + np.power((neck_point[1]-hip_point[1]),2)),2) *2
|
101 |
+
|
102 |
+
|
103 |
+
# # Assuming an average human height
|
104 |
+
average_height_cm = 172.72 *1.5
|
105 |
+
|
106 |
+
# Conversion factor from pixels to cm
|
107 |
+
conversion_factor = average_height_cm / height_pixels
|
108 |
+
|
109 |
+
# Convert shoulder width to real-world units
|
110 |
+
shoulder_width_cm = shoulder_width_pixels * conversion_factor
|
111 |
+
|
112 |
+
print(f'Shoulder width (in pixels): {shoulder_width_pixels}')
|
113 |
+
print(f'Estimated height (in pixels): {height_pixels}')
|
114 |
+
print(f'Conversion factor (pixels to cm): {conversion_factor}')
|
115 |
+
print(f'Shoulder width (in cm): {shoulder_width_cm}')
|
116 |
+
print(f'Shoulder width (in INCH): {round(shoulder_width_cm/2.54,1)}')
|
117 |
+
|
118 |
+
|
119 |
+
model_parse,_ = parsing_model_dc(vton_img.resize((384, 512)))
|
120 |
+
|
121 |
+
|
122 |
+
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
mask = mask.resize((768, 1024), Image.NEAREST)
|
127 |
+
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
128 |
+
# Save the resized masks
|
129 |
+
# mask.save("mask_resized.png")
|
130 |
+
# mask_gray.save("mask_gray_resized.png")
|
131 |
+
|
132 |
+
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
133 |
+
# masked_vton_img.save("masked_vton_img.png")
|
134 |
+
|
135 |
+
print(f'category is {category}')
|
136 |
+
|
137 |
+
images = ootd_model_dc(
|
138 |
+
model_type=model_type,
|
139 |
+
category=category_dict[category],
|
140 |
+
image_garm=garm_img,
|
141 |
+
image_vton=masked_vton_img,
|
142 |
+
mask=mask,
|
143 |
+
image_ori=vton_img,
|
144 |
+
num_samples=1,
|
145 |
+
num_steps=10,
|
146 |
+
image_scale= 1.0,
|
147 |
+
seed=-1,
|
148 |
+
)
|
149 |
+
|
150 |
+
return images
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
@app.route('/')
|
155 |
+
def root():
|
156 |
+
try:
|
157 |
+
response_data = {"message": "This is VTR API v1.0"}
|
158 |
+
return jsonify(response_data)
|
159 |
+
except Exception as e:
|
160 |
+
logger.error(f"Root endpoint error: {str(e)}")
|
161 |
+
response_data = {"message": "Internal server Error"}
|
162 |
+
return jsonify(response_data), 500
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
#write Flask api name "generate" with POST method that will input 2 images and return 1 image
|
167 |
+
@app.route('/generate', methods=['POST'])
|
168 |
+
def generate():
|
169 |
+
"""
|
170 |
+
A Flask route that handles a POST request to the '/generate' endpoint.
|
171 |
+
It expects two files, 'garm_img' and 'vton_img', to be included in the request.
|
172 |
+
The function calls the 'process_dc' function with the provided files and the
|
173 |
+
category 'Upper-body'. It then sends the processed image as a file with the
|
174 |
+
mimetype 'image/png' and returns it to the client. If any exception occurs,
|
175 |
+
the function logs the error and returns a JSON response with a status code of
|
176 |
+
500.
|
177 |
+
|
178 |
+
Parameters:
|
179 |
+
None
|
180 |
+
|
181 |
+
Returns:
|
182 |
+
A Flask response object with the processed image as a file.
|
183 |
+
|
184 |
+
Raises:
|
185 |
+
None
|
186 |
+
"""
|
187 |
+
|
188 |
+
# if category == 'Upper-body':
|
189 |
+
# category = 0
|
190 |
+
# elif category == 'Lower-body':
|
191 |
+
# category = 1
|
192 |
+
# else:
|
193 |
+
# category = 2
|
194 |
+
|
195 |
+
try:
|
196 |
+
garm_img = request.files['garm_img']
|
197 |
+
vton_img = request.files['vton_img']
|
198 |
+
category = 0 # Default to Upper-body if not specified
|
199 |
+
|
200 |
+
# Save the uploaded files
|
201 |
+
garm_path = os.path.join(UPLOAD_FOLDER, 'garm_input.png')
|
202 |
+
vton_path = os.path.join(UPLOAD_FOLDER, 'vton_input.png')
|
203 |
+
|
204 |
+
garm_img.save(garm_path)
|
205 |
+
vton_img.save(vton_path)
|
206 |
+
|
207 |
+
# Convert file objects to bytes IO objects
|
208 |
+
# garm_img = BytesIO(garm_img.read())
|
209 |
+
# vton_img = BytesIO(vton_img.read())
|
210 |
+
|
211 |
+
output_images = process_dc(garm_img=garm_img,
|
212 |
+
vton_img=vton_img,
|
213 |
+
category=category)
|
214 |
+
|
215 |
+
if not output_images:
|
216 |
+
return Response("No output image generated", status=500)
|
217 |
+
|
218 |
+
output_image = output_images[0] # Get the first image
|
219 |
+
|
220 |
+
# Convert PIL Image to bytes
|
221 |
+
img_byte_arr = BytesIO()
|
222 |
+
output_image.save(img_byte_arr, format='PNG')
|
223 |
+
img_byte_arr = img_byte_arr.getvalue()
|
224 |
+
|
225 |
+
return Response(img_byte_arr, mimetype='image/png')
|
226 |
+
|
227 |
+
except Exception as e:
|
228 |
+
print(f"Error: {str(e)}") # Log the error
|
229 |
+
return Response(str(e), status=500)
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
|
234 |
+
|
235 |
+
|
236 |
+
if __name__ == '__main__':
|
237 |
+
app.run(debug=False, host='0.0.0.0', port=5009)
|
238 |
+
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
+
# nohup gunicorn -b 0.0.0.0:5003 sentiment_api:app &
|
app2.py
ADDED
@@ -0,0 +1,391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify,send_file, Response
|
2 |
+
from flask_cors import CORS
|
3 |
+
import logging
|
4 |
+
import gc
|
5 |
+
import os
|
6 |
+
from threading import Thread
|
7 |
+
from flask_sse import sse
|
8 |
+
import uuid
|
9 |
+
import redis
|
10 |
+
import multiprocessing
|
11 |
+
from werkzeug.exceptions import NotFound, InternalServerError
|
12 |
+
import threading
|
13 |
+
from collections import OrderedDict
|
14 |
+
|
15 |
+
from flask import current_app
|
16 |
+
|
17 |
+
import time
|
18 |
+
from celery import Celery
|
19 |
+
from io import BytesIO
|
20 |
+
from pathlib import Path
|
21 |
+
import sys
|
22 |
+
import torch
|
23 |
+
from PIL import Image, ImageOps
|
24 |
+
import numpy as np
|
25 |
+
from run.utils_ootd import get_mask_location
|
26 |
+
from run.cloths_db import cloths_map, modeL_db
|
27 |
+
|
28 |
+
from preprocess.openpose.run_openpose import OpenPose
|
29 |
+
from preprocess.humanparsing.run_parsing import Parsing
|
30 |
+
from ootd.inference_ootd_dc import OOTDiffusionDC
|
31 |
+
|
32 |
+
PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute()
|
33 |
+
sys.path.insert(0, str(PROJECT_ROOT))
|
34 |
+
|
35 |
+
from queue import Queue
|
36 |
+
|
37 |
+
from celery_worker import process_image
|
38 |
+
|
39 |
+
|
40 |
+
#run python garbage collector and nvidia cuda clear memory
|
41 |
+
gc.collect()
|
42 |
+
torch.cuda.empty_cache()
|
43 |
+
|
44 |
+
# Set the start method to 'spawn'
|
45 |
+
# multiprocessing.set_start_method('spawn', force=True)
|
46 |
+
|
47 |
+
# Setup Flask server
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
app = Flask(__name__)
|
53 |
+
app.config.update(
|
54 |
+
CELERY_BROKER_URL='redis://localhost:6379',
|
55 |
+
CELERY_RESULT_BACKEND='redis://localhost:6379'
|
56 |
+
)
|
57 |
+
|
58 |
+
# Initialize Celery
|
59 |
+
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
|
60 |
+
celery.conf.update(app.config)
|
61 |
+
logger = logging.getLogger()
|
62 |
+
|
63 |
+
|
64 |
+
openpose_model = OpenPose(0)
|
65 |
+
parsing_model_dc = Parsing(0)
|
66 |
+
ootd_model_dc = OOTDiffusionDC(0)
|
67 |
+
|
68 |
+
example_path = os.path.join(os.path.dirname(__file__), 'examples')
|
69 |
+
garment_path = os.path.join(os.path.dirname(__file__), 'examples','garment')
|
70 |
+
|
71 |
+
openpose_model.preprocessor.body_estimation.model.to('cuda')
|
72 |
+
|
73 |
+
ootd_model_dc.pipe.to('cuda')
|
74 |
+
ootd_model_dc.image_encoder.to('cuda')
|
75 |
+
ootd_model_dc.text_encoder.to('cuda')
|
76 |
+
|
77 |
+
category_dict = ['upperbody', 'lowerbody', 'dress']
|
78 |
+
category_dict_utils = ['upper_body', 'lower_body', 'dresses']
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
# Ensure this directory exists
|
83 |
+
UPLOAD_FOLDER = 'temp_images'
|
84 |
+
if not os.path.exists(UPLOAD_FOLDER):
|
85 |
+
os.makedirs(UPLOAD_FOLDER)
|
86 |
+
|
87 |
+
|
88 |
+
OUTPUT_FOLDER = 'path/to/output/folder'
|
89 |
+
image_results = {}
|
90 |
+
image_results_lock = threading.Lock()
|
91 |
+
|
92 |
+
|
93 |
+
# Use an OrderedDict to limit the number of stored results
|
94 |
+
image_results = OrderedDict()
|
95 |
+
MAX_RESULTS = 100 # Adjust this value based on your needs
|
96 |
+
|
97 |
+
def process_dc(vton_img, garm_img, category,progress_callback):
|
98 |
+
model_type = 'dc'
|
99 |
+
|
100 |
+
if category == 'Upper-body':
|
101 |
+
category = 0
|
102 |
+
elif category == 'Lower-body':
|
103 |
+
category = 1
|
104 |
+
else:
|
105 |
+
category = 2
|
106 |
+
|
107 |
+
with torch.no_grad():
|
108 |
+
# openpose_model.preprocessor.body_estimation.model.to('cuda')
|
109 |
+
# ootd_model_dc.pipe.to('cuda')
|
110 |
+
# ootd_model_dc.image_encoder.to('cuda')
|
111 |
+
# ootd_model_dc.text_encoder.to('cuda')
|
112 |
+
|
113 |
+
garm_img = Image.open(garm_img).resize((768, 1024))
|
114 |
+
vton_img = Image.open(vton_img).resize((768, 1024))
|
115 |
+
keypoints = openpose_model(vton_img.resize((384, 512)))
|
116 |
+
|
117 |
+
print(len(keypoints["pose_keypoints_2d"]))
|
118 |
+
print(keypoints["pose_keypoints_2d"])
|
119 |
+
|
120 |
+
|
121 |
+
|
122 |
+
left_point = keypoints["pose_keypoints_2d"][2]
|
123 |
+
right_point = keypoints["pose_keypoints_2d"][5]
|
124 |
+
|
125 |
+
neck_point = keypoints["pose_keypoints_2d"][1]
|
126 |
+
hip_point = keypoints["pose_keypoints_2d"][8]
|
127 |
+
|
128 |
+
|
129 |
+
|
130 |
+
print(f'left shoulder - {left_point}')
|
131 |
+
print(f'right shoulder - {right_point}')
|
132 |
+
|
133 |
+
# #find disctance using Euclidian distance
|
134 |
+
shoulder_width_pixels = round(np.sqrt( np.power((right_point[0]-left_point[0]),2) + np.power((right_point[1]-left_point[1]),2)),2)
|
135 |
+
|
136 |
+
height_pixels = round(np.sqrt( np.power((neck_point[0]-hip_point[0]),2) + np.power((neck_point[1]-hip_point[1]),2)),2) *2
|
137 |
+
|
138 |
+
|
139 |
+
# # Assuming an average human height
|
140 |
+
average_height_cm = 172.72 *1.5
|
141 |
+
|
142 |
+
# Conversion factor from pixels to cm
|
143 |
+
conversion_factor = average_height_cm / height_pixels
|
144 |
+
|
145 |
+
# Convert shoulder width to real-world units
|
146 |
+
shoulder_width_cm = shoulder_width_pixels * conversion_factor
|
147 |
+
|
148 |
+
print(f'Shoulder width (in pixels): {shoulder_width_pixels}')
|
149 |
+
print(f'Estimated height (in pixels): {height_pixels}')
|
150 |
+
print(f'Conversion factor (pixels to cm): {conversion_factor}')
|
151 |
+
print(f'Shoulder width (in cm): {shoulder_width_cm}')
|
152 |
+
print(f'Shoulder width (in INCH): {round(shoulder_width_cm/2.54,1)}')
|
153 |
+
|
154 |
+
|
155 |
+
model_parse,_ = parsing_model_dc(vton_img.resize((384, 512)))
|
156 |
+
|
157 |
+
|
158 |
+
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
159 |
+
|
160 |
+
|
161 |
+
|
162 |
+
mask = mask.resize((768, 1024), Image.NEAREST)
|
163 |
+
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
164 |
+
# Save the resized masks
|
165 |
+
# mask.save("mask_resized.png")
|
166 |
+
# mask_gray.save("mask_gray_resized.png")
|
167 |
+
|
168 |
+
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
169 |
+
# masked_vton_img.save("masked_vton_img.png")
|
170 |
+
|
171 |
+
print(f'category is {category}')
|
172 |
+
|
173 |
+
# images = ootd_model_dc(
|
174 |
+
# model_type=model_type,
|
175 |
+
# category=category_dict[category],
|
176 |
+
# image_garm=garm_img,
|
177 |
+
# image_vton=masked_vton_img,
|
178 |
+
# mask=mask,
|
179 |
+
# image_ori=vton_img,
|
180 |
+
# num_samples=3,
|
181 |
+
# num_steps=20,
|
182 |
+
# image_scale= 2.0,
|
183 |
+
# seed=-1,
|
184 |
+
# )
|
185 |
+
|
186 |
+
images = ootd_model_dc(
|
187 |
+
model_type=model_type,
|
188 |
+
category=category_dict[category],
|
189 |
+
image_garm=garm_img,
|
190 |
+
image_vton=masked_vton_img,
|
191 |
+
mask=mask,
|
192 |
+
image_ori=vton_img,
|
193 |
+
num_samples=2,
|
194 |
+
num_steps=10,
|
195 |
+
image_scale=2.0,
|
196 |
+
seed=42,
|
197 |
+
progress_callback=progress_callback,
|
198 |
+
progress_interval=1, # Update progress every step
|
199 |
+
)
|
200 |
+
|
201 |
+
|
202 |
+
return images
|
203 |
+
|
204 |
+
|
205 |
+
|
206 |
+
# def create_progress_callback(session_id):
|
207 |
+
# def progress_callback(step, total_steps):
|
208 |
+
# progress = int((step + 1) / total_steps * 100)
|
209 |
+
# print(f"Publishing progress {progress} for session {session_id}")
|
210 |
+
# sse.publish({"progress": progress}, type='progress', channel=session_id)
|
211 |
+
# return progress_callback
|
212 |
+
|
213 |
+
# @celery.task(bind=True)
|
214 |
+
# def process_image(self, session_id, garm_path, vton_path, category):
|
215 |
+
# try:
|
216 |
+
# print(f"Starting process_image task for session {session_id}")
|
217 |
+
|
218 |
+
# progress_callback = create_progress_callback(session_id)
|
219 |
+
|
220 |
+
# output_images = process_dc(garm_img=garm_path,
|
221 |
+
# vton_img=vton_path,
|
222 |
+
# category=category,
|
223 |
+
# progress_callback=progress_callback)
|
224 |
+
|
225 |
+
# if not output_images:
|
226 |
+
# sse.publish({"error": "No output image generated"}, type='error', channel=session_id)
|
227 |
+
# return None
|
228 |
+
|
229 |
+
# output_image = output_images[0]
|
230 |
+
|
231 |
+
# # Generate a UUID for the output image
|
232 |
+
# image_uuid = str(uuid.uuid4())
|
233 |
+
|
234 |
+
# # Create the output filename with the UUID
|
235 |
+
# output_filename = f"{image_uuid}.png"
|
236 |
+
# output_path = os.path.join(OUTPUT_FOLDER, output_filename)
|
237 |
+
|
238 |
+
# # Save the output image
|
239 |
+
# output_image.save(output_path, format='PNG')
|
240 |
+
|
241 |
+
# # Add the UUID and path to the image_results map
|
242 |
+
# with image_results_lock:
|
243 |
+
# image_results[image_uuid] = output_path
|
244 |
+
|
245 |
+
# sse.publish({"message": "Processing complete", "uuid": image_uuid}, type='complete', channel=session_id)
|
246 |
+
|
247 |
+
# return image_uuid
|
248 |
+
|
249 |
+
# except Exception as e:
|
250 |
+
# sse.publish({"error": str(e)}, type='error', channel=session_id)
|
251 |
+
# return print(f"panic in process_image: {str(e)}")
|
252 |
+
|
253 |
+
|
254 |
+
@app.route('/')
|
255 |
+
def root():
|
256 |
+
try:
|
257 |
+
response_data = {"message": "This is VTR API v1.0"}
|
258 |
+
return jsonify(response_data)
|
259 |
+
except Exception as e:
|
260 |
+
logger.error(f"Root endpoint error: {str(e)}")
|
261 |
+
response_data = {"message": "Internal server Error"}
|
262 |
+
return jsonify(response_data), 500
|
263 |
+
|
264 |
+
|
265 |
+
# @app.route('/stream')
|
266 |
+
# def stream():
|
267 |
+
# session_id = request.args.get('channel')
|
268 |
+
# if not session_id:
|
269 |
+
# return "No channel specified", 400
|
270 |
+
# return Response(sse.stream(), content_type='text/event-stream')
|
271 |
+
|
272 |
+
@app.route('/test_sse/<session_id>')
|
273 |
+
def test_sse(session_id):
|
274 |
+
sse.publish({"message": "Test SSE"}, type='test', channel=session_id)
|
275 |
+
return "SSE test message sent"
|
276 |
+
|
277 |
+
#write Flask api name "generate" with POST method that will input 2 images and return 1 image
|
278 |
+
@app.route('/generate', methods=['POST'])
|
279 |
+
def generate():
|
280 |
+
"""
|
281 |
+
A Flask route that handles a POST request to the '/generate' endpoint.
|
282 |
+
It expects two files, 'garm_img' and 'vton_img', to be included in the request.
|
283 |
+
The function calls the 'process_dc' function with the provided files and the
|
284 |
+
category 'Upper-body'. It then sends the processed image as a file with the
|
285 |
+
mimetype 'image/png' and returns it to the client. If any exception occurs,
|
286 |
+
the function logs the error and returns a JSON response with a status code of
|
287 |
+
500.
|
288 |
+
|
289 |
+
Parameters:
|
290 |
+
None
|
291 |
+
|
292 |
+
Returns:
|
293 |
+
A Flask response object with the processed image as a file.
|
294 |
+
|
295 |
+
Raises:
|
296 |
+
None
|
297 |
+
"""
|
298 |
+
|
299 |
+
# if category == 'Upper-body':
|
300 |
+
# category = 0
|
301 |
+
# elif category == 'Lower-body':
|
302 |
+
# category = 1
|
303 |
+
# else:
|
304 |
+
# category = 2
|
305 |
+
|
306 |
+
try:
|
307 |
+
cloths_type = ["Upper-body", "Lower-body", "Dress"]
|
308 |
+
garm_img = request.files['garm_img']
|
309 |
+
vton_img = request.files['vton_img']
|
310 |
+
cat = request.form['category']
|
311 |
+
|
312 |
+
print(f'category is {cat}')
|
313 |
+
|
314 |
+
category =cloths_type[int(cat)] # Default to Upper-body if not specified
|
315 |
+
|
316 |
+
# Save the uploaded files
|
317 |
+
garm_path = os.path.join(UPLOAD_FOLDER, 'garm_input.png')
|
318 |
+
vton_path = os.path.join(UPLOAD_FOLDER, 'vton_input.png')
|
319 |
+
|
320 |
+
garm_img.save(garm_path)
|
321 |
+
vton_img.save(vton_path)
|
322 |
+
|
323 |
+
# Convert file objects to bytes IO objects
|
324 |
+
# garm_img = BytesIO(garm_img.read())
|
325 |
+
# vton_img = BytesIO(vton_img.read())
|
326 |
+
|
327 |
+
# Start processing in a background task
|
328 |
+
|
329 |
+
session_id = str(uuid.uuid4())
|
330 |
+
|
331 |
+
|
332 |
+
process_image.apply_async(args=[session_id, garm_path, vton_path, category])
|
333 |
+
|
334 |
+
# Immediately return the session_id to the client
|
335 |
+
return jsonify({"session_id": session_id, "message": "Processing started"}), 202
|
336 |
+
|
337 |
+
# while not task.ready():
|
338 |
+
# time.sleep(1) # Polling the task status every second
|
339 |
+
|
340 |
+
# if task.successful():
|
341 |
+
# img_byte_arr = task.result
|
342 |
+
# if img_byte_arr:
|
343 |
+
# return Response(img_byte_arr, mimetype='image/png')
|
344 |
+
# else:
|
345 |
+
# return Response("No output image generated", status=500)
|
346 |
+
# else:
|
347 |
+
# return Response("Processing failed", status=500)
|
348 |
+
|
349 |
+
|
350 |
+
|
351 |
+
except Exception as e:
|
352 |
+
print(f"Error: {str(e)}") # Log the error
|
353 |
+
return Response(str(e), status=500)
|
354 |
+
|
355 |
+
|
356 |
+
|
357 |
+
@app.route('/get_image/<uuid>')
|
358 |
+
def get_image(uuid):
|
359 |
+
try:
|
360 |
+
with image_results_lock:
|
361 |
+
if uuid not in image_results:
|
362 |
+
raise NotFound("Invalid UUID or result not available")
|
363 |
+
|
364 |
+
image_path = image_results[uuid]
|
365 |
+
|
366 |
+
if not os.path.exists(image_path):
|
367 |
+
raise NotFound("Image file not found")
|
368 |
+
|
369 |
+
# Determine the MIME type based on the file extension
|
370 |
+
file_extension = os.path.splitext(image_path)[1].lower()
|
371 |
+
mime_type = 'image/jpeg' if file_extension == '.jpg' or file_extension == '.jpeg' else 'image/png'
|
372 |
+
|
373 |
+
return send_file(image_path, mimetype=mime_type, as_attachment=False)
|
374 |
+
|
375 |
+
except NotFound as e:
|
376 |
+
logger.warning(f"Get image request failed: {str(e)}")
|
377 |
+
return jsonify({"error": str(e)}), 404
|
378 |
+
|
379 |
+
except Exception as e:
|
380 |
+
logger.error(f"Unexpected error in get_image: {str(e)}")
|
381 |
+
return jsonify({"error": "An unexpected error occurred"}), 500
|
382 |
+
|
383 |
+
|
384 |
+
|
385 |
+
if __name__ == '__main__':
|
386 |
+
app.run(debug=False, host='0.0.0.0', port=5009)
|
387 |
+
|
388 |
+
|
389 |
+
|
390 |
+
|
391 |
+
# nohup gunicorn -b 0.0.0.0:5003 sentiment_api:app &
|
checkpoints/openpose/ckpts/body_pose_model.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25a948c16078b0f08e236bda51a385d855ef4c153598947c28c0d47ed94bb746
|
3 |
+
size 209267595
|
debugging_setps.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
initial inference time - 30-40 sec ๐
|
2 |
+
|
3 |
+
1) lowered num_steps for diffusion model to 10 from 20 - inference time = 17-19 sec ๐
|
4 |
+
|
5 |
+
2) moved onxx model from cpu compute to gpu - inference time = 12-14 sec cold start take more time ๐
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
working
|
11 |
+
|
12 |
+
1 preprocess images -
|
13 |
+
first target human image preprocess with openpose and humanparse
|
14 |
+
openpose - to get pose information of joints
|
15 |
+
humanparse- to segment image with diffrent part like face, body , background that we can use to
|
16 |
+
determine where to do diffusion using mask
|
17 |
+
|
18 |
+
merging mask from humanparse on original human image that will we feed into diffusion model
|
19 |
+
|
20 |
+
processing cloth image -
|
21 |
+
|
22 |
+
with torch.no_grad():
|
23 |
+
prompt_image = self.auto_processor(images=image_garm, return_tensors="pt").to('cuda')
|
24 |
+
prompt_image = self.image_encoder(prompt_image.data['pixel_values']).image_embeds
|
25 |
+
prompt_image = prompt_image.unsqueeze(1)
|
26 |
+
if model_type == 'hd':
|
27 |
+
prompt_embeds = self.text_encoder(self.tokenize_captions([""], 2).to('cuda'))[0]
|
28 |
+
prompt_embeds[:, 1:] = prompt_image[:]
|
29 |
+
elif model_type == 'dc':
|
30 |
+
prompt_embeds = self.text_encoder(self.tokenize_captions([category], 3).to('cuda'))[0]
|
31 |
+
prompt_embeds = torch.cat([prompt_embeds, prompt_image], dim=1)
|
32 |
+
|
33 |
+
|
34 |
+
this will convert cloth image into image embedding and generate prompt embedding using category we provide
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
GatedSelfAttentionDense: This class combines visual features and object features using self-attention.
|
39 |
+
It's likely used to fuse information about the clothing items with the human body image.
|
40 |
+
|
41 |
+
2 at last we feed both human masked image and
|
42 |
+
cloth image embedding and prompt embedding concated - [image_embeds, prompt_embeds]
|
43 |
+
into diffusion model then running inference the diffusion model -
|
44 |
+
first it will convert image input as latent embedding using VAE ,
|
45 |
+
then perform difussion with paramter we provided, samples, num_steps, noise, seed, etc
|
46 |
+
after num of steps of diffusion we convert that output again in image spce using VAE
|
47 |
+
and thats our output image
|
nohup.out
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
1 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
2 |
0%| | 0/10 [00:00<?, ?it/s]
|
3 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
4 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
5 |
30%|โโโ | 3/10 [00:05<00:12, 1.76s/it]
|
6 |
40%|โโโโ | 4/10 [00:06<00:10, 1.69s/it]
|
7 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.67s/it]
|
8 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
9 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.64s/it]
|
10 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
11 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
13 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
14 |
0%| | 0/10 [00:00<?, ?it/s]
|
15 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
16 |
20%|โโ | 2/10 [00:03<00:13, 1.75s/it]
|
17 |
30%|โโโ | 3/10 [00:05<00:11, 1.67s/it]
|
18 |
40%|โโโโ | 4/10 [00:06<00:09, 1.65s/it]
|
19 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.63s/it]
|
20 |
60%|โโโโโโ | 6/10 [00:09<00:06, 1.61s/it]
|
21 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.61s/it]
|
22 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.60s/it]
|
23 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.60s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
25 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
26 |
0%| | 0/10 [00:00<?, ?it/s]
|
27 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
28 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
29 |
30%|โโโ | 3/10 [00:05<00:11, 1.70s/it]
|
30 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
31 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
32 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
33 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
34 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
35 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
37 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
38 |
0%| | 0/10 [00:00<?, ?it/s]
|
39 |
10%|โ | 1/10 [00:02<00:18, 2.03s/it]
|
40 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
41 |
30%|โโโ | 3/10 [00:05<00:13, 1.95s/it]
|
42 |
40%|โโโโ | 4/10 [00:07<00:10, 1.81s/it]
|
43 |
50%|โโโโโ | 5/10 [00:09<00:08, 1.75s/it]
|
44 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.70s/it]
|
45 |
70%|โโโโโโโ | 7/10 [00:12<00:05, 1.68s/it]
|
46 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.66s/it]
|
47 |
90%|โโโโโโโโโ | 9/10 [00:15<00:01, 1.64s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
49 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
50 |
0%| | 0/10 [00:00<?, ?it/s]
|
51 |
10%|โ | 1/10 [00:01<00:17, 2.00s/it]
|
52 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
53 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
54 |
40%|โโโโ | 4/10 [00:06<00:09, 1.67s/it]
|
55 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
56 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
57 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
58 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
59 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
61 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
62 |
0%| | 0/10 [00:00<?, ?it/s]
|
63 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
64 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
65 |
30%|โโโ | 3/10 [00:05<00:11, 1.70s/it]
|
66 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
67 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
68 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
69 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
70 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
71 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
73 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
74 |
0%| | 0/10 [00:00<?, ?it/s]
|
75 |
10%|โ | 1/10 [00:02<00:18, 2.02s/it]
|
76 |
20%|โโ | 2/10 [00:03<00:14, 1.79s/it]
|
77 |
30%|โโโ | 3/10 [00:05<00:11, 1.71s/it]
|
78 |
40%|โโโโ | 4/10 [00:06<00:10, 1.68s/it]
|
79 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
80 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
81 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
82 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
83 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
85 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
86 |
0%| | 0/10 [00:00<?, ?it/s]
|
87 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
88 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
89 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
90 |
40%|โโโโ | 4/10 [00:06<00:09, 1.65s/it]
|
91 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
92 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
93 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
94 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
95 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
97 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
98 |
0%| | 0/10 [00:00<?, ?it/s]
|
99 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
100 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
101 |
30%|โโโ | 3/10 [00:05<00:11, 1.71s/it]
|
102 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
103 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
104 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
105 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
106 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
107 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
109 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
110 |
0%| | 0/10 [00:00<?, ?it/s]
|
111 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
112 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
113 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
114 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
115 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
116 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
117 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
118 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
119 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
121 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
122 |
0%| | 0/10 [00:00<?, ?it/s]
|
123 |
10%|โ | 1/10 [00:01<00:17, 2.00s/it]
|
124 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
125 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
126 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
127 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
128 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
129 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
130 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
131 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
133 |
0%| | 0/1 [00:00<?, ?it/s]
|
|
|
|
|
|
|
134 |
0%| | 0/10 [00:00<?, ?it/s]
|
135 |
10%|โ | 1/10 [00:02<00:18, 2.03s/it]
|
136 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
137 |
30%|โโโ | 3/10 [00:06<00:16, 2.39s/it]
|
138 |
40%|โโโโ | 4/10 [00:08<00:12, 2.08s/it]
|
139 |
50%|โโโโโ | 5/10 [00:09<00:09, 1.91s/it]
|
140 |
60%|โโโโโโ | 6/10 [00:11<00:07, 1.81s/it]
|
141 |
70%|โโโโโโโ | 7/10 [00:13<00:05, 1.74s/it]
|
142 |
80%|โโโโโโโโ | 8/10 [00:14<00:03, 1.70s/it]
|
143 |
90%|โโโโโโโโโ | 9/10 [00:16<00:01, 1.67s/it]
|
|
|
1 |
+
|
2 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
3 |
+
warnings.warn(
|
4 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
5 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
6 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
7 |
+
|
8 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
9 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
10 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
11 |
+
IMPORTANT: You are using gradio version 4.16.0, however version 4.29.0 is available, please upgrade.
|
12 |
+
--------
|
13 |
+
Running on local URL: http://0.0.0.0:7860
|
14 |
+
|
15 |
+
To create a public link, set `share=True` in `launch()`.
|
16 |
+
left shoulder - [151.0, 99.0]
|
17 |
+
right shoulder - [233.0, 107.0]
|
18 |
+
Shoulder width (in pixels): 82.39
|
19 |
+
Estimated height (in pixels): 248.68
|
20 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
21 |
+
Shoulder width (in cm): 85.83561685700498
|
22 |
+
Shoulder width (in INCH): 33.8
|
23 |
+
|
24 |
0%| | 0/1 [00:00<?, ?it/s]
|
25 |
+
|
26 |
0%| | 0/1 [00:00<?, ?it/s]
|
27 |
+
Initial seed: 300557857
|
28 |
+
promt is None
|
29 |
+
|
30 |
0%| | 0/10 [00:00<?, ?it/s]
|
31 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
32 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
33 |
30%|โโโ | 3/10 [00:05<00:12, 1.76s/it]
|
34 |
40%|โโโโ | 4/10 [00:06<00:10, 1.69s/it]
|
35 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.67s/it]
|
36 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
37 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.64s/it]
|
38 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
39 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
40 |
+
WARNING: Invalid HTTP request received.
|
41 |
+
WARNING: Invalid HTTP request received.
|
42 |
+
WARNING: Invalid HTTP request received.
|
43 |
+
WARNING: Invalid HTTP request received.
|
44 |
+
left shoulder - [151.0, 99.0]
|
45 |
+
right shoulder - [233.0, 107.0]
|
46 |
+
Shoulder width (in pixels): 82.39
|
47 |
+
Estimated height (in pixels): 248.68
|
48 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
49 |
+
Shoulder width (in cm): 85.83561685700498
|
50 |
+
Shoulder width (in INCH): 33.8
|
51 |
+
|
52 |
0%| | 0/1 [00:00<?, ?it/s]
|
53 |
+
|
54 |
0%| | 0/1 [00:00<?, ?it/s]
|
55 |
+
Initial seed: 1492618498
|
56 |
+
promt is None
|
57 |
+
|
58 |
0%| | 0/10 [00:00<?, ?it/s]
|
59 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
60 |
20%|โโ | 2/10 [00:03<00:13, 1.75s/it]
|
61 |
30%|โโโ | 3/10 [00:05<00:11, 1.67s/it]
|
62 |
40%|โโโโ | 4/10 [00:06<00:09, 1.65s/it]
|
63 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.63s/it]
|
64 |
60%|โโโโโโ | 6/10 [00:09<00:06, 1.61s/it]
|
65 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.61s/it]
|
66 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.60s/it]
|
67 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.60s/it]
|
68 |
+
left shoulder - [151.0, 99.0]
|
69 |
+
right shoulder - [233.0, 107.0]
|
70 |
+
Shoulder width (in pixels): 82.39
|
71 |
+
Estimated height (in pixels): 248.68
|
72 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
73 |
+
Shoulder width (in cm): 85.83561685700498
|
74 |
+
Shoulder width (in INCH): 33.8
|
75 |
+
|
76 |
0%| | 0/1 [00:00<?, ?it/s]
|
77 |
+
|
78 |
0%| | 0/1 [00:00<?, ?it/s]
|
79 |
+
Initial seed: 654897631
|
80 |
+
promt is None
|
81 |
+
|
82 |
0%| | 0/10 [00:00<?, ?it/s]
|
83 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
84 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
85 |
30%|โโโ | 3/10 [00:05<00:11, 1.70s/it]
|
86 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
87 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
88 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
89 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
90 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
91 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
92 |
+
Traceback (most recent call last):
|
93 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 1, in <module>
|
94 |
+
import gradio as gr
|
95 |
+
ModuleNotFoundError: No module named 'gradio'
|
96 |
+
Traceback (most recent call last):
|
97 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 1, in <module>
|
98 |
+
import gradio as gr
|
99 |
+
ModuleNotFoundError: No module named 'gradio'
|
100 |
+
Traceback (most recent call last):
|
101 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 1, in <module>
|
102 |
+
import gradio as gr
|
103 |
+
ModuleNotFoundError: No module named 'gradio'
|
104 |
+
Traceback (most recent call last):
|
105 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 1, in <module>
|
106 |
+
import gradio as gr
|
107 |
+
ModuleNotFoundError: No module named 'gradio'
|
108 |
+
|
109 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
110 |
+
warnings.warn(
|
111 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
112 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
113 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
114 |
+
|
115 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
116 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
117 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
118 |
+
IMPORTANT: You are using gradio version 4.16.0, however version 4.29.0 is available, please upgrade.
|
119 |
+
--------
|
120 |
+
Running on local URL: http://0.0.0.0:7860
|
121 |
+
|
122 |
+
To create a public link, set `share=True` in `launch()`.
|
123 |
+
left shoulder - [151.0, 99.0]
|
124 |
+
right shoulder - [233.0, 107.0]
|
125 |
+
Shoulder width (in pixels): 82.39
|
126 |
+
Estimated height (in pixels): 248.68
|
127 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
128 |
+
Shoulder width (in cm): 85.83561685700498
|
129 |
+
Shoulder width (in INCH): 33.8
|
130 |
+
|
131 |
0%| | 0/1 [00:00<?, ?it/s]
|
132 |
+
|
133 |
0%| | 0/1 [00:00<?, ?it/s]
|
134 |
+
Initial seed: 1082385134
|
135 |
+
promt is None
|
136 |
+
|
137 |
0%| | 0/10 [00:00<?, ?it/s]
|
138 |
10%|โ | 1/10 [00:02<00:18, 2.03s/it]
|
139 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
140 |
30%|โโโ | 3/10 [00:05<00:13, 1.95s/it]
|
141 |
40%|โโโโ | 4/10 [00:07<00:10, 1.81s/it]
|
142 |
50%|โโโโโ | 5/10 [00:09<00:08, 1.75s/it]
|
143 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.70s/it]
|
144 |
70%|โโโโโโโ | 7/10 [00:12<00:05, 1.68s/it]
|
145 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.66s/it]
|
146 |
90%|โโโโโโโโโ | 9/10 [00:15<00:01, 1.64s/it]
|
147 |
+
left shoulder - [151.0, 99.0]
|
148 |
+
right shoulder - [233.0, 107.0]
|
149 |
+
Shoulder width (in pixels): 82.39
|
150 |
+
Estimated height (in pixels): 248.68
|
151 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
152 |
+
Shoulder width (in cm): 85.83561685700498
|
153 |
+
Shoulder width (in INCH): 33.8
|
154 |
+
|
155 |
0%| | 0/1 [00:00<?, ?it/s]
|
156 |
+
|
157 |
0%| | 0/1 [00:00<?, ?it/s]
|
158 |
+
Initial seed: 1103655779
|
159 |
+
promt is None
|
160 |
+
|
161 |
0%| | 0/10 [00:00<?, ?it/s]
|
162 |
10%|โ | 1/10 [00:01<00:17, 2.00s/it]
|
163 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
164 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
165 |
40%|โโโโ | 4/10 [00:06<00:09, 1.67s/it]
|
166 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
167 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
168 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
169 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
170 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
171 |
+
left shoulder - [148.0, 104.0]
|
172 |
+
right shoulder - [232.0, 106.0]
|
173 |
+
Shoulder width (in pixels): 84.02
|
174 |
+
Estimated height (in pixels): 269.08
|
175 |
+
Conversion factor (pixels to cm): 0.9628363312026164
|
176 |
+
Shoulder width (in cm): 80.89750854764382
|
177 |
+
Shoulder width (in INCH): 31.8
|
178 |
+
|
179 |
0%| | 0/1 [00:00<?, ?it/s]
|
180 |
+
|
181 |
0%| | 0/1 [00:00<?, ?it/s]
|
182 |
+
Initial seed: 911324795
|
183 |
+
promt is None
|
184 |
+
|
185 |
0%| | 0/10 [00:00<?, ?it/s]
|
186 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
187 |
20%|โโ | 2/10 [00:03<00:14, 1.77s/it]
|
188 |
30%|โโโ | 3/10 [00:05<00:11, 1.70s/it]
|
189 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
190 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
191 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
192 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
193 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
194 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
195 |
+
left shoulder - [148.0, 104.0]
|
196 |
+
right shoulder - [232.0, 106.0]
|
197 |
+
Shoulder width (in pixels): 84.02
|
198 |
+
Estimated height (in pixels): 269.08
|
199 |
+
Conversion factor (pixels to cm): 0.9628363312026164
|
200 |
+
Shoulder width (in cm): 80.89750854764382
|
201 |
+
Shoulder width (in INCH): 31.8
|
202 |
+
|
203 |
0%| | 0/1 [00:00<?, ?it/s]
|
204 |
+
|
205 |
0%| | 0/1 [00:00<?, ?it/s]
|
206 |
+
Initial seed: 1627175075
|
207 |
+
promt is None
|
208 |
+
|
209 |
0%| | 0/10 [00:00<?, ?it/s]
|
210 |
10%|โ | 1/10 [00:02<00:18, 2.02s/it]
|
211 |
20%|โโ | 2/10 [00:03<00:14, 1.79s/it]
|
212 |
30%|โโโ | 3/10 [00:05<00:11, 1.71s/it]
|
213 |
40%|โโโโ | 4/10 [00:06<00:10, 1.68s/it]
|
214 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
215 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
216 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
217 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
218 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
219 |
+
left shoulder - [151.0, 99.0]
|
220 |
+
right shoulder - [233.0, 107.0]
|
221 |
+
Shoulder width (in pixels): 82.39
|
222 |
+
Estimated height (in pixels): 248.68
|
223 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
224 |
+
Shoulder width (in cm): 85.83561685700498
|
225 |
+
Shoulder width (in INCH): 33.8
|
226 |
+
|
227 |
0%| | 0/1 [00:00<?, ?it/s]
|
228 |
+
|
229 |
0%| | 0/1 [00:00<?, ?it/s]
|
230 |
+
Initial seed: 1589160508
|
231 |
+
promt is None
|
232 |
+
|
233 |
0%| | 0/10 [00:00<?, ?it/s]
|
234 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
235 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
236 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
237 |
40%|โโโโ | 4/10 [00:06<00:09, 1.65s/it]
|
238 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
239 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
240 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
241 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
242 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
243 |
+
left shoulder - [151.0, 99.0]
|
244 |
+
right shoulder - [233.0, 107.0]
|
245 |
+
Shoulder width (in pixels): 82.39
|
246 |
+
Estimated height (in pixels): 248.68
|
247 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
248 |
+
Shoulder width (in cm): 85.83561685700498
|
249 |
+
Shoulder width (in INCH): 33.8
|
250 |
+
|
251 |
0%| | 0/1 [00:00<?, ?it/s]
|
252 |
+
|
253 |
0%| | 0/1 [00:00<?, ?it/s]
|
254 |
+
Initial seed: 391988338
|
255 |
+
promt is None
|
256 |
+
|
257 |
0%| | 0/10 [00:00<?, ?it/s]
|
258 |
10%|โ | 1/10 [00:02<00:18, 2.01s/it]
|
259 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
260 |
30%|โโโ | 3/10 [00:05<00:11, 1.71s/it]
|
261 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
262 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
263 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.64s/it]
|
264 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
265 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
266 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
267 |
+
left shoulder - [151.0, 99.0]
|
268 |
+
right shoulder - [233.0, 107.0]
|
269 |
+
Shoulder width (in pixels): 82.39
|
270 |
+
Estimated height (in pixels): 248.68
|
271 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
272 |
+
Shoulder width (in cm): 85.83561685700498
|
273 |
+
Shoulder width (in INCH): 33.8
|
274 |
+
|
275 |
0%| | 0/1 [00:00<?, ?it/s]
|
276 |
+
|
277 |
0%| | 0/1 [00:00<?, ?it/s]
|
278 |
+
Initial seed: 722354609
|
279 |
+
promt is None
|
280 |
+
|
281 |
0%| | 0/10 [00:00<?, ?it/s]
|
282 |
10%|โ | 1/10 [00:01<00:17, 1.99s/it]
|
283 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
284 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
285 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
286 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.64s/it]
|
287 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
288 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.62s/it]
|
289 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.62s/it]
|
290 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
291 |
+
left shoulder - [151.0, 99.0]
|
292 |
+
right shoulder - [233.0, 107.0]
|
293 |
+
Shoulder width (in pixels): 82.39
|
294 |
+
Estimated height (in pixels): 248.68
|
295 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
296 |
+
Shoulder width (in cm): 85.83561685700498
|
297 |
+
Shoulder width (in INCH): 33.8
|
298 |
+
|
299 |
0%| | 0/1 [00:00<?, ?it/s]
|
300 |
+
|
301 |
0%| | 0/1 [00:00<?, ?it/s]
|
302 |
+
Initial seed: 459777321
|
303 |
+
promt is None
|
304 |
+
|
305 |
0%| | 0/10 [00:00<?, ?it/s]
|
306 |
10%|โ | 1/10 [00:01<00:17, 2.00s/it]
|
307 |
20%|โโ | 2/10 [00:03<00:14, 1.76s/it]
|
308 |
30%|โโโ | 3/10 [00:05<00:11, 1.69s/it]
|
309 |
40%|โโโโ | 4/10 [00:06<00:09, 1.66s/it]
|
310 |
50%|โโโโโ | 5/10 [00:08<00:08, 1.65s/it]
|
311 |
60%|โโโโโโ | 6/10 [00:10<00:06, 1.63s/it]
|
312 |
70%|โโโโโโโ | 7/10 [00:11<00:04, 1.63s/it]
|
313 |
80%|โโโโโโโโ | 8/10 [00:13<00:03, 1.63s/it]
|
314 |
90%|โโโโโโโโโ | 9/10 [00:14<00:01, 1.62s/it]
|
315 |
+
|
316 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
317 |
+
warnings.warn(
|
318 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
319 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
320 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
321 |
+
|
322 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
323 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
324 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
325 |
+
|
326 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
327 |
+
warnings.warn(
|
328 |
+
|
329 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
330 |
+
warnings.warn(
|
331 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
332 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
333 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
334 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
335 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
336 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
337 |
+
|
338 |
+
|
339 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
340 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
341 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
342 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
343 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
344 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
345 |
+
Traceback (most recent call last):
|
346 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 46, in <module>
|
347 |
+
ootd_model_dc.text_encoder.to('cuda')
|
348 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2460, in to
|
349 |
+
return super().to(*args, **kwargs)
|
350 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1145, in to
|
351 |
+
return self._apply(convert)
|
352 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
353 |
+
module._apply(fn)
|
354 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
355 |
+
module._apply(fn)
|
356 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
357 |
+
module._apply(fn)
|
358 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 820, in _apply
|
359 |
+
param_applied = fn(param)
|
360 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1143, in convert
|
361 |
+
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
|
362 |
+
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 146.00 MiB (GPU 0; 14.58 GiB total capacity; 4.96 GiB already allocated; 105.62 MiB free; 5.00 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
|
363 |
+
Traceback (most recent call last):
|
364 |
+
File "/home/ubuntu/GT_VTR3_1/run/gradio_ootd.py", line 46, in <module>
|
365 |
+
ootd_model_dc.text_encoder.to('cuda')
|
366 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2460, in to
|
367 |
+
return super().to(*args, **kwargs)
|
368 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1145, in to
|
369 |
+
return self._apply(convert)
|
370 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
371 |
+
module._apply(fn)
|
372 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
373 |
+
module._apply(fn)
|
374 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 797, in _apply
|
375 |
+
module._apply(fn)
|
376 |
+
[Previous line repeated 3 more times]
|
377 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 820, in _apply
|
378 |
+
param_applied = fn(param)
|
379 |
+
File "/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1143, in convert
|
380 |
+
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
|
381 |
+
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 14.58 GiB total capacity; 5.21 GiB already allocated; 5.62 MiB free; 5.28 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
|
382 |
+
|
383 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
384 |
+
warnings.warn(
|
385 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
386 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
387 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
388 |
+
|
389 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
390 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
391 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
392 |
+
|
393 |
+
/home/ubuntu/miniconda3/envs/vtr/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
|
394 |
+
warnings.warn(
|
395 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
396 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
397 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
398 |
+
|
399 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
|
400 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
|
401 |
+
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
|
402 |
+
IMPORTANT: You are using gradio version 4.16.0, however version 4.29.0 is available, please upgrade.
|
403 |
+
--------
|
404 |
+
Running on local URL: http://0.0.0.0:7860
|
405 |
+
|
406 |
+
To create a public link, set `share=True` in `launch()`.
|
407 |
+
left shoulder - [151.0, 99.0]
|
408 |
+
right shoulder - [233.0, 107.0]
|
409 |
+
Shoulder width (in pixels): 82.39
|
410 |
+
Estimated height (in pixels): 248.68
|
411 |
+
Conversion factor (pixels to cm): 1.0418208138973781
|
412 |
+
Shoulder width (in cm): 85.83561685700498
|
413 |
+
Shoulder width (in INCH): 33.8
|
414 |
+
|
415 |
0%| | 0/1 [00:00<?, ?it/s]
|
416 |
+
|
417 |
0%| | 0/1 [00:00<?, ?it/s]
|
418 |
+
Initial seed: 1770992986
|
419 |
+
promt is None
|
420 |
+
|
421 |
0%| | 0/10 [00:00<?, ?it/s]
|
422 |
10%|โ | 1/10 [00:02<00:18, 2.03s/it]
|
423 |
20%|โโ | 2/10 [00:03<00:14, 1.78s/it]
|
424 |
30%|โโโ | 3/10 [00:06<00:16, 2.39s/it]
|
425 |
40%|โโโโ | 4/10 [00:08<00:12, 2.08s/it]
|
426 |
50%|โโโโโ | 5/10 [00:09<00:09, 1.91s/it]
|
427 |
60%|โโโโโโ | 6/10 [00:11<00:07, 1.81s/it]
|
428 |
70%|โโโโโโโ | 7/10 [00:13<00:05, 1.74s/it]
|
429 |
80%|โโโโโโโโ | 8/10 [00:14<00:03, 1.70s/it]
|
430 |
90%|โโโโโโโโโ | 9/10 [00:16<00:01, 1.67s/it]
|
ootd/inference_ootd.py
CHANGED
@@ -112,9 +112,12 @@ class OOTDiffusion:
|
|
112 |
prompt_image = prompt_image.unsqueeze(1)
|
113 |
if model_type == 'hd':
|
114 |
prompt_embeds = self.text_encoder(self.tokenize_captions([""], 2).to('cuda'))[0]
|
|
|
|
|
115 |
prompt_embeds[:, 1:] = prompt_image[:]
|
116 |
elif model_type == 'dc':
|
117 |
prompt_embeds = self.text_encoder(self.tokenize_captions([category], 3).to('cuda'))[0]
|
|
|
118 |
prompt_embeds = torch.cat([prompt_embeds, prompt_image], dim=1)
|
119 |
else:
|
120 |
raise ValueError("model_type must be \'hd\' or \'dc\'!")
|
|
|
112 |
prompt_image = prompt_image.unsqueeze(1)
|
113 |
if model_type == 'hd':
|
114 |
prompt_embeds = self.text_encoder(self.tokenize_captions([""], 2).to('cuda'))[0]
|
115 |
+
print(prompt_embeds.shape)
|
116 |
+
# print(prompt_embeds.shape)
|
117 |
prompt_embeds[:, 1:] = prompt_image[:]
|
118 |
elif model_type == 'dc':
|
119 |
prompt_embeds = self.text_encoder(self.tokenize_captions([category], 3).to('cuda'))[0]
|
120 |
+
print(prompt_embeds.shape)
|
121 |
prompt_embeds = torch.cat([prompt_embeds, prompt_image], dim=1)
|
122 |
else:
|
123 |
raise ValueError("model_type must be \'hd\' or \'dc\'!")
|
ootd/inference_ootd_dc.py
CHANGED
@@ -38,6 +38,7 @@ class OOTDiffusionDC:
|
|
38 |
VAE_PATH,
|
39 |
subfolder="vae",
|
40 |
torch_dtype=torch.float16,
|
|
|
41 |
)
|
42 |
|
43 |
unet_garm = UNetGarm2DConditionModel.from_pretrained(
|
|
|
38 |
VAE_PATH,
|
39 |
subfolder="vae",
|
40 |
torch_dtype=torch.float16,
|
41 |
+
|
42 |
)
|
43 |
|
44 |
unet_garm = UNetGarm2DConditionModel.from_pretrained(
|
ootd/pipelines_ootd/__pycache__/attention_garm.cpython-310.pyc
ADDED
Binary file (11.4 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/attention_vton.cpython-310.pyc
ADDED
Binary file (11.5 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/pipeline_ootd.cpython-310.pyc
ADDED
Binary file (27 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/transformer_garm_2d.cpython-310.pyc
ADDED
Binary file (13.6 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/transformer_vton_2d.cpython-310.pyc
ADDED
Binary file (13.7 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/unet_garm_2d_blocks.cpython-310.pyc
ADDED
Binary file (63.5 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/unet_garm_2d_condition.cpython-310.pyc
ADDED
Binary file (37 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/unet_vton_2d_blocks.cpython-310.pyc
ADDED
Binary file (63.6 kB). View file
|
|
ootd/pipelines_ootd/__pycache__/unet_vton_2d_condition.cpython-310.pyc
ADDED
Binary file (37.2 kB). View file
|
|
ootd/pipelines_ootd/pipeline_ootd.py
CHANGED
@@ -275,6 +275,10 @@ class OotdPipeline(DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMix
|
|
275 |
device = self._execution_device
|
276 |
# check if scheduler is in sigmas space
|
277 |
scheduler_is_in_sigma_space = hasattr(self.scheduler, "sigmas")
|
|
|
|
|
|
|
|
|
278 |
|
279 |
# 2. Encode input prompt
|
280 |
prompt_embeds = self._encode_prompt(
|
|
|
275 |
device = self._execution_device
|
276 |
# check if scheduler is in sigmas space
|
277 |
scheduler_is_in_sigma_space = hasattr(self.scheduler, "sigmas")
|
278 |
+
|
279 |
+
|
280 |
+
print(f'promt is {prompt}') #debug
|
281 |
+
|
282 |
|
283 |
# 2. Encode input prompt
|
284 |
prompt_embeds = self._encode_prompt(
|
preprocess/humanparsing/datasets/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (160 Bytes). View file
|
|
preprocess/humanparsing/datasets/__pycache__/simple_extractor_dataset.cpython-310.pyc
ADDED
Binary file (2.81 kB). View file
|
|
preprocess/humanparsing/run_parsing.py
CHANGED
@@ -13,15 +13,26 @@ class Parsing:
|
|
13 |
def __init__(self, gpu_id: int):
|
14 |
# self.gpu_id = gpu_id
|
15 |
# torch.cuda.set_device(gpu_id)
|
|
|
|
|
|
|
16 |
session_options = ort.SessionOptions()
|
17 |
session_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
|
18 |
session_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
|
19 |
# session_options.add_session_config_entry('gpu_id', str(gpu_id))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
self.session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_atr.onnx'),
|
21 |
-
sess_options=session_options, providers=
|
22 |
self.lip_session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_lip.onnx'),
|
23 |
-
sess_options=session_options, providers=
|
24 |
-
|
25 |
|
26 |
def __call__(self, input_image):
|
27 |
# torch.cuda.set_device(self.gpu_id)
|
|
|
13 |
def __init__(self, gpu_id: int):
|
14 |
# self.gpu_id = gpu_id
|
15 |
# torch.cuda.set_device(gpu_id)
|
16 |
+
providers = [("CUDAExecutionProvider", {"device_id": torch.cuda.current_device(),
|
17 |
+
"user_compute_stream": str(torch.cuda.current_stream().cuda_stream)})]
|
18 |
+
|
19 |
session_options = ort.SessionOptions()
|
20 |
session_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
|
21 |
session_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
|
22 |
# session_options.add_session_config_entry('gpu_id', str(gpu_id))
|
23 |
+
# self.session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_atr.onnx'),
|
24 |
+
# sess_options=session_options, providers=['CPUExecutionProvider'])
|
25 |
+
# self.lip_session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_lip.onnx'),
|
26 |
+
# sess_options=session_options, providers=['CPUExecutionProvider'])
|
27 |
+
|
28 |
+
|
29 |
+
#new changes -
|
30 |
+
session_options.add_session_config_entry('gpu_id', str(gpu_id))
|
31 |
self.session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_atr.onnx'),
|
32 |
+
sess_options=session_options, providers=providers)
|
33 |
self.lip_session = ort.InferenceSession(os.path.join(Path(__file__).absolute().parents[2].absolute(), 'checkpoints/humanparsing/parsing_lip.onnx'),
|
34 |
+
sess_options=session_options, providers=providers)
|
35 |
+
|
36 |
|
37 |
def __call__(self, input_image):
|
38 |
# torch.cuda.set_device(self.gpu_id)
|
preprocess/humanparsing/utils/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (157 Bytes). View file
|
|
preprocess/humanparsing/utils/__pycache__/transforms.cpython-310.pyc
ADDED
Binary file (4.86 kB). View file
|
|
preprocess/openpose/annotator/__pycache__/util.cpython-310.pyc
ADDED
Binary file (3.19 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.16 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/body.cpython-310.pyc
ADDED
Binary file (7.07 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/face.cpython-310.pyc
ADDED
Binary file (8.16 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/hand.cpython-310.pyc
ADDED
Binary file (3.19 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/model.cpython-310.pyc
ADDED
Binary file (6.2 kB). View file
|
|
preprocess/openpose/annotator/openpose/__pycache__/util.cpython-310.pyc
ADDED
Binary file (7.75 kB). View file
|
|
preprocess/openpose/model_8.png
ADDED
![]() |
preprocess/openpose/run_openpose.py
CHANGED
@@ -16,8 +16,11 @@ import time
|
|
16 |
import json
|
17 |
|
18 |
# from pytorch_lightning import seed_everything
|
19 |
-
from preprocess.openpose.annotator.util import resize_image, HWC3
|
20 |
-
from preprocess.openpose.annotator.openpose import OpenposeDetector
|
|
|
|
|
|
|
21 |
|
22 |
import argparse
|
23 |
from PIL import Image
|
@@ -27,7 +30,7 @@ import pdb
|
|
27 |
# os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
|
28 |
|
29 |
class OpenPose:
|
30 |
-
def __init__(self, gpu_id: int):
|
31 |
# self.gpu_id = gpu_id
|
32 |
# torch.cuda.set_device(gpu_id)
|
33 |
self.preprocessor = OpenposeDetector()
|
@@ -47,6 +50,8 @@ class OpenPose:
|
|
47 |
assert (H == 512 and W == 384), 'Incorrect input image shape'
|
48 |
pose, detected_map = self.preprocessor(input_image, hand_and_face=False)
|
49 |
|
|
|
|
|
50 |
candidate = pose['bodies']['candidate']
|
51 |
subset = pose['bodies']['subset'][0][:18]
|
52 |
for i in range(18):
|
@@ -75,10 +80,15 @@ class OpenPose:
|
|
75 |
# output_image = cv2.resize(cv2.cvtColor(detected_map, cv2.COLOR_BGR2RGB), (768, 1024))
|
76 |
# cv2.imwrite('/home/aigc/ProjectVTON/OpenPose/keypoints/out_pose.jpg', output_image)
|
77 |
|
78 |
-
return keypoints
|
|
|
79 |
|
80 |
|
81 |
if __name__ == '__main__':
|
82 |
|
|
|
83 |
model = OpenPose()
|
84 |
-
|
|
|
|
|
|
|
|
16 |
import json
|
17 |
|
18 |
# from pytorch_lightning import seed_everything
|
19 |
+
# from preprocess.openpose.annotator.util import resize_image, HWC3
|
20 |
+
# from preprocess.openpose.annotator.openpose import OpenposeDetector
|
21 |
+
|
22 |
+
from annotator.util import resize_image, HWC3
|
23 |
+
from annotator.openpose import OpenposeDetector
|
24 |
|
25 |
import argparse
|
26 |
from PIL import Image
|
|
|
30 |
# os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
|
31 |
|
32 |
class OpenPose:
|
33 |
+
def __init__(self, gpu_id: int=0):
|
34 |
# self.gpu_id = gpu_id
|
35 |
# torch.cuda.set_device(gpu_id)
|
36 |
self.preprocessor = OpenposeDetector()
|
|
|
50 |
assert (H == 512 and W == 384), 'Incorrect input image shape'
|
51 |
pose, detected_map = self.preprocessor(input_image, hand_and_face=False)
|
52 |
|
53 |
+
# print(pose)
|
54 |
+
|
55 |
candidate = pose['bodies']['candidate']
|
56 |
subset = pose['bodies']['subset'][0][:18]
|
57 |
for i in range(18):
|
|
|
80 |
# output_image = cv2.resize(cv2.cvtColor(detected_map, cv2.COLOR_BGR2RGB), (768, 1024))
|
81 |
# cv2.imwrite('/home/aigc/ProjectVTON/OpenPose/keypoints/out_pose.jpg', output_image)
|
82 |
|
83 |
+
# return keypoints
|
84 |
+
return keypoints, candidate, subset
|
85 |
|
86 |
|
87 |
if __name__ == '__main__':
|
88 |
|
89 |
+
import os
|
90 |
model = OpenPose()
|
91 |
+
|
92 |
+
print(os.getcwd())
|
93 |
+
|
94 |
+
pose = model('./model_8.png')
|
ps.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
43684
|
requirements.txt
CHANGED
@@ -15,4 +15,5 @@ gradio==4.16.0
|
|
15 |
config==0.5.1
|
16 |
einops==0.7.0
|
17 |
onnxruntime==1.16.2
|
18 |
-
basicsr
|
|
|
|
15 |
config==0.5.1
|
16 |
einops==0.7.0
|
17 |
onnxruntime==1.16.2
|
18 |
+
basicsr
|
19 |
+
onnxruntime-gpu==1.18.0
|
run/cloths_db.py
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
cloths_map= {
|
4 |
+
'050105_1.jpeg': "Upper-body",
|
5 |
+
'02783_00.jpeg': "Upper-body",
|
6 |
+
'male_tshirt1.jpeg': "Upper-body",
|
7 |
+
'051515_1.jpeg': "Lower-body",
|
8 |
+
'07764_00.jpeg': "Upper-body",
|
9 |
+
'053786_1.jpeg': "Dress",
|
10 |
+
'09933_00.jpeg': "Upper-body",
|
11 |
+
'052234_1.jpeg': "Dress",
|
12 |
+
'049947_1.jpeg': "Upper-body",
|
13 |
+
'06123_00.jpeg': "Upper-body",
|
14 |
+
'051827_1.jpeg': "Lower-body",
|
15 |
+
'049805_1.jpeg': "Upper-body",
|
16 |
+
'049920_1.jpeg': "Upper-body",
|
17 |
+
'08348_00.jpeg': "Upper-body",
|
18 |
+
'050191_1.jpeg':"Upper-body",
|
19 |
+
'03244_00.jpeg': "Upper-body",
|
20 |
+
'11791_00.jpeg': "Upper-body",
|
21 |
+
'051946_1.jpeg': "Lower-body",
|
22 |
+
'00470_00.jpeg': "Upper-body",
|
23 |
+
'050181_1.jpeg': "Upper-body",
|
24 |
+
'03751_00.jpeg': "Upper-body",
|
25 |
+
'11028_00.jpeg': "Upper-body",
|
26 |
+
'07382_00.jpeg': "Upper-body",
|
27 |
+
'051998_1.jpeg': "Dress",
|
28 |
+
'051988_1.jpeg': "Lower-body",
|
29 |
+
'11351_00.jpeg': "Upper-body",
|
30 |
+
'07429_00.jpeg': "Upper-body",
|
31 |
+
'02305_00.jpeg': "Upper-body",
|
32 |
+
'03032_00.jpeg': "Upper-body",
|
33 |
+
'049949_1.jpeg': "Upper-body",
|
34 |
+
'049940_1.jpeg': "Upper-body",
|
35 |
+
'049965_1.jpeg': "Upper-body",
|
36 |
+
'053790_1.jpeg': "Dress",
|
37 |
+
'050002_1.jpeg': "Upper-body",
|
38 |
+
'10297_00.jpeg': "Upper-body",
|
39 |
+
'048769_1.jpeg': "Upper-body",
|
40 |
+
'00055_00.jpeg': "Upper-body",
|
41 |
+
'048554_1.jpeg': "Upper-body",
|
42 |
+
'051517_1.jpeg': "Lower-body",
|
43 |
+
'02015_00.jpeg': "Upper-body",
|
44 |
+
'053290_1.jpeg': "Dress",
|
45 |
+
'053742_1.jpeg': "Dress",
|
46 |
+
'04825_00.jpeg': "Upper-body",
|
47 |
+
'053319_1.jpeg': "Dress",
|
48 |
+
'053744_1.jpeg': "Dress",
|
49 |
+
'00151_00.jpeg': "Upper-body",
|
50 |
+
'06429_00.jpeg': "Upper-body",
|
51 |
+
'01260_00.jpeg': "Upper-body",
|
52 |
+
'12562_00.jpeg': "Upper-body",
|
53 |
+
'01430_00.jpeg': "Upper-body",
|
54 |
+
'051412_1.jpeg': "Lower-body",
|
55 |
+
'00126_00.jpeg': "Upper-body",
|
56 |
+
'051991_1.jpeg': "Lower-body",
|
57 |
+
'06802_00.jpeg': "Upper-body",
|
58 |
+
'051473_1.jpeg': "Lower-body"
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
modeL_db= {
|
63 |
+
'051962_0.jpg': "no-dress",
|
64 |
+
'052472_0.jpg': "dress",
|
65 |
+
'02783_00.jpg': 0,
|
66 |
+
'09933_00.jpg': 0,
|
67 |
+
'053228_0.jpg': "dress",
|
68 |
+
'051482_0.jpg': "no-dress",
|
69 |
+
'model_1.png': 0,
|
70 |
+
'051918_0.jpg': "no-dress",
|
71 |
+
'05997_00.jpg': 0,
|
72 |
+
'model_2.png': 0,
|
73 |
+
'08348_00.jpg': 0,
|
74 |
+
'07966_00.jpg': 0,
|
75 |
+
'11791_00.jpg': 0,
|
76 |
+
'model_9.png': "dress",
|
77 |
+
'03751_00.jpg': 0,
|
78 |
+
'11028_00.jpg': 0,
|
79 |
+
'14627_00.jpg': 0,
|
80 |
+
'11351_00.jpg': 0,
|
81 |
+
'053700_0.jpg': "dress",
|
82 |
+
'09597_00.jpg': 0,
|
83 |
+
'07429_00.jpg': 0,
|
84 |
+
'052964_0.jpg': "dress",
|
85 |
+
'model_3.png': 0,
|
86 |
+
'052767_0.jpg': "dress",
|
87 |
+
'049447_0.jpg': "no-dress",
|
88 |
+
'model_6.png': 0,
|
89 |
+
'model_7.png': 0,
|
90 |
+
'02849_00.jpg': 0,
|
91 |
+
'model_5.png': 0,
|
92 |
+
'model_4.png': 0,
|
93 |
+
'06429_00.jpg': 0,
|
94 |
+
'01260_00.jpg': 0,
|
95 |
+
'01008_00.jpg': "no-dress",
|
96 |
+
'049713_0.jpg': "no-dress",
|
97 |
+
'model_8.png': "no-dress",
|
98 |
+
'053514_0.jpg': "dress",
|
99 |
+
'01861_00.jpg': 0,
|
100 |
+
'01430_00.jpg': 0,
|
101 |
+
'06802_00.jpg': 0,
|
102 |
+
'049205_0.jpg': "no-dress"
|
103 |
+
}
|
104 |
+
|
105 |
+
# import os
|
106 |
+
|
107 |
+
# def list_files_in_folder(folder_path):
|
108 |
+
# """
|
109 |
+
# List all files in the given folder and create a dictionary with filenames as keys and 0 as values.
|
110 |
+
|
111 |
+
# Args:
|
112 |
+
# folder_path (str): Path to the folder.
|
113 |
+
|
114 |
+
# Returns:
|
115 |
+
# dict: Dictionary with filenames as keys and 0 as values.
|
116 |
+
# """
|
117 |
+
# files_dict = {}
|
118 |
+
|
119 |
+
# try:
|
120 |
+
# # List all files in the folder
|
121 |
+
# for file_name in os.listdir(folder_path):
|
122 |
+
# # Check if it's a file ("no-dress"t a directory)
|
123 |
+
# if os.path.isfile(os.path.join(folder_path, file_name)):
|
124 |
+
# files_dict[file_name] = 0
|
125 |
+
# except Exception as e:
|
126 |
+
# print(f"An error occurred: {e}")
|
127 |
+
|
128 |
+
# return files_dict
|
129 |
+
|
130 |
+
# # Example usage
|
131 |
+
# folder_path = 'run/examples/model'
|
132 |
+
# files_dict = list_files_in_folder(folder_path)
|
133 |
+
# print(files_dict)
|
run/gradio_ootd copy_backup.py
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from pathlib import Path
|
4 |
+
import sys
|
5 |
+
import torch
|
6 |
+
from PIL import Image, ImageOps
|
7 |
+
import numpy as np
|
8 |
+
from utils_ootd import get_mask_location
|
9 |
+
|
10 |
+
PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute()
|
11 |
+
sys.path.insert(0, str(PROJECT_ROOT))
|
12 |
+
|
13 |
+
from preprocess.openpose.run_openpose import OpenPose
|
14 |
+
from preprocess.humanparsing.run_parsing import Parsing
|
15 |
+
from ootd.inference_ootd_hd import OOTDiffusionHD
|
16 |
+
from ootd.inference_ootd_dc import OOTDiffusionDC
|
17 |
+
from preprocess.openpose.annotator.openpose.util import draw_bodypose
|
18 |
+
|
19 |
+
# Set default dtype to float64
|
20 |
+
# torch.set_default_dtype(torch.float16)
|
21 |
+
|
22 |
+
|
23 |
+
openpose_model_hd = OpenPose(0)
|
24 |
+
parsing_model_hd = Parsing(0)
|
25 |
+
ootd_model_hd = OOTDiffusionHD(0)
|
26 |
+
|
27 |
+
openpose_model_dc = OpenPose(0)
|
28 |
+
parsing_model_dc = Parsing(0)
|
29 |
+
ootd_model_dc = OOTDiffusionDC(0)
|
30 |
+
|
31 |
+
|
32 |
+
category_dict = ['upperbody', 'lowerbody', 'dress']
|
33 |
+
category_dict_utils = ['upper_body', 'lower_body', 'dresses']
|
34 |
+
|
35 |
+
|
36 |
+
example_path = os.path.join(os.path.dirname(__file__), 'examples')
|
37 |
+
model_hd = os.path.join(example_path, 'model/model_1.png')
|
38 |
+
garment_hd = os.path.join(example_path, 'garment/03244_00.jpg')
|
39 |
+
model_dc = os.path.join(example_path, 'model/model_8.png')
|
40 |
+
garment_dc = os.path.join(example_path, 'garment/048554_1.jpg')
|
41 |
+
|
42 |
+
openpose_model_dc.preprocessor.body_estimation.model.to('cuda')
|
43 |
+
ootd_model_dc.pipe.to('cuda')
|
44 |
+
ootd_model_dc.image_encoder.to('cuda')
|
45 |
+
ootd_model_dc.text_encoder.to('cuda')
|
46 |
+
|
47 |
+
def convert_to_image(image_array):
|
48 |
+
if isinstance(image_array, np.ndarray):
|
49 |
+
# Normalize the data to the range [0, 255]
|
50 |
+
image_array = 255 * (image_array - np.min(image_array)) / (np.max(image_array) - np.min(image_array))
|
51 |
+
# Convert to uint8
|
52 |
+
image_array = image_array.astype(np.uint8)
|
53 |
+
return Image.fromarray(image_array)
|
54 |
+
else:
|
55 |
+
# Convert to NumPy array first if necessary
|
56 |
+
image_array = np.array(image_array)
|
57 |
+
# Normalize and convert to uint8
|
58 |
+
image_array = 255 * (image_array - np.min(image_array)) / (np.max(image_array) - np.min(image_array))
|
59 |
+
image_array = image_array.astype(np.uint8)
|
60 |
+
return Image.fromarray(image_array)
|
61 |
+
|
62 |
+
# import spaces
|
63 |
+
|
64 |
+
# @spaces.GPU
|
65 |
+
def process_hd(vton_img, garm_img, n_samples, n_steps, image_scale, seed):
|
66 |
+
model_type = 'hd'
|
67 |
+
category = 0 # 0:upperbody; 1:lowerbody; 2:dress
|
68 |
+
|
69 |
+
with torch.no_grad():
|
70 |
+
openpose_model_hd.preprocessor.body_estimation.model.to('cuda')
|
71 |
+
ootd_model_hd.pipe.to('cuda')
|
72 |
+
ootd_model_hd.image_encoder.to('cuda')
|
73 |
+
ootd_model_hd.text_encoder.to('cuda')
|
74 |
+
|
75 |
+
garm_img = Image.open(garm_img).resize((768, 1024))
|
76 |
+
vton_img = Image.open(vton_img).resize((768, 1024))
|
77 |
+
keypoints = openpose_model_hd(vton_img.resize((384, 512)))
|
78 |
+
model_parse, _ = parsing_model_hd(vton_img.resize((384, 512)))
|
79 |
+
|
80 |
+
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
81 |
+
mask = mask.resize((768, 1024), Image.NEAREST)
|
82 |
+
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
83 |
+
|
84 |
+
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
85 |
+
|
86 |
+
images = ootd_model_hd(
|
87 |
+
model_type=model_type,
|
88 |
+
category=category_dict[category],
|
89 |
+
image_garm=garm_img,
|
90 |
+
image_vton=masked_vton_img,
|
91 |
+
mask=mask,
|
92 |
+
image_ori=vton_img,
|
93 |
+
num_samples=n_samples,
|
94 |
+
num_steps=n_steps,
|
95 |
+
image_scale=image_scale,
|
96 |
+
seed=seed,
|
97 |
+
)
|
98 |
+
|
99 |
+
return images
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
# @spaces.GPU
|
104 |
+
def process_dc(vton_img, garm_img, category):
|
105 |
+
model_type = 'dc'
|
106 |
+
if category == 'Upper-body':
|
107 |
+
category = 0
|
108 |
+
elif category == 'Lower-body':
|
109 |
+
category = 1
|
110 |
+
else:
|
111 |
+
category =2
|
112 |
+
|
113 |
+
with torch.no_grad():
|
114 |
+
# openpose_model_dc.preprocessor.body_estimation.model.to('cuda')
|
115 |
+
# ootd_model_dc.pipe.to('cuda')
|
116 |
+
# ootd_model_dc.image_encoder.to('cuda')
|
117 |
+
# ootd_model_dc.text_encoder.to('cuda')
|
118 |
+
|
119 |
+
garm_img = Image.open(garm_img).resize((768, 1024))
|
120 |
+
vton_img = Image.open(vton_img).resize((768, 1024))
|
121 |
+
keypoints ,candidate , subset = openpose_model_dc(vton_img.resize((384, 512)))
|
122 |
+
|
123 |
+
# print(len(keypoints["pose_keypoints_2d"]))
|
124 |
+
# print(keypoints["pose_keypoints_2d"])
|
125 |
+
|
126 |
+
# person_image = np.asarray(vton_img)
|
127 |
+
|
128 |
+
|
129 |
+
# print(len(person_image))
|
130 |
+
|
131 |
+
|
132 |
+
# person_image = np.asarray(Image.open(vton_img).resize((768, 1024)))
|
133 |
+
|
134 |
+
# output = draw_bodypose(canvas=person_image,candidate=candidate, subset=subset )
|
135 |
+
# output_image = Image.fromarray(output)
|
136 |
+
# output_image.save('keypose.png')
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
left_point = keypoints["pose_keypoints_2d"][2]
|
141 |
+
right_point = keypoints["pose_keypoints_2d"][5]
|
142 |
+
|
143 |
+
neck_point = keypoints["pose_keypoints_2d"][1]
|
144 |
+
hip_point = keypoints["pose_keypoints_2d"][8]
|
145 |
+
|
146 |
+
|
147 |
+
|
148 |
+
print(f'left shoulder - {left_point}')
|
149 |
+
print(f'right shoulder - {right_point}')
|
150 |
+
|
151 |
+
# #find disctance using Euclidian distance
|
152 |
+
shoulder_width_pixels = round(np.sqrt( np.power((right_point[0]-left_point[0]),2) + np.power((right_point[1]-left_point[1]),2)),2)
|
153 |
+
|
154 |
+
height_pixels = round(np.sqrt( np.power((neck_point[0]-hip_point[0]),2) + np.power((neck_point[1]-hip_point[1]),2)),2) *2
|
155 |
+
|
156 |
+
|
157 |
+
# # Assuming an average human height
|
158 |
+
average_height_cm = 172.72 *1.5
|
159 |
+
|
160 |
+
# Conversion factor from pixels to cm
|
161 |
+
conversion_factor = average_height_cm / height_pixels
|
162 |
+
|
163 |
+
# Convert shoulder width to real-world units
|
164 |
+
shoulder_width_cm = shoulder_width_pixels * conversion_factor
|
165 |
+
|
166 |
+
print(f'Shoulder width (in pixels): {shoulder_width_pixels}')
|
167 |
+
print(f'Estimated height (in pixels): {height_pixels}')
|
168 |
+
print(f'Conversion factor (pixels to cm): {conversion_factor}')
|
169 |
+
print(f'Shoulder width (in cm): {shoulder_width_cm}')
|
170 |
+
print(f'Shoulder width (in INCH): {round(shoulder_width_cm/2.54,1)}')
|
171 |
+
|
172 |
+
model_parse, face_mask = parsing_model_dc(vton_img.resize((384, 512)))
|
173 |
+
|
174 |
+
model_parse_image = convert_to_image(model_parse)
|
175 |
+
face_mask_image = convert_to_image(face_mask)
|
176 |
+
|
177 |
+
# Save the images
|
178 |
+
model_parse_image.save('model_parse_image.png')
|
179 |
+
face_mask_image.save('face_mask_image.png')
|
180 |
+
|
181 |
+
|
182 |
+
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
183 |
+
mask = mask.resize((768, 1024), Image.NEAREST)
|
184 |
+
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
185 |
+
|
186 |
+
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
187 |
+
|
188 |
+
images = ootd_model_dc(
|
189 |
+
model_type=model_type,
|
190 |
+
category=category_dict[category],
|
191 |
+
image_garm=garm_img,
|
192 |
+
image_vton=masked_vton_img,
|
193 |
+
mask=mask,
|
194 |
+
image_ori=vton_img,
|
195 |
+
num_samples=1,
|
196 |
+
num_steps=10,
|
197 |
+
image_scale= 2.0,
|
198 |
+
seed=-1,
|
199 |
+
)
|
200 |
+
|
201 |
+
return images
|
202 |
+
|
203 |
+
|
204 |
+
block = gr.Blocks().queue()
|
205 |
+
with block:
|
206 |
+
with gr.Row():
|
207 |
+
gr.Markdown("# ")
|
208 |
+
# with gr.Row():
|
209 |
+
# gr.Markdown("## Half-body-1")
|
210 |
+
# with gr.Row():
|
211 |
+
# gr.Markdown("***Support upper-body garments***")
|
212 |
+
# with gr.Row():
|
213 |
+
# with gr.Column():
|
214 |
+
# vton_img = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_hd)
|
215 |
+
# example = gr.Examples(
|
216 |
+
# inputs=vton_img,
|
217 |
+
# examples_per_page=14,
|
218 |
+
# examples=[
|
219 |
+
# os.path.join(example_path, 'model/model_1.png'),
|
220 |
+
# os.path.join(example_path, 'model/model_2.png'),
|
221 |
+
# os.path.join(example_path, 'model/model_3.png'),
|
222 |
+
# os.path.join(example_path, 'model/model_4.png'),
|
223 |
+
# os.path.join(example_path, 'model/model_5.png'),
|
224 |
+
# os.path.join(example_path, 'model/model_6.png'),
|
225 |
+
# os.path.join(example_path, 'model/model_7.png'),
|
226 |
+
# os.path.join(example_path, 'model/01008_00.jpg'),
|
227 |
+
# os.path.join(example_path, 'model/07966_00.jpg'),
|
228 |
+
# os.path.join(example_path, 'model/05997_00.jpg'),
|
229 |
+
# os.path.join(example_path, 'model/02849_00.jpg'),
|
230 |
+
# os.path.join(example_path, 'model/14627_00.jpg'),
|
231 |
+
# os.path.join(example_path, 'model/09597_00.jpg'),
|
232 |
+
# os.path.join(example_path, 'model/01861_00.jpg'),
|
233 |
+
# ])
|
234 |
+
# with gr.Column():
|
235 |
+
# garm_img = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_hd)
|
236 |
+
# example = gr.Examples(
|
237 |
+
# inputs=garm_img,
|
238 |
+
# examples_per_page=14,
|
239 |
+
# examples=[
|
240 |
+
# os.path.join(example_path, 'garment/03244_00.jpg'),
|
241 |
+
# os.path.join(example_path, 'garment/00126_00.jpg'),
|
242 |
+
# os.path.join(example_path, 'garment/03032_00.jpg'),
|
243 |
+
# os.path.join(example_path, 'garment/06123_00.jpg'),
|
244 |
+
# os.path.join(example_path, 'garment/02305_00.jpg'),
|
245 |
+
# os.path.join(example_path, 'garment/00055_00.jpg'),
|
246 |
+
# os.path.join(example_path, 'garment/00470_00.jpg'),
|
247 |
+
# os.path.join(example_path, 'garment/02015_00.jpg'),
|
248 |
+
# os.path.join(example_path, 'garment/10297_00.jpg'),
|
249 |
+
# os.path.join(example_path, 'garment/07382_00.jpg'),
|
250 |
+
# os.path.join(example_path, 'garment/07764_00.jpg'),
|
251 |
+
# os.path.join(example_path, 'garment/00151_00.jpg'),
|
252 |
+
# os.path.join(example_path, 'garment/12562_00.jpg'),
|
253 |
+
# os.path.join(example_path, 'garment/04825_00.jpg'),
|
254 |
+
# ])
|
255 |
+
# with gr.Column():
|
256 |
+
# result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
257 |
+
# with gr.Column():
|
258 |
+
# run_button = gr.Button(value="Run")
|
259 |
+
# n_samples = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1)
|
260 |
+
# n_steps = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1)
|
261 |
+
# # scale = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
262 |
+
# image_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
263 |
+
# seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
264 |
+
|
265 |
+
# ips = [vton_img, garm_img, n_samples, n_steps, image_scale, seed]
|
266 |
+
# run_button.click(fn=process_hd, inputs=ips, outputs=[result_gallery])
|
267 |
+
|
268 |
+
|
269 |
+
with gr.Row():
|
270 |
+
gr.Markdown("## Virtual Trial Room")
|
271 |
+
with gr.Row():
|
272 |
+
gr.Markdown("*** Note :- Please Select Garment Type in below drop-down as upper-body/lower-body/dresses;***")
|
273 |
+
with gr.Row():
|
274 |
+
with gr.Column():
|
275 |
+
vton_img_dc = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_dc)
|
276 |
+
example = gr.Examples(
|
277 |
+
label="Select for Upper/Lower Body",
|
278 |
+
inputs=vton_img_dc,
|
279 |
+
examples_per_page=7,
|
280 |
+
examples=[
|
281 |
+
os.path.join(example_path, 'model/model_8.png'),
|
282 |
+
os.path.join(example_path, 'model/049447_0.jpg'),
|
283 |
+
os.path.join(example_path, 'model/049713_0.jpg'),
|
284 |
+
os.path.join(example_path, 'model/051482_0.jpg'),
|
285 |
+
os.path.join(example_path, 'model/051918_0.jpg'),
|
286 |
+
os.path.join(example_path, 'model/051962_0.jpg'),
|
287 |
+
os.path.join(example_path, 'model/049205_0.jpg'),
|
288 |
+
]
|
289 |
+
)
|
290 |
+
example = gr.Examples(
|
291 |
+
label="Select for Full Body Dress",
|
292 |
+
inputs=vton_img_dc,
|
293 |
+
examples_per_page=7,
|
294 |
+
examples=[
|
295 |
+
os.path.join(example_path, 'model/model_9.png'),
|
296 |
+
# os.path.join(example_path, 'model/052767_0.jpg'),
|
297 |
+
# os.path.join(example_path, 'model/052472_0.jpg'),
|
298 |
+
os.path.join(example_path, 'model/053514_0.jpg'),
|
299 |
+
os.path.join(example_path, 'model/male/male_side.png'),
|
300 |
+
os.path.join(example_path, 'model/male/male_2.png'),
|
301 |
+
|
302 |
+
os.path.join(example_path, 'model/male/femal_s_34.png'),
|
303 |
+
os.path.join(example_path, 'model/male/femal_s_34_test.png'),
|
304 |
+
os.path.join(example_path, 'model/male/male_small.png'),
|
305 |
+
os.path.join(example_path, 'model/male/female.png'),
|
306 |
+
# os.path.join(example_path, 'model/053228_0.jpg'),
|
307 |
+
# os.path.join(example_path, 'model/052964_0.jpg'),
|
308 |
+
# os.path.join(example_path, 'model/053700_0.jpg'),
|
309 |
+
]
|
310 |
+
)
|
311 |
+
with gr.Column():
|
312 |
+
garm_img_dc = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_dc)
|
313 |
+
category_dc = gr.Dropdown(label="Garment category (important option!!!)", choices=["Upper-body", "Lower-body", "Dress"], value="Upper-body")
|
314 |
+
example = gr.Examples(
|
315 |
+
label="Examples (upper-body)",
|
316 |
+
inputs=garm_img_dc,
|
317 |
+
examples_per_page=7,
|
318 |
+
examples=[
|
319 |
+
os.path.join(example_path,'garment/01260_00.jpg'),
|
320 |
+
os.path.join(example_path,'garment/01430_00.jpg'),
|
321 |
+
os.path.join(example_path,'garment/02783_00.jpg'),
|
322 |
+
os.path.join(example_path,'garment/03751_00.jpg'),
|
323 |
+
os.path.join(example_path,'garment/06429_00.jpg'),
|
324 |
+
os.path.join(example_path,'garment/06802_00.jpg'),
|
325 |
+
os.path.join(example_path,'garment/07429_00.jpg'),
|
326 |
+
os.path.join(example_path,'garment/08348_00.jpg'),
|
327 |
+
os.path.join(example_path,'garment/09933_00.jpg'),
|
328 |
+
os.path.join(example_path,'garment/11028_00.jpg'),
|
329 |
+
os.path.join(example_path,'garment/11351_00.jpg'),
|
330 |
+
os.path.join(example_path,'garment/11791_00.jpg'),
|
331 |
+
os.path.join(example_path, 'garment/048554_1.jpg'),
|
332 |
+
os.path.join(example_path, 'garment/049920_1.jpg'),
|
333 |
+
os.path.join(example_path, 'garment/049965_1.jpg'),
|
334 |
+
os.path.join(example_path, 'garment/049949_1.jpg'),
|
335 |
+
os.path.join(example_path, 'garment/050181_1.jpg'),
|
336 |
+
os.path.join(example_path, 'garment/049805_1.jpg'),
|
337 |
+
os.path.join(example_path, 'garment/050105_1.jpg'),
|
338 |
+
os.path.join(example_path, 'garment/male_tshirt1.png'),
|
339 |
+
])
|
340 |
+
example = gr.Examples(
|
341 |
+
label="Examples (lower-body)",
|
342 |
+
inputs=garm_img_dc,
|
343 |
+
examples_per_page=7,
|
344 |
+
examples=[
|
345 |
+
os.path.join(example_path, 'garment/051827_1.jpg'),
|
346 |
+
os.path.join(example_path, 'garment/051946_1.jpg'),
|
347 |
+
os.path.join(example_path, 'garment/051473_1.jpg'),
|
348 |
+
os.path.join(example_path, 'garment/051515_1.jpg'),
|
349 |
+
os.path.join(example_path, 'garment/051517_1.jpg'),
|
350 |
+
os.path.join(example_path, 'garment/051988_1.jpg'),
|
351 |
+
os.path.join(example_path, 'garment/051412_1.jpg'),
|
352 |
+
])
|
353 |
+
example = gr.Examples(
|
354 |
+
label="Examples (dress)",
|
355 |
+
inputs=garm_img_dc,
|
356 |
+
examples_per_page=7,
|
357 |
+
examples=[
|
358 |
+
os.path.join(example_path, 'garment/053290_1.jpg'),
|
359 |
+
os.path.join(example_path, 'garment/053744_1.jpg'),
|
360 |
+
os.path.join(example_path, 'garment/053742_1.jpg'),
|
361 |
+
os.path.join(example_path, 'garment/053786_1.jpg'),
|
362 |
+
os.path.join(example_path, 'garment/053790_1.jpg'),
|
363 |
+
os.path.join(example_path, 'garment/053319_1.jpg'),
|
364 |
+
os.path.join(example_path, 'garment/052234_1.jpg'),
|
365 |
+
])
|
366 |
+
with gr.Column():
|
367 |
+
result_gallery_dc = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
368 |
+
with gr.Column():
|
369 |
+
run_button_dc = gr.Button(value="Run")
|
370 |
+
# n_samples_dc = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1)
|
371 |
+
# n_steps_dc = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1)
|
372 |
+
# scale_dc = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
373 |
+
# image_scale_dc = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
374 |
+
# seed_dc = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
375 |
+
|
376 |
+
ips_dc = [vton_img_dc, garm_img_dc, category_dc]
|
377 |
+
run_button_dc.click(fn=process_dc, inputs=ips_dc, outputs=[result_gallery_dc])
|
378 |
+
|
379 |
+
|
380 |
+
block.launch(server_name="0.0.0.0", server_port=7860 )
|
run/gradio_ootd.py
CHANGED
@@ -4,9 +4,9 @@ from pathlib import Path
|
|
4 |
import sys
|
5 |
import torch
|
6 |
from PIL import Image, ImageOps
|
7 |
-
|
8 |
from utils_ootd import get_mask_location
|
9 |
-
|
10 |
PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute()
|
11 |
sys.path.insert(0, str(PROJECT_ROOT))
|
12 |
|
@@ -14,15 +14,19 @@ from preprocess.openpose.run_openpose import OpenPose
|
|
14 |
from preprocess.humanparsing.run_parsing import Parsing
|
15 |
from ootd.inference_ootd_hd import OOTDiffusionHD
|
16 |
from ootd.inference_ootd_dc import OOTDiffusionDC
|
|
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
openpose_model_hd = OpenPose(0)
|
20 |
parsing_model_hd = Parsing(0)
|
21 |
ootd_model_hd = OOTDiffusionHD(0)
|
22 |
|
23 |
-
openpose_model_dc = OpenPose(
|
24 |
-
parsing_model_dc = Parsing(
|
25 |
-
ootd_model_dc = OOTDiffusionDC(
|
26 |
|
27 |
|
28 |
category_dict = ['upperbody', 'lowerbody', 'dress']
|
@@ -30,15 +34,36 @@ category_dict_utils = ['upper_body', 'lower_body', 'dresses']
|
|
30 |
|
31 |
|
32 |
example_path = os.path.join(os.path.dirname(__file__), 'examples')
|
|
|
33 |
model_hd = os.path.join(example_path, 'model/model_1.png')
|
34 |
garment_hd = os.path.join(example_path, 'garment/03244_00.jpg')
|
|
|
35 |
model_dc = os.path.join(example_path, 'model/model_8.png')
|
36 |
garment_dc = os.path.join(example_path, 'garment/048554_1.jpg')
|
37 |
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
@spaces.GPU
|
42 |
def process_hd(vton_img, garm_img, n_samples, n_steps, image_scale, seed):
|
43 |
model_type = 'hd'
|
44 |
category = 0 # 0:upperbody; 1:lowerbody; 2:dress
|
@@ -75,7 +100,9 @@ def process_hd(vton_img, garm_img, n_samples, n_steps, image_scale, seed):
|
|
75 |
|
76 |
return images
|
77 |
|
78 |
-
|
|
|
|
|
79 |
def process_dc(vton_img, garm_img, category):
|
80 |
model_type = 'dc'
|
81 |
if category == 'Upper-body':
|
@@ -86,21 +113,90 @@ def process_dc(vton_img, garm_img, category):
|
|
86 |
category =2
|
87 |
|
88 |
with torch.no_grad():
|
89 |
-
openpose_model_dc.preprocessor.body_estimation.model.to('cuda')
|
90 |
-
ootd_model_dc.pipe.to('cuda')
|
91 |
-
ootd_model_dc.image_encoder.to('cuda')
|
92 |
-
ootd_model_dc.text_encoder.to('cuda')
|
93 |
|
94 |
garm_img = Image.open(garm_img).resize((768, 1024))
|
95 |
vton_img = Image.open(vton_img).resize((768, 1024))
|
96 |
-
keypoints = openpose_model_dc(vton_img.resize((384, 512)))
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
mask = mask.resize((768, 1024), Image.NEAREST)
|
101 |
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
|
|
|
|
|
|
102 |
|
103 |
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
|
|
104 |
|
105 |
images = ootd_model_dc(
|
106 |
model_type=model_type,
|
@@ -110,167 +206,147 @@ def process_dc(vton_img, garm_img, category):
|
|
110 |
mask=mask,
|
111 |
image_ori=vton_img,
|
112 |
num_samples=1,
|
113 |
-
num_steps=
|
114 |
-
image_scale=2.0,
|
115 |
seed=-1,
|
116 |
)
|
117 |
|
118 |
return images
|
119 |
|
|
|
|
|
120 |
|
121 |
block = gr.Blocks().queue()
|
122 |
with block:
|
123 |
with gr.Row():
|
124 |
gr.Markdown("# ")
|
125 |
-
# with gr.Row():
|
126 |
-
# gr.Markdown("## Half-body-1")
|
127 |
-
# with gr.Row():
|
128 |
-
# gr.Markdown("***Support upper-body garments***")
|
129 |
-
# with gr.Row():
|
130 |
-
# with gr.Column():
|
131 |
-
# vton_img = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_hd)
|
132 |
-
# example = gr.Examples(
|
133 |
-
# inputs=vton_img,
|
134 |
-
# examples_per_page=14,
|
135 |
-
# examples=[
|
136 |
-
# os.path.join(example_path, 'model/model_1.png'),
|
137 |
-
# os.path.join(example_path, 'model/model_2.png'),
|
138 |
-
# os.path.join(example_path, 'model/model_3.png'),
|
139 |
-
# os.path.join(example_path, 'model/model_4.png'),
|
140 |
-
# os.path.join(example_path, 'model/model_5.png'),
|
141 |
-
# os.path.join(example_path, 'model/model_6.png'),
|
142 |
-
# os.path.join(example_path, 'model/model_7.png'),
|
143 |
-
# os.path.join(example_path, 'model/01008_00.jpg'),
|
144 |
-
# os.path.join(example_path, 'model/07966_00.jpg'),
|
145 |
-
# os.path.join(example_path, 'model/05997_00.jpg'),
|
146 |
-
# os.path.join(example_path, 'model/02849_00.jpg'),
|
147 |
-
# os.path.join(example_path, 'model/14627_00.jpg'),
|
148 |
-
# os.path.join(example_path, 'model/09597_00.jpg'),
|
149 |
-
# os.path.join(example_path, 'model/01861_00.jpg'),
|
150 |
-
# ])
|
151 |
-
# with gr.Column():
|
152 |
-
# garm_img = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_hd)
|
153 |
-
# example = gr.Examples(
|
154 |
-
# inputs=garm_img,
|
155 |
-
# examples_per_page=14,
|
156 |
-
# examples=[
|
157 |
-
# os.path.join(example_path, 'garment/03244_00.jpg'),
|
158 |
-
# os.path.join(example_path, 'garment/00126_00.jpg'),
|
159 |
-
# os.path.join(example_path, 'garment/03032_00.jpg'),
|
160 |
-
# os.path.join(example_path, 'garment/06123_00.jpg'),
|
161 |
-
# os.path.join(example_path, 'garment/02305_00.jpg'),
|
162 |
-
# os.path.join(example_path, 'garment/00055_00.jpg'),
|
163 |
-
# os.path.join(example_path, 'garment/00470_00.jpg'),
|
164 |
-
# os.path.join(example_path, 'garment/02015_00.jpg'),
|
165 |
-
# os.path.join(example_path, 'garment/10297_00.jpg'),
|
166 |
-
# os.path.join(example_path, 'garment/07382_00.jpg'),
|
167 |
-
# os.path.join(example_path, 'garment/07764_00.jpg'),
|
168 |
-
# os.path.join(example_path, 'garment/00151_00.jpg'),
|
169 |
-
# os.path.join(example_path, 'garment/12562_00.jpg'),
|
170 |
-
# os.path.join(example_path, 'garment/04825_00.jpg'),
|
171 |
-
# ])
|
172 |
-
# with gr.Column():
|
173 |
-
# result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
174 |
-
# with gr.Column():
|
175 |
-
# run_button = gr.Button(value="Run")
|
176 |
-
# n_samples = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1)
|
177 |
-
# n_steps = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1)
|
178 |
-
# # scale = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
179 |
-
# image_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
180 |
-
# seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
181 |
-
|
182 |
-
# ips = [vton_img, garm_img, n_samples, n_steps, image_scale, seed]
|
183 |
-
# run_button.click(fn=process_hd, inputs=ips, outputs=[result_gallery])
|
184 |
-
|
185 |
|
186 |
with gr.Row():
|
187 |
gr.Markdown("## Virtual Trial Room")
|
188 |
-
with gr.Row():
|
189 |
-
|
190 |
with gr.Row():
|
191 |
with gr.Column():
|
192 |
vton_img_dc = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_dc)
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
with gr.Column():
|
222 |
garm_img_dc = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_dc)
|
223 |
category_dc = gr.Dropdown(label="Garment category (important option!!!)", choices=["Upper-body", "Lower-body", "Dress"], value="Upper-body")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
example = gr.Examples(
|
225 |
label="Examples (upper-body)",
|
226 |
inputs=garm_img_dc,
|
|
|
|
|
|
|
|
|
227 |
examples_per_page=7,
|
228 |
examples=[
|
229 |
-
os.path.join(
|
230 |
-
os.path.join(
|
231 |
-
os.path.join(
|
232 |
-
os.path.join(
|
233 |
-
os.path.join(
|
234 |
-
os.path.join(
|
235 |
-
os.path.join(
|
236 |
-
os.path.join(
|
237 |
-
os.path.join(
|
238 |
-
os.path.join(
|
239 |
-
os.path.join(
|
240 |
-
os.path.join(
|
241 |
-
os.path.join(
|
242 |
-
os.path.join(
|
243 |
-
os.path.join(
|
244 |
-
os.path.join(
|
245 |
-
os.path.join(
|
246 |
-
os.path.join(
|
247 |
-
os.path.join(
|
|
|
248 |
])
|
249 |
example = gr.Examples(
|
250 |
label="Examples (lower-body)",
|
251 |
inputs=garm_img_dc,
|
252 |
examples_per_page=7,
|
253 |
examples=[
|
254 |
-
os.path.join(
|
255 |
-
os.path.join(
|
256 |
-
os.path.join(
|
257 |
-
os.path.join(
|
258 |
-
os.path.join(
|
259 |
-
os.path.join(
|
260 |
-
os.path.join(
|
261 |
])
|
|
|
|
|
|
|
262 |
example = gr.Examples(
|
263 |
label="Examples (dress)",
|
264 |
inputs=garm_img_dc,
|
265 |
examples_per_page=7,
|
266 |
examples=[
|
267 |
-
os.path.join(
|
268 |
-
os.path.join(
|
269 |
-
os.path.join(
|
270 |
-
os.path.join(
|
271 |
-
os.path.join(
|
272 |
-
os.path.join(
|
273 |
-
os.path.join(
|
274 |
])
|
275 |
with gr.Column():
|
276 |
result_gallery_dc = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
@@ -281,9 +357,12 @@ with block:
|
|
281 |
# scale_dc = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
282 |
# image_scale_dc = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
283 |
# seed_dc = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
284 |
-
|
285 |
-
ips_dc = [vton_img_dc, garm_img_dc, category_dc]
|
|
|
|
|
|
|
286 |
run_button_dc.click(fn=process_dc, inputs=ips_dc, outputs=[result_gallery_dc])
|
287 |
|
288 |
|
289 |
-
block.launch()
|
|
|
4 |
import sys
|
5 |
import torch
|
6 |
from PIL import Image, ImageOps
|
7 |
+
import numpy as np
|
8 |
from utils_ootd import get_mask_location
|
9 |
+
from cloths_db import cloths_map, modeL_db
|
10 |
PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute()
|
11 |
sys.path.insert(0, str(PROJECT_ROOT))
|
12 |
|
|
|
14 |
from preprocess.humanparsing.run_parsing import Parsing
|
15 |
from ootd.inference_ootd_hd import OOTDiffusionHD
|
16 |
from ootd.inference_ootd_dc import OOTDiffusionDC
|
17 |
+
from preprocess.openpose.annotator.openpose.util import draw_bodypose
|
18 |
+
|
19 |
+
# Set default dtype to float64
|
20 |
+
# torch.set_default_dtype(torch.float16)
|
21 |
|
22 |
|
23 |
openpose_model_hd = OpenPose(0)
|
24 |
parsing_model_hd = Parsing(0)
|
25 |
ootd_model_hd = OOTDiffusionHD(0)
|
26 |
|
27 |
+
openpose_model_dc = OpenPose(0)
|
28 |
+
parsing_model_dc = Parsing(0)
|
29 |
+
ootd_model_dc = OOTDiffusionDC(0)
|
30 |
|
31 |
|
32 |
category_dict = ['upperbody', 'lowerbody', 'dress']
|
|
|
34 |
|
35 |
|
36 |
example_path = os.path.join(os.path.dirname(__file__), 'examples')
|
37 |
+
garment_path = os.path.join(os.path.dirname(__file__), 'examples','garment')
|
38 |
model_hd = os.path.join(example_path, 'model/model_1.png')
|
39 |
garment_hd = os.path.join(example_path, 'garment/03244_00.jpg')
|
40 |
+
|
41 |
model_dc = os.path.join(example_path, 'model/model_8.png')
|
42 |
garment_dc = os.path.join(example_path, 'garment/048554_1.jpg')
|
43 |
|
44 |
+
openpose_model_dc.preprocessor.body_estimation.model.to('cuda')
|
45 |
+
ootd_model_dc.pipe.to('cuda')
|
46 |
+
ootd_model_dc.image_encoder.to('cuda')
|
47 |
+
ootd_model_dc.text_encoder.to('cuda')
|
48 |
|
49 |
+
def convert_to_image(image_array):
|
50 |
+
if isinstance(image_array, np.ndarray):
|
51 |
+
# Normalize the data to the range [0, 255]
|
52 |
+
image_array = 255 * (image_array - np.min(image_array)) / (np.max(image_array) - np.min(image_array))
|
53 |
+
# Convert to uint8
|
54 |
+
image_array = image_array.astype(np.uint8)
|
55 |
+
return Image.fromarray(image_array)
|
56 |
+
else:
|
57 |
+
# Convert to NumPy array first if necessary
|
58 |
+
image_array = np.array(image_array)
|
59 |
+
# Normalize and convert to uint8
|
60 |
+
image_array = 255 * (image_array - np.min(image_array)) / (np.max(image_array) - np.min(image_array))
|
61 |
+
image_array = image_array.astype(np.uint8)
|
62 |
+
return Image.fromarray(image_array)
|
63 |
+
|
64 |
+
# import spaces
|
65 |
|
66 |
+
# @spaces.GPU
|
67 |
def process_hd(vton_img, garm_img, n_samples, n_steps, image_scale, seed):
|
68 |
model_type = 'hd'
|
69 |
category = 0 # 0:upperbody; 1:lowerbody; 2:dress
|
|
|
100 |
|
101 |
return images
|
102 |
|
103 |
+
|
104 |
+
|
105 |
+
# @spaces.GPU
|
106 |
def process_dc(vton_img, garm_img, category):
|
107 |
model_type = 'dc'
|
108 |
if category == 'Upper-body':
|
|
|
113 |
category =2
|
114 |
|
115 |
with torch.no_grad():
|
116 |
+
# openpose_model_dc.preprocessor.body_estimation.model.to('cuda')
|
117 |
+
# ootd_model_dc.pipe.to('cuda')
|
118 |
+
# ootd_model_dc.image_encoder.to('cuda')
|
119 |
+
# ootd_model_dc.text_encoder.to('cuda')
|
120 |
|
121 |
garm_img = Image.open(garm_img).resize((768, 1024))
|
122 |
vton_img = Image.open(vton_img).resize((768, 1024))
|
123 |
+
keypoints ,candidate , subset = openpose_model_dc(vton_img.resize((384, 512)))
|
124 |
+
|
125 |
+
# print(len(keypoints["pose_keypoints_2d"]))
|
126 |
+
# print(keypoints["pose_keypoints_2d"])
|
127 |
+
|
128 |
+
# person_image = np.asarray(vton_img)
|
129 |
+
|
130 |
+
|
131 |
+
# print(len(person_image))
|
132 |
+
|
133 |
+
|
134 |
+
# person_image = np.asarray(Image.open(vton_img).resize((768, 1024)))
|
135 |
+
|
136 |
+
# output = draw_bodypose(canvas=person_image,candidate=candidate, subset=subset )
|
137 |
+
# output_image = Image.fromarray(output)
|
138 |
+
# output_image.save('keypose.png')
|
139 |
+
|
140 |
+
|
141 |
+
|
142 |
+
left_point = keypoints["pose_keypoints_2d"][2]
|
143 |
+
right_point = keypoints["pose_keypoints_2d"][5]
|
144 |
+
|
145 |
+
neck_point = keypoints["pose_keypoints_2d"][1]
|
146 |
+
hip_point = keypoints["pose_keypoints_2d"][8]
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
print(f'left shoulder - {left_point}')
|
151 |
+
print(f'right shoulder - {right_point}')
|
152 |
+
|
153 |
+
# #find disctance using Euclidian distance
|
154 |
+
shoulder_width_pixels = round(np.sqrt( np.power((right_point[0]-left_point[0]),2) + np.power((right_point[1]-left_point[1]),2)),2)
|
155 |
+
|
156 |
+
height_pixels = round(np.sqrt( np.power((neck_point[0]-hip_point[0]),2) + np.power((neck_point[1]-hip_point[1]),2)),2) *2
|
157 |
+
|
158 |
+
|
159 |
+
# # Assuming an average human height
|
160 |
+
average_height_cm = 172.72 *1.5
|
161 |
+
|
162 |
+
# Conversion factor from pixels to cm
|
163 |
+
conversion_factor = average_height_cm / height_pixels
|
164 |
+
|
165 |
+
# Convert shoulder width to real-world units
|
166 |
+
shoulder_width_cm = shoulder_width_pixels * conversion_factor
|
167 |
+
|
168 |
+
print(f'Shoulder width (in pixels): {shoulder_width_pixels}')
|
169 |
+
print(f'Estimated height (in pixels): {height_pixels}')
|
170 |
+
print(f'Conversion factor (pixels to cm): {conversion_factor}')
|
171 |
+
print(f'Shoulder width (in cm): {shoulder_width_cm}')
|
172 |
+
print(f'Shoulder width (in INCH): {round(shoulder_width_cm/2.54,1)}')
|
173 |
+
|
174 |
+
model_parse, face_mask = parsing_model_dc(vton_img.resize((384, 512)))
|
175 |
+
|
176 |
+
model_parse_image = convert_to_image(model_parse)
|
177 |
+
face_mask_image = convert_to_image(face_mask)
|
178 |
+
|
179 |
+
# Save the images
|
180 |
+
model_parse_image.save('model_parse_image.png')
|
181 |
+
face_mask_image.save('face_mask_image.png')
|
182 |
+
|
183 |
|
184 |
mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints)
|
185 |
+
|
186 |
+
# final_mask = convert_to_image(mask)
|
187 |
+
# final_mask.save("final_mask.png")
|
188 |
+
|
189 |
+
# final_mask_grat = convert_to_image(mask_gray)
|
190 |
+
# final_mask_grat.save("final_mask_grat.png")
|
191 |
+
|
192 |
mask = mask.resize((768, 1024), Image.NEAREST)
|
193 |
mask_gray = mask_gray.resize((768, 1024), Image.NEAREST)
|
194 |
+
# Save the resized masks
|
195 |
+
mask.save("mask_resized.png")
|
196 |
+
mask_gray.save("mask_gray_resized.png")
|
197 |
|
198 |
masked_vton_img = Image.composite(mask_gray, vton_img, mask)
|
199 |
+
masked_vton_img.save("masked_vton_img.png")
|
200 |
|
201 |
images = ootd_model_dc(
|
202 |
model_type=model_type,
|
|
|
206 |
mask=mask,
|
207 |
image_ori=vton_img,
|
208 |
num_samples=1,
|
209 |
+
num_steps=10,
|
210 |
+
image_scale= 2.0,
|
211 |
seed=-1,
|
212 |
)
|
213 |
|
214 |
return images
|
215 |
|
216 |
+
# is_upper = False
|
217 |
+
|
218 |
|
219 |
block = gr.Blocks().queue()
|
220 |
with block:
|
221 |
with gr.Row():
|
222 |
gr.Markdown("# ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
with gr.Row():
|
225 |
gr.Markdown("## Virtual Trial Room")
|
226 |
+
# with gr.Row():
|
227 |
+
# gr.Markdown("")
|
228 |
with gr.Row():
|
229 |
with gr.Column():
|
230 |
vton_img_dc = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_dc)
|
231 |
+
|
232 |
+
# Hidden component to store is_upper value
|
233 |
+
# is_upper = gr.State(value=True)
|
234 |
+
|
235 |
+
# #set is_upper variable to True when user selects examples from gr.examples upper/lower body
|
236 |
+
# def check_image_type(image_path):
|
237 |
+
# if image_path:
|
238 |
+
# filename = os.path.basename(image_path)
|
239 |
+
# image_type = modeL_db.get(filename, "no-dress") # Default to "no-dress" if not found
|
240 |
+
# return image_type == "no-dress"
|
241 |
+
# return False # Default to True if no image
|
242 |
+
|
243 |
+
# vton_img_dc.change(fn=check_image_type, inputs=vton_img_dc)
|
244 |
+
|
245 |
+
|
246 |
+
|
247 |
+
|
248 |
+
|
249 |
+
example = gr.Examples(
|
250 |
+
label="Select for Upper/Lower Body",
|
251 |
+
inputs=vton_img_dc,
|
252 |
+
examples_per_page=7,
|
253 |
+
examples=[
|
254 |
+
os.path.join(example_path, 'model/model_8.png'),
|
255 |
+
os.path.join(example_path, 'model/049447_0.jpg'),
|
256 |
+
os.path.join(example_path, 'model/049713_0.jpg'),
|
257 |
+
os.path.join(example_path, 'model/051482_0.jpg'),
|
258 |
+
os.path.join(example_path, 'model/051918_0.jpg'),
|
259 |
+
os.path.join(example_path, 'model/051962_0.jpg'),
|
260 |
+
os.path.join(example_path, 'model/049205_0.jpg'),
|
261 |
+
],
|
262 |
+
|
263 |
+
)
|
264 |
+
|
265 |
+
|
266 |
+
example = gr.Examples(
|
267 |
+
label="Select for Full Body Dress",
|
268 |
+
inputs=vton_img_dc,
|
269 |
+
examples_per_page=7,
|
270 |
+
examples=[
|
271 |
+
os.path.join(example_path, 'model/model_9.png'),
|
272 |
+
os.path.join(example_path, 'model/052767_0.jpg'),
|
273 |
+
os.path.join(example_path, 'model/052472_0.jpg'),
|
274 |
+
os.path.join(example_path, 'model/053514_0.jpg'),
|
275 |
+
os.path.join(example_path, 'model/053228_0.jpg'),
|
276 |
+
os.path.join(example_path, 'model/052964_0.jpg'),
|
277 |
+
os.path.join(example_path, 'model/053700_0.jpg'),
|
278 |
+
],
|
279 |
+
|
280 |
+
)
|
281 |
with gr.Column():
|
282 |
garm_img_dc = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_dc)
|
283 |
category_dc = gr.Dropdown(label="Garment category (important option!!!)", choices=["Upper-body", "Lower-body", "Dress"], value="Upper-body")
|
284 |
+
|
285 |
+
def update_category(image_path):
|
286 |
+
if image_path:
|
287 |
+
filename = os.path.basename(image_path)
|
288 |
+
return cloths_map.get(filename, None) # Return None if not found
|
289 |
+
return None # Return None if no image
|
290 |
+
|
291 |
+
garm_img_dc.change(fn=update_category, inputs=garm_img_dc, outputs=category_dc)
|
292 |
example = gr.Examples(
|
293 |
label="Examples (upper-body)",
|
294 |
inputs=garm_img_dc,
|
295 |
+
|
296 |
+
|
297 |
+
|
298 |
+
|
299 |
examples_per_page=7,
|
300 |
examples=[
|
301 |
+
os.path.join(garment_path,'01260_00.jpg'),
|
302 |
+
os.path.join(garment_path,'01430_00.jpg'),
|
303 |
+
os.path.join(garment_path,'02783_00.jpg'),
|
304 |
+
os.path.join(garment_path,'03751_00.jpg'),
|
305 |
+
os.path.join(garment_path,'06429_00.jpg'),
|
306 |
+
os.path.join(garment_path,'06802_00.jpg'),
|
307 |
+
os.path.join(garment_path,'07429_00.jpg'),
|
308 |
+
os.path.join(garment_path,'08348_00.jpg'),
|
309 |
+
os.path.join(garment_path,'09933_00.jpg'),
|
310 |
+
os.path.join(garment_path,'11028_00.jpg'),
|
311 |
+
os.path.join(garment_path,'11351_00.jpg'),
|
312 |
+
os.path.join(garment_path,'11791_00.jpg'),
|
313 |
+
os.path.join(garment_path, '048554_1.jpg'),
|
314 |
+
os.path.join(garment_path, '049920_1.jpg'),
|
315 |
+
os.path.join(garment_path, '049965_1.jpg'),
|
316 |
+
os.path.join(garment_path, '049949_1.jpg'),
|
317 |
+
os.path.join(garment_path, '050181_1.jpg'),
|
318 |
+
os.path.join(garment_path, '049805_1.jpg'),
|
319 |
+
os.path.join(garment_path, '050105_1.jpg'),
|
320 |
+
os.path.join(garment_path, 'male_tshirt1.png'),
|
321 |
])
|
322 |
example = gr.Examples(
|
323 |
label="Examples (lower-body)",
|
324 |
inputs=garm_img_dc,
|
325 |
examples_per_page=7,
|
326 |
examples=[
|
327 |
+
os.path.join(garment_path, '051827_1.jpg'),
|
328 |
+
os.path.join(garment_path, '051946_1.jpg'),
|
329 |
+
os.path.join(garment_path, '051473_1.jpg'),
|
330 |
+
os.path.join(garment_path, '051515_1.jpg'),
|
331 |
+
os.path.join(garment_path, '051517_1.jpg'),
|
332 |
+
os.path.join(garment_path, '051988_1.jpg'),
|
333 |
+
os.path.join(garment_path, '051412_1.jpg'),
|
334 |
])
|
335 |
+
|
336 |
+
|
337 |
+
|
338 |
example = gr.Examples(
|
339 |
label="Examples (dress)",
|
340 |
inputs=garm_img_dc,
|
341 |
examples_per_page=7,
|
342 |
examples=[
|
343 |
+
os.path.join(garment_path, '053290_1.jpg'),
|
344 |
+
os.path.join(garment_path, '053744_1.jpg'),
|
345 |
+
os.path.join(garment_path, '053742_1.jpg'),
|
346 |
+
os.path.join(garment_path, '053786_1.jpg'),
|
347 |
+
os.path.join(garment_path, '053790_1.jpg'),
|
348 |
+
os.path.join(garment_path, '053319_1.jpg'),
|
349 |
+
os.path.join(garment_path, '052234_1.jpg'),
|
350 |
])
|
351 |
with gr.Column():
|
352 |
result_gallery_dc = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
|
|
357 |
# scale_dc = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
358 |
# image_scale_dc = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
359 |
# seed_dc = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
360 |
+
|
361 |
+
# ips_dc = [vton_img_dc, garm_img_dc, category_dc]
|
362 |
+
|
363 |
+
|
364 |
+
ips_dc = [vton_img_dc, garm_img_dc ,category_dc]
|
365 |
run_button_dc.click(fn=process_dc, inputs=ips_dc, outputs=[result_gallery_dc])
|
366 |
|
367 |
|
368 |
+
block.launch(server_name="0.0.0.0", server_port=7860 )
|
test_df.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
|
3 |
+
def check_bf16_support():
|
4 |
+
if not torch.cuda.is_available():
|
5 |
+
print("CUDA is not available on this system.")
|
6 |
+
return False
|
7 |
+
|
8 |
+
device = torch.device("cuda")
|
9 |
+
capability = torch.cuda.get_device_capability(device)
|
10 |
+
|
11 |
+
# As of now, GPUs with compute capability >= 8.0 support BF16
|
12 |
+
# Example: NVIDIA A100 has compute capability 8.0
|
13 |
+
bf16_supported = capability[0] >= 8
|
14 |
+
|
15 |
+
print(f"GPU Compute Capability: {capability}")
|
16 |
+
if bf16_supported:
|
17 |
+
print("BF16 is supported on this GPU.")
|
18 |
+
else:
|
19 |
+
print("BF16 is not supported on this GPU.")
|
20 |
+
|
21 |
+
return bf16_supported
|
22 |
+
|
23 |
+
# Check if BF16 is supported
|
24 |
+
check_bf16_support()
|