lixiang46 commited on
Commit
6af3026
1 Parent(s): 8654223
Files changed (2) hide show
  1. app.py +19 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import numpy as np
6
  import random
7
  import base64
8
  import requests
 
9
 
10
 
11
  def start_tryon(person_img, garment_img, seed, randomize_seed):
@@ -19,8 +20,24 @@ def start_tryon(person_img, garment_img, seed, randomize_seed):
19
  url = "http://" + os.environ['tryon_url']
20
  token = os.environ['token']
21
  print(url, token)
22
-
23
- return person_img, seed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  MAX_SEED = 999999
26
 
 
6
  import random
7
  import base64
8
  import requests
9
+ import json
10
 
11
 
12
  def start_tryon(person_img, garment_img, seed, randomize_seed):
 
20
  url = "http://" + os.environ['tryon_url']
21
  token = os.environ['token']
22
  print(url, token)
23
+ headers = {'Content-Type': 'application/json', 'token': token}
24
+ data = {
25
+ "clothImage": encoded_garment_img,
26
+ "humanImage": encoded_person_img,
27
+ "seed": seed
28
+ }
29
+
30
+ # response = requests.post(url, headers=headers, data=json.dumps(data))
31
+ # print("response code", response.status_code)
32
+ # if response.status_code == 200:
33
+ # result = response.json()
34
+ # result = base64.b64decode(result['images'][0])
35
+ # result_np = np.frombuffer(result, np.uint8)
36
+ # result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
37
+
38
+ result_img = cv2.imdecode(np.frombuffer(base64.b64decode(encoded_person_img), np.uint8), cv2.IMREAD_UNCHANGED)
39
+
40
+ return result_img, seed
41
 
42
  MAX_SEED = 999999
43
 
requirements.txt CHANGED
@@ -5,4 +5,5 @@ torch
5
  transformers
6
  xformers
7
  opencv-python
8
- requests
 
 
5
  transformers
6
  xformers
7
  opencv-python
8
+ requests
9
+ json