mikel-brostrom / boxmot

BoxMOT: pluggable SOTA tracking modules for segmentation, object detection and pose estimation models
GNU Affero General Public License v3.0
6.59k stars 1.7k forks source link

How to track with a modified yoloV8 detection model? #1415

Closed Gump1111 closed 4 months ago

Gump1111 commented 4 months ago

Search before asking

Question

Hi Author! Really thanks for your great job! I have a question there, if I modify the YOLOv8's structure ,for example ,I add the CBAM attention into YOLOv8, and got a model best.pt after trained it with my dataset. Since I have changed the yolov8.yaml, Could I directly set the argument "--yolo-model" as " best.pt" and execute track.py?

mikel-brostrom commented 4 months ago

Not sure, have not tried to run any such experiment 😄

TYPXT commented 4 months ago

I tried loading a model trained on another dataset, and at first the error told me that the model name needed to be chosen between YOLOv8, YOLO-NAS, and YOLOX, so I changed my best.pt file to "yolov8u.pt" and the algorithm worked, and it felt like it was lying to it saying: "This is yolov8.pt, go train". Maybe you could try something like this?

Gump1111 commented 4 months ago

Not sure, have not tried to run any such experiment 😄

All right, still thanks a lot!

Gump1111 commented 4 months ago

I tried loading a model trained on another dataset, and at first the error told me that the model name needed to be chosen between YOLOv8, YOLO-NAS, and YOLOX, so I changed my best.pt file to "yolov8u.pt" and the algorithm worked, and it felt like it was lying to it saying: "This is yolov8.pt, go train". Maybe you could try something like this?

Thank you very much, friend. Have you modified your detection model's structure like I said, adding some modules, I don't know whether it is compatible with a weight created from a modified model. But whatever, I'll try. Thanks

TYPXT commented 4 months ago

I tried loading a model trained on another dataset, and at first the error told me that the model name needed to be chosen between YOLOv8, YOLO-NAS, and YOLOX, so I changed my best.pt file to "yolov8u.pt" and the algorithm worked, and it felt like it was lying to it saying: "This is yolov8.pt, go train". Maybe you could try something like this?

Thank you very much, friend. Have you modified your detection model's structure like I said, adding some modules, I don't know whether it is compatible with a weight created from a modified model. But whatever, I'll try. Thanks

Not yet, but I may try it in the near future.😄I think it should work after synchronizing the modified model structure code to the files under ultralytics/nn/ used by yolo_track.

TYPXT commented 4 months ago

Oh, I'm very happy to tell you that I did it. Using the same method I used to build the model, which was to change the relevant files under ultralytics/nn/, I managed to get the model loaded, running properly and outputting track results. I replaced the entire YOLOv8 backbone with the Swin Transformer and implemented tracking, which proves that it is possible to use the modified detection model, but of course, I used the name "yolov8o.pt" to fool the algorithm when running the track.py file, just as I said before.

Gump1111 commented 4 months ago

Oh, I'm very happy to tell you that I did it. Using the same method I used to build the model, which was to change the relevant files under ultralytics/nn/, I managed to get the model loaded, running properly and outputting track results. I replaced the entire YOLOv8 backbone with the Swin Transformer and implemented tracking, which proves that it is possible to use the modified detection model, but of course, I used the name "yolov8o.pt" to fool the algorithm when running the track.py file, just as I said before.

What great news, congratulations, my friend! Did you modify the structure and train it on the official YOLOv8 github, then get "yolov8o.pt", and then directly assign the value "yolov8o.pt" in the author Mikel's track.py code? Because I found that Mikel's code file does not have the ultralytics folder. Thank you again and I hope your research will be successful!

TYPXT commented 4 months ago

Oh, I'm very happy to tell you that I did it. Using the same method I used to build the model, which was to change the relevant files under ultralytics/nn/, I managed to get the model loaded, running properly and outputting track results. I replaced the entire YOLOv8 backbone with the Swin Transformer and implemented tracking, which proves that it is possible to use the modified detection model, but of course, I used the name "yolov8o.pt" to fool the algorithm when running the track.py file, just as I said before.

