snipplets.dev/projects/CV/ex.py

33 lines
613 B
Python

from ultralytics import YOLO
model = YOLO('yolov8s.pt')
model.save_dir = './predict/'
result = model.predict(
'./Assets/cat_dog.jpg',
save=True,
project='test',
name='ololo',
device=0,
show=False,
classes=[16, 15],
)[0]
# result = model(
# './Assets/cat_dog.jpg',
# save=True,
# project='test',
# name='ololo',
# device='gpu',
# show=False,
# )[0]
print(model.names)
# print(len(result.boxes))
# for _ in result.boxes:
# box = result.boxes[_]
# print("Object type:", box.cls)
# print("Coordinates:", box.xyxy)
# print("Probability:", box.conf)