lixiang46 commited on
Commit
b6434bc
1 Parent(s): ffca2ae
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import cv2
 
3
  from PIL import Image
4
  import gradio as gr
5
  import numpy as np
@@ -8,8 +9,8 @@ import base64
8
  import requests
9
  import json
10
  import time
11
- from requests.adapters import HTTPAdapter
12
 
 
13
  def tryon(person_img, garment_img, seed, randomize_seed):
14
  post_start_time = time.time()
15
  if person_img is None or garment_img is None:
@@ -73,6 +74,8 @@ def tryon(person_img, garment_img, seed, randomize_seed):
73
  except requests.exceptions.ReadTimeout:
74
  print("timeout")
75
  info = "Too many users, please try again later"
 
 
76
  time.sleep(1)
77
  get_end_time = time.time()
78
  print(f"get time used: {get_end_time-get_start_time}")
 
1
  import os
2
  import cv2
3
+ import spaces
4
  from PIL import Image
5
  import gradio as gr
6
  import numpy as np
 
9
  import requests
10
  import json
11
  import time
 
12
 
13
+ @spaces.GPU
14
  def tryon(person_img, garment_img, seed, randomize_seed):
15
  post_start_time = time.time()
16
  if person_img is None or garment_img is None:
 
74
  except requests.exceptions.ReadTimeout:
75
  print("timeout")
76
  info = "Too many users, please try again later"
77
+ except Exception as err:
78
+ print(f"Error: {err}")
79
  time.sleep(1)
80
  get_end_time = time.time()
81
  print(f"get time used: {get_end_time-get_start_time}")