What great news, congratulations, my friend! Did you modify the structure and train it on the official YOLOv8 github, then get "yolov8o.pt", and then directly assign the value "yolov8o.pt" in the author Mikel's track.py code? Because I found that Mikel's code file does not have the ultralytics folder. Thank you again and I hope your research will be successful!

Yes! My detailed steps were like this: I created a virtual environment on a linux server, pulled the YOLOv8 source code from the official Github, and modified the files inside my virtual environment, the exact path of the file I modified is "anaconda/envs/track/Lib/site-packages/ultralytics/nn/", because inside the virtual environment The code under this path is called first, so the modifications under ultralytics/ultralytics/nn/ will not work. I then trained using the model with the modified structure, got the best.pt file and renamed it yolov8o.pt, and inside the track.py file modified "parser.add_argument('--yolo-model', type=Path, default= WEIGHTS / 'absolute path/to/yolov8o.pt',help='yolo model path')" in the track.py file and run track.py in the terminal, then it can run successfully.

Gump1111 commented 4 months ago

Oh, I'm very happy to tell you that I did it. Using the same method I used to build the model, which was to change the relevant files under ultralytics/nn/, I managed to get the model loaded, running properly and outputting track results. I replaced the entire YOLOv8 backbone with the Swin Transformer and implemented tracking, which proves that it is possible to use the modified detection model, but of course, I used the name "yolov8o.pt" to fool the algorithm when running the track.py file, just as I said before.

What great news, congratulations, my friend! Did you modify the structure and train it on the official YOLOv8 github, then get "yolov8o.pt", and then directly assign the value "yolov8o.pt" in the author Mikel's track.py code? Because I found that Mikel's code file does not have the ultralytics folder. Thank you again and I hope your research will be successful!

Yes! My detailed steps were like this: I created a virtual environment on a linux server, pulled the YOLOv8 source code from the official Github, and modified the files inside my virtual environment, the exact path of the file I modified is "anaconda/envs/track/Lib/site-packages/ultralytics/nn/", because inside the virtual environment The code under this path is called first, so the modifications under ultralytics/ultralytics/nn/ will not work. I then trained using the model with the modified structure, got the best.pt file and renamed it yolov8o.pt, and inside the track.py file modified "parser.add_argument('--yolo-model', type=Path, default= WEIGHTS / 'absolute path/to/yolov8o.pt',help='yolo model path')" in the track.py file and run track.py in the terminal, then it can run successfully.

Friend, you are awesome! I will follow in your footsteps and continue my work. Wish you all the best!

TYPXT commented 4 months ago

Oh, I'm very happy to tell you that I did it. Using the same method I used to build the model, which was to change the relevant files under ultralytics/nn/, I managed to get the model loaded, running properly and outputting track results. I replaced the entire YOLOv8 backbone with the Swin Transformer and implemented tracking, which proves that it is possible to use the modified detection model, but of course, I used the name "yolov8o.pt" to fool the algorithm when running the track.py file, just as I said before.

What great news, congratulations, my friend! Did you modify the structure and train it on the official YOLOv8 github, then get "yolov8o.pt", and then directly assign the value "yolov8o.pt" in the author Mikel's track.py code? Because I found that Mikel's code file does not have the ultralytics folder. Thank you again and I hope your research will be successful!

Yes! My detailed steps were like this: I created a virtual environment on a linux server, pulled the YOLOv8 source code from the official Github, and modified the files inside my virtual environment, the exact path of the file I modified is "anaconda/envs/track/Lib/site-packages/ultralytics/nn/", because inside the virtual environment The code under this path is called first, so the modifications under ultralytics/ultralytics/nn/ will not work. I then trained using the model with the modified structure, got the best.pt file and renamed it yolov8o.pt, and inside the track.py file modified "parser.add_argument('--yolo-model', type=Path, default= WEIGHTS / 'absolute path/to/yolov8o.pt',help='yolo model path')" in the track.py file and run track.py in the terminal, then it can run successfully.

Friend, you are awesome! I will follow in your footsteps and continue my work. Wish you all the best!

I'm glad I could help you and wish you success, my friend!😄

github-actions[bot] commented 4 months ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!