chris-propeller commited on
Commit
b61fb4c
Β·
1 Parent(s): 45fae41
Files changed (2) hide show
  1. app.py +2 -0
  2. requirements.txt +2 -1
app.py CHANGED
@@ -7,6 +7,7 @@ import io
7
  import cv2
8
  from typing import Dict, Any, List, Optional
9
  from transformers import Sam3Model, Sam3Processor
 
10
 
11
  class SAM3Handler:
12
  """SAM3 handler for both UI and API access"""
@@ -24,6 +25,7 @@ class SAM3Handler:
24
  self.processor = Sam3Processor.from_pretrained("facebook/sam3")
25
  print("SAM3 model loaded successfully")
26
 
 
27
  def predict(self, image, text_prompt, confidence_threshold=0.5):
28
  """
29
  Main prediction function for both UI and API
 
7
  import cv2
8
  from typing import Dict, Any, List, Optional
9
  from transformers import Sam3Model, Sam3Processor
10
+ import spaces
11
 
12
  class SAM3Handler:
13
  """SAM3 handler for both UI and API access"""
 
25
  self.processor = Sam3Processor.from_pretrained("facebook/sam3")
26
  print("SAM3 model loaded successfully")
27
 
28
+ @spaces.GPU
29
  def predict(self, image, text_prompt, confidence_threshold=0.5):
30
  """
31
  Main prediction function for both UI and API
requirements.txt CHANGED
@@ -9,4 +9,5 @@ accelerate
9
  opencv-python
10
  huggingface-hub
11
  tokenizers
12
- gradio
 
 
9
  opencv-python
10
  huggingface-hub
11
  tokenizers
12
+ gradio
13
+ spaces