-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
18 lines (15 loc) · 751 Bytes
/
Copy pathpredict.py
File metadata and controls
18 lines (15 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from ultralytics import YOLO
# Load a model
model = YOLO("runs/detect/runs/TLENetv9-yolov5su/weights/best.pt") # pretrained YOLO26n model
# Run batched inference on a list of images
file=input("Image path: ")
results = model([file]) # return a list of Results objects
# Process results list
for result in results:
boxes = result.boxes # Boxes object for bounding box outputs
masks = result.masks # Masks object for segmentation masks outputs
keypoints = result.keypoints # Keypoints object for pose outputs
probs = result.probs # Probs object for classification outputs
obb = result.obb # Oriented boxes object for OBB outputs
result.show() # display to screen
result.save(filename="result.jpg") # save to disk