lixiang46 commited on
Commit
5e35140
1 Parent(s): 3ea9ed2
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -20,21 +20,26 @@ def start_tryon(person_img, garment_img, seed, randomize_seed):
20
  url = "https://" + os.environ['tryon_url']
21
  token = os.environ['token']
22
  cookie = os.environ['Cookie']
 
23
  headers = {'Content-Type': 'application/json', 'token': token, 'Cookie': cookie}
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
  print("response", response, type(response))
33
  if response.status_code == 200:
34
- result = response.json()
35
- result = base64.b64decode(result['images'][0])
36
- result_np = np.frombuffer(result, np.uint8)
37
- result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
 
 
 
38
 
39
  # result_img = cv2.imdecode(np.frombuffer(base64.b64decode(encoded_person_img), np.uint8), cv2.IMREAD_UNCHANGED)
40
 
@@ -53,11 +58,11 @@ human_list_path = [os.path.join(example_path,"human",human) for human in human_l
53
  css="""
54
  #col-left {
55
  margin: 0 auto;
56
- max-width: 400px;
57
  }
58
  #col-mid {
59
  margin: 0 auto;
60
- max-width: 400px;
61
  }
62
  #col-right {
63
  margin: 0 auto;
 
20
  url = "https://" + os.environ['tryon_url']
21
  token = os.environ['token']
22
  cookie = os.environ['Cookie']
23
+
24
  headers = {'Content-Type': 'application/json', 'token': token, 'Cookie': cookie}
25
  data = {
26
  "clothImage": encoded_garment_img,
27
  "humanImage": encoded_person_img,
28
  "seed": seed
29
  }
30
+ # print(url, token, cookie, encoded_garment_imgm, encoded_person_img)
31
 
32
  response = requests.post(url, headers=headers, data=json.dumps(data))
33
  print("response code", response.status_code)
34
  print("response", response, type(response))
35
  if response.status_code == 200:
36
+ result = response.json()['result']
37
+ print("result", result)
38
+ status = response['status']
39
+ if status == "success":
40
+ result = base64.b64decode(result['result'])
41
+ result_np = np.frombuffer(result, np.uint8)
42
+ result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
43
 
44
  # result_img = cv2.imdecode(np.frombuffer(base64.b64decode(encoded_person_img), np.uint8), cv2.IMREAD_UNCHANGED)
45
 
 
58
  css="""
59
  #col-left {
60
  margin: 0 auto;
61
+ max-width: 380px;
62
  }
63
  #col-mid {
64
  margin: 0 auto;
65
+ max-width: 380px;
66
  }
67
  #col-right {
68
  margin: 0 auto;