ZQPei / deep_sort_pytorch

MOT using deepsort and yolov3 with pytorch
MIT License
2.83k stars 727 forks source link

How can I use this in another class? #58

Closed sub2sub2 closed 4 years ago

sub2sub2 commented 5 years ago

Hello! I am thankful to you for sharing this. I'm working on a project to find people and balls in the video. I succeeded in training two classes in yolov3 with my own data, and now I am trying to track that objects. I have revised the Darknet in your file but I am having a hard time using Deepsort. How can i track on my own data like ball and person?? Should i train deepsort weights file like Yolov3? If I have to do that, how can train my data on deepsort weights file? Or there is another way to track my own data?

crazylazydboy commented 5 years ago

Hi, @sub2sub2 Were you able to run this on your own video ? Can you tell me what did you change on the code ?

summerwbb commented 5 years ago

Hello, have you successfully implemented the tracking in your own category? What should I do?

masouduut94 commented 4 years ago

Hello Can you tell us the steps you followed for training and also modification to do your job? @sub2sub2 @ZQPei

HYH817 commented 4 years ago

hello! I want to run my own video by using your code , and the code is running successfully ,but the results show us the number of target of the detector and tracker is 0 always, please, Could you tell me the reason .my best wish to you!!!@sub2sub2

ZQPei commented 4 years ago

@HYH817 What kind of objects do you want to detect?

HYH817 commented 4 years ago

@ZQPei First of all,thank you for your reply in the middle of night,I am currently working as the research of the direction of automatic driving object tracking,I want to detect car​ and ped​est​rian,eventually achieve to track these objects of detections.the code is sucessfully runing,at present,but the fps is about 10,why?Could you tell me how to improve the fps?  Thanks again​

