SauravMaheshkar commited on
Commit
46abea7
1 Parent(s): dcd31d7

feat: migrate to ZeroGPU

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  import numpy as np
3
  import cv2
4
 
 
 
5
  from PIL import Image
6
 
7
  from src.plot_utils import show_masks
@@ -18,7 +20,7 @@ choice_mapping = {
18
  "large": ["sam2_hiera_l.yaml", "assets/checkpoints/sam2_hiera_large.pt"],
19
  }
20
 
21
-
22
  def predict(model_choice: str, annotations, image):
23
  config_file, ckpt_path = choice_mapping[str(model_choice)]
24
  sam2_model = build_sam2(config_file, ckpt_path, device="cpu")
 
2
  import numpy as np
3
  import cv2
4
 
5
+ import spaces
6
+
7
  from PIL import Image
8
 
9
  from src.plot_utils import show_masks
 
20
  "large": ["sam2_hiera_l.yaml", "assets/checkpoints/sam2_hiera_large.pt"],
21
  }
22
 
23
+ @spaces.GPU
24
  def predict(model_choice: str, annotations, image):
25
  config_file, ckpt_path = choice_mapping[str(model_choice)]
26
  sam2_model = build_sam2(config_file, ckpt_path, device="cpu")
requirements.txt CHANGED
@@ -1,4 +1,5 @@
 
1
  gradio
2
  gradio_image_annotation
3
  opencv-python
4
- samv2
 
1
+ git+https://github.com/facebookresearch/segment-anything-2.git
2
  gradio
3
  gradio_image_annotation
4
  opencv-python
5
+ spaces