Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
lixiang46
commited on
Commit
•
5479e73
1
Parent(s):
efa1709
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', cv2.
|
16 |
encoded_person_img = base64.b64encode(encoded_person_img).decode('utf-8')
|
17 |
-
encoded_garment_img = cv2.imencode('.jpg', cv2.
|
18 |
encoded_garment_img = base64.b64encode(encoded_garment_img).decode('utf-8')
|
19 |
|
20 |
url = "https://" + os.environ['tryon_url']
|
@@ -38,7 +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 |
-
result_img = cv2.
|
42 |
info = "Success"
|
43 |
else:
|
44 |
info = "Try again latter"
|
|
|
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.cvtColors(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.cvtColors(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.cvtColors(result_img, cv2.COLOR_RGB2BGR)
|
42 |
info = "Success"
|
43 |
else:
|
44 |
info = "Try again latter"
|