Code Monkey home page Code Monkey logo

yolo_deepsort's Introduction

yolo_deepsort

MOT base on yolo3/yolo4+deepsort, different from the official use of numpy to implement sort, the sort here reimplemented with pytorch, so it running at GPU.

Mainly dependent

pytorch >= 1.3
torchvision >= 0.4.0
opencv-python >= 4.1

Quick start

  1. Clone the repositorty
git clone https://github.com/GlassyWing/yolo_deepsort
  1. Download weights of yolo3 or yolo4
cd weights/
wget https://pjreddie.com/media/files/yolov3.weights
wget https://pjreddie.com/media/files/yolov3-tiny.weights
wget https://drive.google.com/file/d/1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT/view
  1. Download weights of DeepSort
# download ckpt.t7 from
https://drive.google.com/drive/folders/1xhG0kRH1EX5B9_Iz8gQJb7UNnn_riXi6 to this folder
  1. Run example
python video_deepsort.py

If you do not want to run the tracker, set the parameter tracker to None:

video_detector = VideoDetector(...
                               tracker=None)

Replacing Re-ID

Please read the tutorial.

Example

Training

This library does not contain a feasible training program, please refer to the training:

yolo

deepsort

References

https://github.com/eriklindernoren/PyTorch-YOLOv3

https://github.com/ZQPei/deep_sort_pytorch

yolo_deepsort's People

Contributors

glassywing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yolo_deepsort's Issues

请问我想用Ground Truth单独测试追踪的评价指标应该怎么做

请问大佬,我想用Ground Truth单独测试追踪的评价指标应该怎么做,就是我想用groundtruth作为追踪输入,得到追踪的结果,不用yolo跑出来的检测结果作为追踪的输入,该怎么做?我的ground truth是下面的格式
1,0,824,771,127,129,1,4,0,0
2,0,828,761,124,123,1,4,0,0
3,0,833,752,120,116,1,4,0,0
4,0,834,741,119,117,1,4,0,0
5,0,836,731,117,117,1,4,0,0
6,0,840,720,114,113,1,4,0,0
7,0,844,710,111,108,1,4,0,0
8,0,848,700,109,104,1,4,0,0
9,0,850,692,107,102,1,4,0,0
10,0,852,685,105,100,1,4,0,0
11,0,855,678,102,98,1,4,0,0
12,0,857,671,100,95,1,4,0,0
13,0,859,664,98,93,1,4,0,0
14,0,862,656,95,92,1,4,0,0
15,0,864,649,93,90,1,4,0,0
16,0,866,642,91,87,1,4,0,0
17,0,869,635,88,85,1,4,0,0
18,0,871,628,86,83,1,4,0,0
19,0,874,621,84,81,1,4,0,0
20,0,875,615,83,79,1,4,0,0
21,0,877,610,81,77,1,4,0,0
22,0,878,604,80,76,1,4,0,0
23,0,880,599,79,74,1,4,0,0

RuntimeError: shape '[1024, 512, 3, 3]' is invalid for input of size 2552319

when I run the video_deepsort , an error is thrown :
File "C:/Users/16950/Desktop/yolo_deepsort-master/yolo_deepsort-master/video_deepsort.py", line 14, in
model.load_darknet_weights("weights/yolov3.weights")
File "C:\Users\16950\Desktop\yolo_deepsort-master\yolo_deepsort-master\yolo3\models\models.py", line 364, in load_darknet_weights
conv_w = torch.from_numpy(weights[ptr: ptr + num_w]).view_as(conv_layer.weight)
RuntimeError: shape '[1024, 512, 3, 3]' is invalid for input of size 2552319

I don't quite understand. Could you direct me?Thank you !

Tracking more than 80 classes?

Hi @GlassyWing ,

i've managed to use your git project (working fine, nice work! :-) ) but I've got the problem that only ClassID 0 is tracked (I've got 142 trained classes).

I'm using my custom yolov4 weights file and the corresponding config.

Problem a.)
When i set classes=142 in my cfg, it throws an error:
File "/usr/local/src/yolo_deepsort/yolo3/models/models.py", line 199, in forward
prediction = x.view(num_samples, self.num_anchors, self.num_classes + 5, *grid_size).permute(0, 1, 3, 4, 2)
RuntimeError: shape '[1, 3, 147, 108, 108]' is invalid for input of size 2974320

