vibs08 commited on
Commit
95ec856
·
verified ·
1 Parent(s): 2647415

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -31,7 +31,8 @@ from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orienta
31
 
32
 
33
  HEADER = """FRAME AI"""
34
- torch.cuda.empty_cache()
 
35
  if torch.cuda.is_available():
36
  device = "cuda:0"
37
  else:
@@ -150,6 +151,7 @@ def check_input_image(input_image):
150
  raise gr.Error("No image uploaded!")
151
 
152
  def preprocess(input_image, do_remove_background, foreground_ratio):
 
153
  def fill_background(image):
154
  image = np.array(image).astype(np.float32) / 255.0
155
  image = image[:, :, :3] * image[:, :, 3:4] + (1 - image[:, :, 3:4]) * 0.5
@@ -165,6 +167,7 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
165
  image = input_image
166
  if image.mode == "RGBA":
167
  image = fill_background(image)
 
168
  return image
169
 
170
  @spaces.GPU
 
31
 
32
 
33
  HEADER = """FRAME AI"""
34
+
35
+
36
  if torch.cuda.is_available():
37
  device = "cuda:0"
38
  else:
 
151
  raise gr.Error("No image uploaded!")
152
 
153
  def preprocess(input_image, do_remove_background, foreground_ratio):
154
+ torch.cuda.synchronize()
155
  def fill_background(image):
156
  image = np.array(image).astype(np.float32) / 255.0
157
  image = image[:, :, :3] * image[:, :, 3:4] + (1 - image[:, :, 3:4]) * 0.5
 
167
  image = input_image
168
  if image.mode == "RGBA":
169
  image = fill_background(image)
170
+ torch.cuda.synchronize()
171
  return image
172
 
173
  @spaces.GPU