------------------ 原始邮件 ------------------ 发件人: "pzq"<notifications@github.com>; 发送时间: 2020年4月17日(星期五) 晚上11:37 收件人: "ZQPei/deep_sort_pytorch"<deep_sort_pytorch@noreply.github.com>; 抄送: "huangyuhang "<1018685704@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [ZQPei/deep_sort_pytorch] How can I use this in another class? (#58)

@HYH817 What kind of objects do you want to detect?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ZQPei commented 4 years ago

@HYH817

  1. Adopt light weight detection model.
  2. Model pruning.
  3. Quantization. Use fp16 or int8 instead of fp32.
  4. Heterogeneous computing to accerate.
HYH817 commented 4 years ago

1、Did you have any recommendations for lightweight detection models?2、How to prun model?  Adjust weight?Yolov3 should be faster and accurate than other model 3、Does your code use fp32 at present? 4、I run the code in the GPU (Nvidia 1080Ti)

Looking forward to your valuable suggestions!!!thanks  ------------------ 原始邮件 ------------------ 发件人: "pzq"<notifications@github.com>; 发送时间: 2020年4月18日(星期六) 凌晨0:18 收件人: "ZQPei/deep_sort_pytorch"<deep_sort_pytorch@noreply.github.com>; 抄送: "huangyuhang "<1018685704@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [ZQPei/deep_sort_pytorch] How can I use this in another class? (#58)

@HYH817

Adopt light weight detection model.

Model pruning.

Quantization. Use fp16 or int8 instead of fp32.

Heterogeneous computing to accerate.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

pauli-lab commented 4 years ago

@HYH817 could you tell me how to detect one class? I have trained my weight,change my cfg ,names and data ,but when I run it,the results show us the number of target of the detector and tracker is 0 ,too.I think it's the same question as yours, so could you tell me how to figure it out? thanks!!!!

duyao-art commented 4 years ago

@ZQPei Hello! Thank you for your sharing. It is a wonderful work. I have a problem now and I hope you could give me some advice. The code can run but the detection number and the tracking number is always zero. I am very confused and I hope you could give me some advice for possible reasons. the below is the modification of your codes based on my project:

  1. I have totally six classes for my yolo classification task. so I change the relevant mask parameter below to 6 in the yolov3_deepsort.py file.

    do detection

        bbox_xywh, cls_conf, cls_ids = self.detector(im)
        # select person class    
        mask = cls_ids < 6
  2. Also, when running the yolov3_deepsort.py code in the prompt, I have changed the parser of --config_detection, --config_deepsort and the relevant config files as below, based on my pre-trained yolov3 model.

YOLOV3: CFG: "./detector/YOLOv3/cfg/yolov3-spp.cfg" WEIGHT: "./detector/YOLOv3/weight/best.pt" CLASS_NAMES: "./detector/YOLOv3/cfg/obj.names"

CFG: "./detector/YOLOv3/cfg/yolo_v3.cfg"

WEIGHT: "./detector/YOLOv3/weight/yolov3.weights"

CLASS_NAMES: "./detector/YOLOv3/cfg/coco.names"

DEEPSORT: REID_CKPT: "./deep_sort/deep/checkpoint/ckpt.t7"

Prompt comond (deep_sort_pytorch_gpu) duyao@duyao-desktop:~/PycharmProjects/deep_sort_pytorch$ python yolov3_deepsort.py vehicle.mp4 /home/duyao/PycharmProjects/deep_sort_pytorch/utils/parser.py:23: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. self.update(yaml.load(fo.read())) 2020-05-29 11:45:19 [INFO]: Loading weights from ./detector/YOLOv3/weight/best.pt... Done! 2020-05-29 11:45:21 [INFO]: Loading weights from ./deep_sort/deep/checkpoint/ckpt.t7... Done! 2020-05-29 11:45:22 [INFO]: Save results to ./output/ 2020-05-29 11:45:23 [INFO]: time: 1.663s, fps: 0.601, detection numbers: 0, tracking numbers: 0

The detection and tracking number is zero for all frames.

However, when I tried to run detection module on ultralytics / yolov3 project (because I just trained my custom yolov3 weight on this project. the detection is well, all six classes of vehicles can be detected.

So I think it is still the problem of parameter passing. I want to know if I need to change or modify the specific parameters in your project if I want to use your project to detect and track six classes of vehicles.

I would be very very appreciated if you could reply to me at your convenient time. I have been struggled with this issue several days. it is horrible...

masouduut94 commented 4 years ago

@duyao-art do you want to track different types of objects? for example like pedestrians, vehicles, cars and etc?

duyao-art commented 4 years ago

@masouduut94 Yes,that is exactly what I want to do but I am confused about the problem above. Do you have any suggestions or ideas?

duyao-art commented 4 years ago

@summerwbb Hello, have you solved the tracking issue based on your own data and class? I also want to track my own selected classes and objects, the code can run, but the detection and tracking number is always zero. If you have succeeded, could you please give me some advice?

duyao-art commented 4 years ago

@HYH817 Hello, I have the same problem, very strange. Have you solved the tracking issue based on your own data and class? I also want to track my own selected classes and objects, the code can run, but the detection and tracking number is always zero. If you have succeeded, could you please give me some advice?

2020-06-01 09:36:13 [INFO]: time: 0.029s, fps: 34.739, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 35.788, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 35.350, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.029s, fps: 34.923, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 35.379, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 36.063, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 36.312, detection numbers: 0, tracking numbers: 0 2020-06-01 09:36:13 [INFO]: time: 0.028s, fps: 35.966, detection numbers: 0, tracking numbers: 0

many many thanks

duyao-art commented 4 years ago

@pauli-lab Have you solved your problem? I have been struggled with this for a week now....

pauli-lab commented 4 years ago

make sure the class number is right. The original code is for detecting person ,but if you want to detect other things ,you should change your class number. Or could you please show me more details about your project?

pauli-lab commented 4 years ago

In yolov3_deepsort.py, search" mask = cls_ids==0", change the number to what you want . but if you want to track different types of objects , maybe you need a list or something else to do this

duyao-art commented 4 years ago

@pauli-lab Thank you so much for your reply. Yes, I want to detect vehicles. And I have revised the relevant code as you mentioned.

select person class

        # revise for tracking six classes: car, van, light bus, bus, light truck, truck 

        mask = cls_ids < 6

So do you mean that I need to create a mask list ? not just only one mask variable. I am not sure it will work. because I have tried, I changed the 'mask = cls_ids==0 'before. Theoretically, it should detect and track the car ( my car class number is zero), but the detection and tracking number is still zero.

(deep_sort_pytorch_gpu) duyao@duyao-desktop:~/PycharmProjects/deep_sort_pytorch$ python yolov3_deepsort.py vehicle.mp4 --display /home/duyao/PycharmProjects/deep_sort_pytorch/utils/parser.py:23: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. self.update(yaml.load(fo.read())) 2020-06-01 10:44:57 [INFO]: Loading weights from ./detector/YOLOv3/weight/best.pt... Done! 2020-06-01 10:44:58 [INFO]: Loading weights from ./deep_sort/deep/checkpoint/ckpt.t7... Done! 2020-06-01 10:44:58 [INFO]: Save results to ./output/ 2020-06-01 10:44:58 [INFO]: time: 0.146s, fps: 6.855, detection numbers: 0, tracking numbers: 0 2020-06-01 10:44:58 [INFO]: time: 0.037s, fps: 27.395, detection numbers: 0, tracking numbers: 0 2020-06-01 10:44:58 [INFO]: time: 0.034s, fps: 29.077, detection numbers: 0, tracking numbers: 0 2020-06-01 10:44:58 [INFO]: time: 0.033s, fps: 30.192, detection numbers: 0, tracking numbers: 0 2020-06-01 10:44:58 [INFO]: time: 0.028s, fps: 36.346, detection numbers: 0, tracking numbers: 0

The above is the running result which was just created before I made this reply. Thank you very much for this discussion.

masouduut94 commented 4 years ago

@duyao-art I think you need something like this for vehicle tracking.

https://github.com/wsh122333/Multi-type_vehicles_flow_statistics

Take a look at readme file. It is said that for tracking pedestrian, you need to train your model on specific re-identification purpose dataset.

You have to do the same to train the feature extractor on the re-identification dataset for vehicles.

duyao-art commented 4 years ago

Yes, I think I really need to retrain the re-identification model for better tracking of vehicles. Thank you so much for your kind reply and your shared link! Thank you~

Masoud Masoumi Moghadam notifications@github.com 于2020年6月2日周二 下午2:38写道:

@duyao-art https://github.com/duyao-art I think you need something like this for vehicle tracking.

https://github.com/wsh122333/Multi-type_vehicles_flow_statistics

Take a look at readme file. It is said that for tracking pedestrian, you need to train your model on specific re-identification purpose dataset.

You have to do the same to train the feature extractor on the re-identification dataset for vehicles.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ZQPei/deep_sort_pytorch/issues/58#issuecomment-637311076, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANNRQ4ZRQXREKQHEGEMTEGTRUSM7ZANCNFSM4I53UGPQ .