JasonYinnnn commited on
Commit
c187f4c
·
1 Parent(s): f37905f

spaces.GPU

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +4 -6
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🦀
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 4.36.1
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
 
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 4.38.1
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
app.py CHANGED
@@ -174,8 +174,8 @@ def cleanup_tmp(tmp_root: str = "./tmp", expire_seconds: int = 3600) -> None:
174
  except Exception as e:
175
  print(f"[cleanup_tmp] failed to remove {path}: {e}")
176
 
177
- @torch.no_grad()
178
  @spaces.GPU
 
179
  def run_segmentation(
180
  image_prompts: Any,
181
  polygon_refinement: bool = True,
@@ -187,8 +187,7 @@ def run_segmentation(
187
 
188
  # pre-process the layers and get the xyxy boxes of each layer
189
  if len(image_prompts["points"]) == 0:
190
- gr.Error("No points provided for segmentation. Please add points to the image.")
191
- return None
192
 
193
  boxes = [
194
  [
@@ -221,8 +220,8 @@ def run_segmentation(
221
 
222
  return seg_map_pil
223
 
224
- @torch.no_grad()
225
  @spaces.GPU
 
226
  def run_depth_estimation(
227
  image_prompts: Any,
228
  seg_image: Union[str, Image.Image],
@@ -333,7 +332,6 @@ def set_random_seed(seed):
333
  if torch.cuda.is_available():
334
  torch.cuda.manual_seed_all(seed)
335
 
336
- @spaces.GPU
337
  def export_single_glb_from_outputs(
338
  outputs,
339
  fine_scale,
@@ -387,8 +385,8 @@ def get_duration(rgb_image, seg_image, seed, randomize_seed,
387
  step_duration = 15.0
388
  return instance_labels.shape[0] * step_duration
389
 
390
- @torch.no_grad()
391
  @spaces.GPU(duration=get_duration)
 
392
  def run_generation(
393
  rgb_image: Any,
394
  seg_image: Union[str, Image.Image],
 
174
  except Exception as e:
175
  print(f"[cleanup_tmp] failed to remove {path}: {e}")
176
 
 
177
  @spaces.GPU
178
+ @torch.no_grad()
179
  def run_segmentation(
180
  image_prompts: Any,
181
  polygon_refinement: bool = True,
 
187
 
188
  # pre-process the layers and get the xyxy boxes of each layer
189
  if len(image_prompts["points"]) == 0:
190
+ raise gr.Error("No points provided for segmentation. Please add points to the image.")
 
191
 
192
  boxes = [
193
  [
 
220
 
221
  return seg_map_pil
222
 
 
223
  @spaces.GPU
224
+ @torch.no_grad()
225
  def run_depth_estimation(
226
  image_prompts: Any,
227
  seg_image: Union[str, Image.Image],
 
332
  if torch.cuda.is_available():
333
  torch.cuda.manual_seed_all(seed)
334
 
 
335
  def export_single_glb_from_outputs(
336
  outputs,
337
  fine_scale,
 
385
  step_duration = 15.0
386
  return instance_labels.shape[0] * step_duration
387
 
 
388
  @spaces.GPU(duration=get_duration)
389
+ @torch.no_grad()
390
  def run_generation(
391
  rgb_image: Any,
392
  seg_image: Union[str, Image.Image],