vision-ai-test/main.py
2024-12-14 04:10:29 +00:00

20 lines
770 B
Python

from ultralytics import YOLO
# Load a pretrained YOLO11n model
model = YOLO("yolo11m-2_uniform.onnx")
model_pose = YOLO("yolo11s-pose.pt")
# Define path to video file
source = "PF-071124-2.mp4"
# Run inference on the source
results = model(source, stream=True) # generator of Results objects
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