augmentedstartups / AS-One

Easy & Modular Computer Vision Detectors, Trackers & SAM - Run YOLOv9,v8,v7,v6,v5,R,X in under 10 lines of code.

Home Page:https://www.augmentedstartups.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closing Tracking and See Class Names?

4lparslan opened this issue · comments

Hi thanks for great repository. I want to use only detection, not tracking. And also want to see class names. Help please

@4lparslan You can use the code given here in README.md file to test detector only and can get the names using IDs of detector. So complete code is given below:

import cv2
import asone

from asone.utils import get_names
from asone.detectors import Detector

img = cv2.imread('data/sample_imgs/test2.jpg')
detector = Detector(asone.YOLOV7_E6_ONNX, use_cuda=True) # Set use_cuda to False for cpu

filter_classes = ['person'] # Set to None to detect all classes

dets, img_info = detector.detect(img,  filter_classes=filter_classes)

bbox_xyxy = dets[:, :4]
scores = dets[:, 4]
class_ids = dets[:, 5].astype(int)

names = get_names()
print([names[class_id] for class_id in class_ids])