Problem b is solved, so please ignore b) :-)

Can you give me some input how i can achieve that with your code or am i blind somewhere?

Thanks & Cheers! :-)

Problem b.) - [ Solved ] -> I had to reduce '...nms_thres=0.4....' down to '...nms_thres=0.1....' "

So when i use classes=80 from the coco default cfg its working fine. But my main problem is, that i want track all my classes not only classID 0. I've already set class_mask in video_deepsort.py but still no success (same problem also when i use the default yolov4.weights and the config for the coco dataset):

video_detector = VideoDetector(model,
....
class_mask=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 5 6, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142]
....

How to define the path to the input video?

Hi! Thank you for your work. I ran this repo before on google colab to track objects on a random video and it worked perfectly fine. However, I am failing to locate the tracker to the input video file right now. I'm not sure if I am doing anything wrong. I get the following error when I run video_deepsort.py:

image

image

Can you please help me out here?

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

When I run a test with a webcam or file, an error is thrown:
Traceback (most recent call last): File "video_deepsort.py", line 47, in <module> for image, detections, _ in video_detector.detect("rtsp://admin:[email protected]/ISAPI/Streaming/Channels/101", File "A:\ml\yolo_deepsort\yolo3\detect\video_detect.py", line 135, in detect detections = self.image_detector.detect(frame) File "A:\ml\yolo_deepsort\yolo3\detect\img_detect.py", line 86, in detect detections = self.model(image) File "C:\Users\pcdreams\miniconda3\envs\yolo_deepsort\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "A:\ml\yolo_deepsort\yolo3\models\models.py", line 308, in forward x, layer_loss = module[0](x, targets, img_dim) File "C:\Users\pcdreams\miniconda3\envs\yolo_deepsort\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "A:\ml\yolo_deepsort\yolo3\models\models.py", line 217, in forward pred_conf.view((num_samples, -1, 1)), RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

whats a problem with view?

pytorch - 1.7.0
torchvision - 0.8.1
opencv-python - 4.4.0.46

How to save the output video?

Hi! I am running the repo on google colab. I have successfully able to use the code and run the tracking on my video but the output video is not saving even though I have specified the path.
image

According to the path, the output video is supposed to be stored at "data/" but after finishing the tracking the does not get saved. Can you please tell me how can I save the output prediction?

Thank you!

显示问题

你好,我在用您代码的时候检测不到是怎么回事?检测框不显示直接,希望您看到后回复我一下,谢谢

运行video_deepsort.py错误RuntimeError: "unfolded2d_copy" not implemented for 'Half'

您好,我尝试yolov3-tiny,yolov4,yolov4-tiny都出现同样的问题,请问能否指点下,错误具体如下:
Traceback (most recent call last):
File "video_deepsort.py", line 50, in
skip_secs=0):
File "/root/yolo_deepsort/yolo3/detect/video_detect.py", line 141, in detect
detections = self.image_detector.detect(frame)
File "/root/yolo_deepsort/yolo3/detect/img_detect.py", line 85, in detect
detections = self.model(image)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/root/yolo_deepsort/yolo3/models/models.py", line 299, in forward
x = module(x)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/container.py", line 100, in forward
input = module(input)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 349, in forward
return self._conv_forward(input, self.weight)
File "/root/anaconda3/envs/python377/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 346, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: "unfolded2d_copy" not implemented for 'Half'
terminate called without an active exception
Aborted (core dumped)

替换Reid模型

你好,请教下大佬,我想改进deepsort中reid模型,原论文是在market1501上训练的模型,对人的重识别效果好,对车的可能不好,所以我想在车的数据上训练出个模型,请问reid部分你和原论文做了哪些改动,还是保持没变,我该怎么训练?

运行test.py

请问运行test.py时出现了FileNotFoundError: [Errno 2] No such file or directory: 'data/coco/5k.txt'这样的错误是什么原因呢?

显示

请问实时显示的视频中类别和编号都不清晰,有改进的空间吗?

cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Hi I have been trying to run the repo in google colab with gpu. When I execute "video_deepsort.py" I get the following error:

