DawnC commited on
Commit
a4c5b38
1 Parent(s): 8e90922

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -33,9 +33,10 @@ from html_templates import (
33
  )
34
  from urllib.parse import quote
35
  from ultralytics import YOLO
36
- from device_manager import DeviceManager
37
  import asyncio
38
  import traceback
 
39
 
40
 
41
  # model_yolo = YOLO('yolov8l.pt')
@@ -622,6 +623,7 @@ def preprocess_image(image):
622
 
623
  return transform(image).unsqueeze(0)
624
 
 
625
  async def predict_single_dog(image):
626
  """
627
  Predicts the dog breed using only the classifier.
@@ -655,7 +657,8 @@ async def predict_single_dog(image):
655
  return await predict_single_dog(image) # 遞迴調用,使用 CPU
656
  raise e
657
 
658
-
 
659
  async def detect_multiple_dogs(image, conf_threshold=0.3, iou_threshold=0.55):
660
  results = model_yolo(image, conf=conf_threshold, iou=iou_threshold)[0]
661
  dogs = []
 
33
  )
34
  from urllib.parse import quote
35
  from ultralytics import YOLO
36
+ from device_manager import DeviceManager, device_handler
37
  import asyncio
38
  import traceback
39
+ import spaces
40
 
41
 
42
  # model_yolo = YOLO('yolov8l.pt')
 
623
 
624
  return transform(image).unsqueeze(0)
625
 
626
+ @device_handler
627
  async def predict_single_dog(image):
628
  """
629
  Predicts the dog breed using only the classifier.
 
657
  return await predict_single_dog(image) # 遞迴調用,使用 CPU
658
  raise e
659
 
660
+
661
+ @device_handler
662
  async def detect_multiple_dogs(image, conf_threshold=0.3, iou_threshold=0.55):
663
  results = model_yolo(image, conf=conf_threshold, iou=iou_threshold)[0]
664
  dogs = []