Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,25 +2,16 @@ import torch
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import pandas as pd
|
| 4 |
import seaborn as sns
|
| 5 |
-
from ultralytics import YOLO
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
MODEL_PATH = "
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
raise FileNotFoundError(f"Test image not found at {TEST_IMAGE}")
|
| 21 |
-
|
| 22 |
-
results = model(TEST_IMAGE)
|
| 23 |
-
|
| 24 |
-
for r in results:
|
| 25 |
-
print(r.boxes)
|
| 26 |
-
r.show()
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import pandas as pd
|
| 4 |
import seaborn as sns
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Path to model
|
| 7 |
+
MODEL_PATH = "Model/EvoSEGA/evoSEGA.pt"
|
| 8 |
|
| 9 |
+
# Load YOLOv5 model
|
| 10 |
+
model = torch.hub.load("ultralytics/yolov5", "custom", path=MODEL_PATH, force_reload=True)
|
| 11 |
|
| 12 |
+
# Run inference
|
| 13 |
+
results = model("test.jpg")
|
| 14 |
|
| 15 |
+
# Print results
|
| 16 |
+
print(results.pandas().xyxy[0]) # Pandas dataframe
|
| 17 |
+
results.show() # Show image with detections
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|