2020-07-24 06:02:19,815 - INFO - Reading config...
2020-07-24 06:02:20,276 - INFO - Reading config done
Loading weights from weights/ckpt.t7... Done!
2020-07-24 06:02:24,310 - INFO - Detect video: data/test.mp4
2020-07-24 06:02:24,355 - INFO - Output Type: ../data/output.mp4, 828601953, 30, (1920, 1080)
2020-07-24 06:02:24,533 - INFO - Inference time: 0:00:00.072129
2020-07-24 06:02:24,616 - INFO - Inference time: 0:00:00.046835
2020-07-24 06:02:24,697 - INFO - Inference time: 0:00:00.041138
2020-07-24 06:02:24,762 - INFO - Inference time: 0:00:00.032771
2020-07-24 06:02:24,864 - INFO - Inference time: 0:00:00.057584
2020-07-24 06:02:24,939 - INFO - Inference time: 0:00:00.037254
2020-07-24 06:02:24,998 - INFO - Inference time: 0:00:00.030447
2020-07-24 06:02:25,090 - INFO - Inference time: 0:00:00.057867
2020-07-24 06:02:25,161 - INFO - Inference time: 0:00:00.046764
2020-07-24 06:02:25,231 - INFO - Inference time: 0:00:00.032764
2020-07-24 06:02:25,283 - INFO - Inference time: 0:00:00.029539
2020-07-24 06:02:25,370 - INFO - Inference time: 0:00:00.061455
FPS: 23
2020-07-24 06:02:25,468 - INFO - Inference time: 0:00:00.050386
2020-07-24 06:02:25,580 - INFO - Inference time: 0:00:00.055735
2020-07-24 06:02:25,647 - INFO - Inference time: 0:00:00.038648
2020-07-24 06:02:25,708 - INFO - Inference time: 0:00:00.030106
2020-07-24 06:02:25,763 - INFO - Inference time: 0:00:00.030028
2020-07-24 06:02:25,840 - INFO - Inference time: 0:00:00.049671
2020-07-24 06:02:25,898 - INFO - Inference time: 0:00:00.030984
2020-07-24 06:02:25,965 - INFO - Inference time: 0:00:00.037194
2020-07-24 06:02:26,085 - INFO - Inference time: 0:00:00.046189
2020-07-24 06:02:26,170 - INFO - Inference time: 0:00:00.048173
2020-07-24 06:02:26,237 - INFO - Inference time: 0:00:00.031856
2020-07-24 06:02:26,296 - INFO - Inference time: 0:00:00.030107
2020-07-24 06:02:26,383 - INFO - Inference time: 0:00:00.063005
FPS: 26
2020-07-24 06:02:26,465 - INFO - Inference time: 0:00:00.042469
2020-07-24 06:02:26,521 - INFO - Inference time: 0:00:00.029568
2020-07-24 06:02:26,578 - INFO - Inference time: 0:00:00.030526
2020-07-24 06:02:26,638 - INFO - Inference time: 0:00:00.030534
2020-07-24 06:02:26,703 - INFO - Inference time: 0:00:00.030067
2020-07-24 06:02:26,781 - INFO - Inference time: 0:00:00.049437
2020-07-24 06:02:26,877 - INFO - Inference time: 0:00:00.058676
2020-07-24 06:02:26,984 - INFO - Inference time: 0:00:00.037252
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/imutils/video/filevideostream.py", line 67, in update
frame = self.transform(frame)
File "/content/yolo_deepsort/yolo3/detect/video_detect.py", line 34, in _transform
return cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

