tournas commited on
Commit
86ad5b0
·
verified ·
1 Parent(s): fca69f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -10,6 +10,7 @@ from ultralytics import YOLO
10
  from gtts import gTTS
11
  from PIL import Image
12
  from nltk.tokenize import sent_tokenize
 
13
 
14
  # Set device (use GPU if available, but don't initialize CUDA here)
15
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -25,6 +26,7 @@ client = OpenAI(api_key=api_key)
25
  # Download NLTK data
26
  nltk.download("punkt")
27
 
 
28
  # Lazy-load models to avoid initializing CUDA in the main process
29
  def load_yolo_model():
30
  return YOLO("yolov8s.pt")
 
10
  from gtts import gTTS
11
  from PIL import Image
12
  from nltk.tokenize import sent_tokenize
13
+ import spaces
14
 
15
  # Set device (use GPU if available, but don't initialize CUDA here)
16
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
26
  # Download NLTK data
27
  nltk.download("punkt")
28
 
29
+ @spaces.GPU
30
  # Lazy-load models to avoid initializing CUDA in the main process
31
  def load_yolo_model():
32
  return YOLO("yolov8s.pt")