YOLOX_deepsort_tracker
yolox+deepsort实现目标跟踪
最新的yolox尝尝鲜~~(yolox正处在频繁更新阶段,因此直接链接yolox仓库作为子模块)
🎉 How to use Detector and Tracker
↳ Detect example
from detector import Detector
detector = Detector(model='yolox-s', ckpt='yolo_s.pth') # instantiate Detector
img = cv2.imread('dog.jpg') # load image
result = detector.detect(img) # detect targets
img_visual = result['visual'] # visualized image
cv2.imshow('detect', img_visual) # imshow
Detector uses yolo-x family models to detect targets.
You can also get more information like raw_img/boudingbox/score/class_id from the result of detector.
↳ Track example
from tracker import Tracker
tracker = Tracker(model='yolox-s', ckpt='yolo_s.pth') # instantiate Tracker
cap = cv2.VideoCapture('test.mp4') # load video
while True:
_, frame = cap.read() # get new frame
if frame is None:
break
result = tracker.update(frame) # detect and track targets
cv2.imshow('demo', result['visual']) # imshow visualized frame
cv2.waitKey(1)
Tracker uses detector to get each frame's boundingbox, and use deepsort to get every bbox's ID.
🎨 Install
-
Clone the repository recursively:
git clone --recurse-submodules https://github.com/pmj110119/YOLOX_deepsort_tracker.git
If you already cloned and forgot to use
--recurse-submodules
you can rungit submodule update --init
(clone最新的YOLOX仓库) -
Make sure that you fulfill all the requirements: Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install, run:
pip install -r requirements.txt
⚡ Select a YOLOX family model
-
train your own model or just download pretrained models from https://github.com/Megvii-BaseDetection/YOLOX
-
select the model and checkpoint when using Detector and Tracker
for example:
""" YOLO family: yolox-s, yolox-m, yolox-l, yolox-x, yolox-tiny, yolox-nano, yolov3 """ # yolox-s example detector = Detector(model='yolox-s', ckpt='./yolo_s.pth') # yolox-m example detector = Detector(model='yolox-m', ckpt='./yolo_m.pth')
👏 Run demo
-
Detect on image
python .\demo.py --mode=detect --file=dog.jpg
-
Track on video
python .\demo.py --mode=track --file=test.mp4
Filter tracked classes
coming soon...
Train your own model
coming soon...