ZQPei / deep_sort_pytorch

MOT using deepsort and yolov3 with pytorch
MIT License
2.79k stars 722 forks source link

how can I use my own yolov3 weights? #206

Open Y-Mona opened 3 years ago

Y-Mona commented 3 years ago

I can use tracking by my .t7 . In the same time,I also want to use my own weights which is trained with yolov3-spp.cfg and pytorch.I have tried to using the convert() in the model.py to convert .pt to .weight,which was sucessful, but I can't detect anything when I change the detector.py ,the yolov3.yaml and the yolov3_deepsort.py. what should I do?

Y-Mona commented 3 years ago

the modification in the code is just to change the path of cfg,weights and the names

abdulkafiyahya commented 3 years ago

@Y-Mona how did u convert in the model ?? can u help me please

Y-Mona commented 3 years ago

@ Y-Mona您是 如何在模型中转换的?你能帮我吗

`from models import * model=Darknet("cfg/yolov3-spp.cfg")

your dir of cfg

checkpoint = torch.load("weights/last.pt",map_location='cpu') model.load_state_dict(checkpoint['model']) save_weights(model,path='weights/last.weights',cutoff=-1) ` you can use this code, which comes from the model.py in project yolov3

Y-Mona commented 3 years ago

@ Y-Mona您是 如何在模型中转换的?你能帮我吗

just make a new .py,and put it in yolo

abdulkafiyahya commented 3 years ago

@Y-Mona thank u for ur replay. i did what u say. i maked new.py and i puted it in detector->YOLOv3 folder, but i get "No module named 'models' " ? did i do somthings wrong??

Y-Mona commented 3 years ago

Sorry,I forget it.I used this code in YOLOv3 detection project .the repo:https://github.com/ultralytics/yolov3/tree/archive you can put the code with models.py,and execute it,or try to download the models.py in this project . Because the function I used in the conversion just comes from models.py

abdulkafiyahya commented 3 years ago

hi @Y-Mona ,i did it but i get this error No module named 'models.yolo'; 'models' is not a package any help please

Y-Mona commented 3 years ago

Forgive me for being hasty . you can try to clone the repo of yolov3,then do it in the project .

abdulkafiyahya commented 3 years ago

@Y-Mona the last qustion please. how do making your own .t7 . i am working on Traking Model with may own dataset, do u have project for this ???

oomq commented 3 years ago

我试过yolo3-spp.cfg也是遇到一样的问题,但用yolov3.cfg训练就可以检测到目标了

Y-Mona commented 3 years ago

我试过yolo3-spp.cfg也是遇到一样的问题,但用yolov3.cfg训练就可以检测到目标了

ok我试一下,非非常感谢!

Y-Mona commented 3 years ago

@Y-Mona the last qustion please. how do making your own .t7 . i am working on Traking Model with may own dataset, do u have project for this ??? Sorry, I have been working on my graduation thesis.

  1. download original_ckpt.t7
  2. if you want to track people, use Mars or Market 1501 datasets.else you need Re_ID datastes,such as VeRI which is a car datasets.
  3. then write the code to make your file structure of Re_ID struture the same as Market1501
  4. then python train.py

I will upload my project soon.

Y-Mona commented 3 years ago

@ Y-Mona请问最后一个问题。如何制作自己的.t7。我正在使用可能具有自己的数据集的Traking模型进行工作,您是否有针对此的项目???

my repo https://github.com/Y-Mona/DeepSORT_Pytorch_VeRi

Y-Mona commented 3 years ago

After the test,I got the correct tracking result!I only need to use yolov3.cfg to train the weight of yolo.convert .pt to .weight, then replace the file in detector and modify little settings of parameters

mozeqiu commented 3 years ago

经过测试,我得到了正确的跟踪结果!我只需要使用yolov3.cfg将yolo.convert .pt的权重训练为.weight,然后替换检测器中的文件并修改一些参数设置

What parameters have you changed? I want to use this tracking model and my own yolov3.weights for target detection

mozeqiu commented 3 years ago

经过测试,我得到了正确的跟踪结果!我只需要使用yolov3.cfg将yolo.convert .pt的权重训练为.weight,然后替换检测器中的文件并修改一些参数设置

What parameters have you changed? I want to use this tracking model and my own yolov3.weights for target detection

yuanqiyin commented 3 years ago

麻烦问一下您的YOLO v3权重是自己修改后又训练的么?我想用pth文件进行检测,您可以给出一些建议么?

Y-Mona commented 3 years ago

麻烦问一下您的YOLO v3权重是自己修改后又训练的么?我想用pth文件进行检测,您可以给出一些建议么?

你换一个模型,用yolov3.cfg 生成的权重转成.pt就行了

yuanqiyin commented 3 years ago

麻烦问一下您的YOLO v3权重是自己修改后又训练的么?我想用pth文件进行检测,您可以给出一些建议么?

你换一个模型,用yolov3.cfg 生成的权重转成.pt就行了

那大概步骤是不是这样 1.用自己的pytorch版本的yolov3训练,然后得到yolov3.pt文件; 2.利用自己训练的cfg文件进行转化,得到yolov3.weights文件; 3.替换deepsort中所有用到检测权重的地方,例如yolov3.yaml和deepsort.yaml文件; 4.替换检测模型为自己训练时的检测模型,进行跟踪。 请您指导一下,上述可能有不对的地方,我做了前三项工作,第四项正在做,烦请您看到回复一下,谢谢您。

Y-Mona commented 3 years ago

麻烦问一下您的YOLO v3权重是自己修改后又训练的么?我想用pth文件进行检测,您可以给出一些建议么?

你换一个模型,用yolov3.cfg 生成的权重转成.pt就行了

那大概步骤是不是这样 1.用自己的pytorch版本的yolov3训练,然后得到yolov3.pt文件; 2.利用自己训练的cfg文件进行转化,得到yolov3.weights文件; 3.替换deepsort中所有用到检测权重的地方,例如yolov3.yaml和deepsort.yaml文件; 4.替换检测模型为自己训练时的检测模型,进行跟踪。 请您指导一下,上述可能有不对的地方,我做了前三项工作,第四项正在做,烦请您看到回复一下,谢谢您。

还需要根据你的网络配置更改跟踪文件中的mask,以确定跟踪目标类型。 检测部分中的cfg也要改成你检测模型使用的那个,应该还有names文件之类的。就是目标检测自定义目标修改的文件