Spaces:
Sleeping
Sleeping
jovian
commited on
Commit
·
e237fa7
1
Parent(s):
ae429f8
Add application file
Browse files
app.py
CHANGED
|
@@ -13,6 +13,8 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
| 13 |
|
| 14 |
|
| 15 |
class Detection:
|
|
|
|
|
|
|
| 16 |
def __init__(self):
|
| 17 |
# Set the model path and confidence threshold
|
| 18 |
yolov8_model_path = "./model/best.pt" # Update to your model path
|
|
@@ -25,7 +27,6 @@ class Detection:
|
|
| 25 |
device=device # Change to 'cuda:0' if you are using a GPU
|
| 26 |
)
|
| 27 |
|
| 28 |
-
@spaces.GPU
|
| 29 |
def detect_from_image(self, image):
|
| 30 |
# Perform sliced prediction with SAHI
|
| 31 |
results = get_sliced_prediction(
|
|
@@ -39,7 +40,6 @@ class Detection:
|
|
| 39 |
postprocess_match_metric='IOU',
|
| 40 |
postprocess_match_threshold=0.1,
|
| 41 |
postprocess_class_agnostic=True,
|
| 42 |
-
device=device
|
| 43 |
)
|
| 44 |
|
| 45 |
# Retrieve COCO annotations
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
class Detection:
|
| 16 |
+
|
| 17 |
+
@spaces.GPU
|
| 18 |
def __init__(self):
|
| 19 |
# Set the model path and confidence threshold
|
| 20 |
yolov8_model_path = "./model/best.pt" # Update to your model path
|
|
|
|
| 27 |
device=device # Change to 'cuda:0' if you are using a GPU
|
| 28 |
)
|
| 29 |
|
|
|
|
| 30 |
def detect_from_image(self, image):
|
| 31 |
# Perform sliced prediction with SAHI
|
| 32 |
results = get_sliced_prediction(
|
|
|
|
| 40 |
postprocess_match_metric='IOU',
|
| 41 |
postprocess_match_threshold=0.1,
|
| 42 |
postprocess_class_agnostic=True,
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
# Retrieve COCO annotations
|