lixiang46 commited on
Commit
aecd249
1 Parent(s): 4e460bd
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -32,7 +32,7 @@ def tryon(person_img, garment_img, seed, randomize_seed):
32
  "seed": seed
33
  }
34
  try:
35
- response = requests.post(url, headers=headers, data=json.dumps(data), timeout=30)
36
  print("post response code", response.status_code)
37
  if response.status_code == 200:
38
  result = response.json()['result']
@@ -48,10 +48,12 @@ def tryon(person_img, garment_img, seed, randomize_seed):
48
  get_start_time =time.time()
49
  Max_Retry = 3
50
  for i in range(Max_Retry):
 
51
  try:
52
  url = "http://" + os.environ['tryon_url'] + "Query?" + uuid
53
  response = requests.get(url, headers=headers, timeout=10)
54
  print("get response code", response.status_code)
 
55
  if response.status_code == 200:
56
  result = response.json()['result']
57
  status = result['status']
@@ -69,14 +71,10 @@ def tryon(person_img, garment_img, seed, randomize_seed):
69
  print("timeout")
70
  info = "Too many users, please try again later"
71
  raise gr.Error("Too many users, please try again later")
72
- time.sleep(3)
73
  get_end_time = time.time()
74
  print(f"time used: {get_end_time-get_start_time}")
75
 
76
  return result_img, seed, info
77
-
78
-
79
-
80
 
81
  def start_tryon(person_img, garment_img, seed, randomize_seed):
82
  start_time = time.time()
 
32
  "seed": seed
33
  }
34
  try:
35
+ response = requests.post(url, headers=headers, data=json.dumps(data), timeout=20)
36
  print("post response code", response.status_code)
37
  if response.status_code == 200:
38
  result = response.json()['result']
 
48
  get_start_time =time.time()
49
  Max_Retry = 3
50
  for i in range(Max_Retry):
51
+ time.sleep(3)
52
  try:
53
  url = "http://" + os.environ['tryon_url'] + "Query?" + uuid
54
  response = requests.get(url, headers=headers, timeout=10)
55
  print("get response code", response.status_code)
56
+ print(response.text)
57
  if response.status_code == 200:
58
  result = response.json()['result']
59
  status = result['status']
 
71
  print("timeout")
72
  info = "Too many users, please try again later"
73
  raise gr.Error("Too many users, please try again later")
 
74
  get_end_time = time.time()
75
  print(f"time used: {get_end_time-get_start_time}")
76
 
77
  return result_img, seed, info
 
 
 
78
 
79
  def start_tryon(person_img, garment_img, seed, randomize_seed):
80
  start_time = time.time()