Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,19 +4,17 @@ from ultralytics import YOLO
|
|
| 4 |
from huggingface_hub import snapshot_download
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
# Download the model from HF Hub (if not already cached)
|
| 8 |
model_dir = snapshot_download("cazzz307/Pothole-Finetuned-YoloV8")
|
| 9 |
-
model_path = os.path.join(model_dir, "
|
| 10 |
|
| 11 |
-
# Load model
|
| 12 |
model = YOLO(model_path)
|
| 13 |
|
| 14 |
def detect_potholes(image: Image.Image):
|
| 15 |
results = model(image)
|
| 16 |
-
annotated_img = results[0].plot()
|
| 17 |
return Image.fromarray(annotated_img)
|
| 18 |
|
| 19 |
-
|
| 20 |
demo = gr.Interface(
|
| 21 |
fn=detect_potholes,
|
| 22 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 4 |
from huggingface_hub import snapshot_download
|
| 5 |
import os
|
| 6 |
|
|
|
|
| 7 |
model_dir = snapshot_download("cazzz307/Pothole-Finetuned-YoloV8")
|
| 8 |
+
model_path = os.path.join(model_dir, "Yolov8-fintuned-on-potholes.pt")
|
| 9 |
|
|
|
|
| 10 |
model = YOLO(model_path)
|
| 11 |
|
| 12 |
def detect_potholes(image: Image.Image):
|
| 13 |
results = model(image)
|
| 14 |
+
annotated_img = results[0].plot()
|
| 15 |
return Image.fromarray(annotated_img)
|
| 16 |
|
| 17 |
+
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=detect_potholes,
|
| 20 |
inputs=gr.Image(type="pil"),
|