snipplets.dev/projects/CV/ex.py

29 lines
543 B
Python
Raw Normal View History

2023-09-29 21:51:53 +03:00
from ultralytics import YOLO
model = YOLO('yolov8m.pt')
model.save_dir = './predict/'
result = model.predict(
'./Assets/cat_dog.jpg',
save=True,
device='cpu',
show=False,
classes=[16, 15],
)[0]
result = model(
'./Assets/cat_dog.jpg',
save=True,
project='test',
name='ololo',
device='cpu',
show=False,
)[0]
# print(len(result.boxes))
# for _ in result.boxes:
# box = result.boxes[_]
# print("Object type:", box.cls)
# print("Coordinates:", box.xyxy)
# print("Probability:", box.conf)