augmentedstartups / AS-One

Easy & Modular Computer Vision Detectors, Trackers & SAM - Run YOLOv9,v8,v7,v6,v5,R,X in under 10 lines of code.
https://www.augmentedstartups.com
GNU General Public License v3.0
608 stars 103 forks source link

How to use my training weights to your model? #5

Closed stphtan94117 closed 1 year ago

stphtan94117 commented 1 year ago

I train a model for pigs and other animals. (yolov5x) so how to use my weight pt file to this model? i want to track and counting function.

thanks

MNMaqsood commented 1 year ago

Currently there's no direct method to use custom weights. We'll add this support in next update

stphtan94117 commented 1 year ago

another question: is it possible to detect on RTSP? want to detect in real-time on cctv. thanks.

MNMaqsood commented 1 year ago

Not at the moment, we'll add these in next updates. The update allowing users to use custom weights will hopefully be over weekend. The RTSP and similar protocols will be dealt in next update

ghaith-khlifi commented 1 year ago

please add the custom weights option asap

MNMaqsood commented 1 year ago

This feature has been added in new updates. Here's how to add custom weights

import asone
from asone import utils
from asone import ASOne
import cv2

video_path = 'data/sample_videos/license_video.webm'
detector = ASOne(detector=asone.YOLOV7_PYTORCH, weights='data/custom_weights/yolov7_custom.pt', use_cuda=True) # Set use_cuda to False for cpu

class_names = ['license_plate'] # your custom classes list

cap = cv2.VideoCapture(video_path)

while True:
    _, frame = cap.read()
    if not _:
        break

    dets, img_info = detector.detect(frame)

    bbox_xyxy = dets[:, :4]
    scores = dets[:, 4]
    class_ids = dets[:, 5]

    frame = utils.draw_boxes(frame, bbox_xyxy, class_ids=class_ids, class_names=class_names) # simply pass custom classes list to write your classes on result video

    cv2.imshow('result', frame)

    if cv2.waitKey(25) & 0xFF == ord('q'):
        break