Spaces:
Sleeping
Sleeping
lixiang46
commited on
Commit
•
efa1709
1
Parent(s):
b453f9d
test
Browse files
app.py
CHANGED
@@ -12,9 +12,9 @@ import json
|
|
12 |
def start_tryon(person_img, garment_img, seed, randomize_seed):
|
13 |
if randomize_seed:
|
14 |
seed = random.randint(0, MAX_SEED)
|
15 |
-
encoded_person_img = cv2.imencode('.jpg', person_img)[1].tobytes()
|
16 |
encoded_person_img = base64.b64encode(encoded_person_img).decode('utf-8')
|
17 |
-
encoded_garment_img = cv2.imencode('.jpg', garment_img)[1].tobytes()
|
18 |
encoded_garment_img = base64.b64encode(encoded_garment_img).decode('utf-8')
|
19 |
|
20 |
url = "https://" + os.environ['tryon_url']
|
@@ -38,6 +38,7 @@ def start_tryon(person_img, garment_img, seed, randomize_seed):
|
|
38 |
result = base64.b64decode(result['result'])
|
39 |
result_np = np.frombuffer(result, np.uint8)
|
40 |
result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
|
|
|
41 |
info = "Success"
|
42 |
else:
|
43 |
info = "Try again latter"
|
@@ -117,6 +118,11 @@ with gr.Blocks(css=css) as Tryon:
|
|
117 |
|
118 |
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used, result_info], api_name='tryon')
|
119 |
|
|
|
|
|
|
|
|
|
|
|
120 |
ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()
|
121 |
print("ip address", ip)
|
122 |
Tryon.queue(max_size=10).launch()
|
|
|
12 |
def start_tryon(person_img, garment_img, seed, randomize_seed):
|
13 |
if randomize_seed:
|
14 |
seed = random.randint(0, MAX_SEED)
|
15 |
+
encoded_person_img = cv2.imencode('.jpg', cv2.cv2Colors(person_img, cv2.COLOR_RGB2BGR))[1].tobytes()
|
16 |
encoded_person_img = base64.b64encode(encoded_person_img).decode('utf-8')
|
17 |
+
encoded_garment_img = cv2.imencode('.jpg', cv2.cv2Colors(garment_img, cv2.COLOR_RGB2BGR))[1].tobytes()
|
18 |
encoded_garment_img = base64.b64encode(encoded_garment_img).decode('utf-8')
|
19 |
|
20 |
url = "https://" + os.environ['tryon_url']
|
|
|
38 |
result = base64.b64decode(result['result'])
|
39 |
result_np = np.frombuffer(result, np.uint8)
|
40 |
result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
|
41 |
+
result_img = cv2.cv2Colors(result_img, cv2.COLOR_RGB2BGR)
|
42 |
info = "Success"
|
43 |
else:
|
44 |
info = "Try again latter"
|
|
|
118 |
|
119 |
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used, result_info], api_name='tryon')
|
120 |
|
121 |
+
# with gr.Row(label="Examples"):
|
122 |
+
# with gr.Column(elem_id = "col-left"):
|
123 |
+
# imgs = gr.Image(label="Person image", sources='upload', type="numpy")
|
124 |
+
|
125 |
+
|
126 |
ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()
|
127 |
print("ip address", ip)
|
128 |
Tryon.queue(max_size=10).launch()
|