2020-07-24 06:02:27,088 - INFO - Inference time: 0:00:00.036465
2020-07-24 06:02:27,138 - INFO - Inference time: 0:00:00.025053
2020-07-24 06:02:27,189 - INFO - Inference time: 0:00:00.024349
2020-07-24 06:02:27,238 - INFO - Inference time: 0:00:00.023730
2020-07-24 06:02:27,285 - INFO - Inference time: 0:00:00.024008
2020-07-24 06:02:27,332 - INFO - Inference time: 0:00:00.023859
2020-07-24 06:02:27,379 - INFO - Inference time: 0:00:00.023900
FPS: 30
2020-07-24 06:02:27,427 - INFO - Inference time: 0:00:00.023751
2020-07-24 06:02:27,476 - INFO - Inference time: 0:00:00.023747
2020-07-24 06:02:27,525 - INFO - Inference time: 0:00:00.024034
2020-07-24 06:02:27,578 - INFO - Inference time: 0:00:00.023974
2020-07-24 06:02:27,625 - INFO - Inference time: 0:00:00.023888
2020-07-24 06:02:27,675 - INFO - Inference time: 0:00:00.024328
2020-07-24 06:02:27,724 - INFO - Inference time: 0:00:00.023467
2020-07-24 06:02:27,773 - INFO - Inference time: 0:00:00.023828
2020-07-24 06:02:27,821 - INFO - Inference time: 0:00:00.023553
2020-07-24 06:02:27,876 - INFO - Inference time: 0:00:00.024036
2020-07-24 06:02:27,929 - INFO - Inference time: 0:00:00.023671
2020-07-24 06:02:27,986 - INFO - Inference time: 0:00:00.026806
2020-07-24 06:02:28,037 - INFO - Inference time: 0:00:00.023839
2020-07-24 06:02:28,092 - INFO - Inference time: 0:00:00.023777
2020-07-24 06:02:28,141 - INFO - Inference time: 0:00:00.024310
2020-07-24 06:02:28,190 - INFO - Inference time: 0:00:00.023869
2020-07-24 06:02:28,241 - INFO - Inference time: 0:00:00.024323
2020-07-24 06:02:28,293 - INFO - Inference time: 0:00:00.024464
2020-07-24 06:02:28,350 - INFO - Inference time: 0:00:00.026074
FPS: 38
2020-07-24 06:02:28,409 - INFO - Inference time: 0:00:00.027308
2020-07-24 06:02:28,465 - INFO - Inference time: 0:00:00.023894
2020-07-24 06:02:28,520 - INFO - Inference time: 0:00:00.023870
2020-07-24 06:02:28,579 - INFO - Inference time: 0:00:00.025258
2020-07-24 06:02:28,635 - INFO - Inference time: 0:00:00.023769
2020-07-24 06:02:28,689 - INFO - Inference time: 0:00:00.024628
2020-07-24 06:02:28,742 - INFO - Inference time: 0:00:00.024018
2020-07-24 06:02:28,795 - INFO - Inference time: 0:00:00.023710
2020-07-24 06:02:28,850 - INFO - Inference time: 0:00:00.024600
2020-07-24 06:02:28,905 - INFO - Inference time: 0:00:00.028612
2020-07-24 06:02:28,956 - INFO - Inference time: 0:00:00.023884
2020-07-24 06:02:29,009 - INFO - Inference time: 0:00:00.024233
2020-07-24 06:02:29,062 - INFO - Inference time: 0:00:00.023808
2020-07-24 06:02:29,117 - INFO - Inference time: 0:00:00.023849
2020-07-24 06:02:29,170 - INFO - Inference time: 0:00:00.023648
2020-07-24 06:02:29,224 - INFO - Inference time: 0:00:00.023403
2020-07-24 06:02:29,281 - INFO - Inference time: 0:00:00.024250
2020-07-24 06:02:29,338 - INFO - Inference time: 0:00:00.024134
FPS: 36
2020-07-24 06:02:29,392 - INFO - Inference time: 0:00:00.023779
2020-07-24 06:02:29,446 - INFO - Inference time: 0:00:00.023504
2020-07-24 06:02:29,501 - INFO - Inference time: 0:00:00.024275
2020-07-24 06:02:29,555 - INFO - Inference time: 0:00:00.023809
2020-07-24 06:02:29,608 - INFO - Inference time: 0:00:00.023458
2020-07-24 06:02:29,664 - INFO - Inference time: 0:00:00.024181
2020-07-24 06:02:29,720 - INFO - Inference time: 0:00:00.023965
2020-07-24 06:02:29,776 - INFO - Inference time: 0:00:00.025904
2020-07-24 06:02:29,836 - INFO - Inference time: 0:00:00.024041
2020-07-24 06:02:29,890 - INFO - Inference time: 0:00:00.023678
2020-07-24 06:02:29,952 - INFO - Inference time: 0:00:00.024716
2020-07-24 06:02:30,007 - INFO - Inference time: 0:00:00.024368
2020-07-24 06:02:30,062 - INFO - Inference time: 0:00:00.023714
2020-07-24 06:02:30,126 - INFO - Inference time: 0:00:00.023561


It looks like an opencv error to actually view the video while executing code. I am sure that colab won't allow to show the detection while running the code. I could be wrong but could you please suggest me something about this error?
Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.