Update app.py
Browse files
app.py
CHANGED
|
@@ -20,22 +20,19 @@ templates = Jinja2Templates(directory="templates")
|
|
| 20 |
|
| 21 |
|
| 22 |
def predict_yolo(image_path):
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
files = {"file": file}
|
| 26 |
-
# Load a model
|
| 27 |
-
model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
return predictions
|
| 40 |
|
| 41 |
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def predict_yolo(image_path):
|
| 23 |
+
# Load a model
|
| 24 |
+
model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
# Run batched inference on a list of images
|
| 27 |
+
results = model(image_path) # return a list of Results objects
|
| 28 |
|
| 29 |
+
# Process results list
|
| 30 |
+
for result in results:
|
| 31 |
+
boxes = result.boxes # Boxes object for bbox outputs
|
| 32 |
+
# masks = result.masks # Masks object for segmentation masks outputs
|
| 33 |
+
# keypoints = result.keypoints # Keypoints object for pose outputs
|
| 34 |
+
# probs = result.probs # Probs object for classification outputs
|
| 35 |
+
predictions = boxes.json()
|
| 36 |
return predictions
|
| 37 |
|
| 38 |
|