Giter Club home page Giter Club logo

torchyolo's Introduction

TorchYolo: YOLO Series Object Detection and Track Algorithm Library

teaser
downloads pypi version HuggingFace Spaces

Introduction

The TorchYolo library aims to support YOLO models(like YOLOv5, YOLOv6, YOLOv7, YOLOv8) and Tracker Algorithm(Sort, StrongSort, ByteTrack, OcSort and Norfair) and provide a unified interface for training and inference. The library is based on PyTorch and is designed to be easy to use and extend.

Installation

pip install torchyolo

Use From Python

First download the default_config.yaml file.

Object Prediction
from torchyolo import YoloHub

model = YoloHub(
    config_path=config_path,
    model_type=model_type,
    model_path=model_path,
)

result = model.predict(source=source)
Object Tracking
model = YoloHub(
    config_path=config_path,
    model_type=model_type,
    model_path=model_path,
)

if tracker_type == "STRONGSORT":
    result = model.tracker_predict(
        source=source,
        tracker_type=tracker_type,
        tracker_weight_path=tracker_weight_path,
        tracker_config_path=tracker_config_path,
    )
else:
    result = model.tracker_predict(
        source=source,
        tracker_type=tracker_type,
        tracker_config_path=tracker_config_path,
    )

Use From Command Line

torchyolo predict --config_path torchyolo/configs/default_config.yaml \
                  --model_type yolov5 \
                  --model_path yolov5s.pt --source test.mp4

torchyolo tracker --config_path torchyolo/configs/default_config.yaml \
                  --model_type yolov5 --model_path yolov5s.pt \
                  --tracker_config_path norfair.yaml

Detect Configuration

DETECTOR_CONFIG:
  # The threshold for the IOU score
  IOU_TH: 0.45
  # The threshold for the confidence score
  CONF_TH: 0.25
  # The size of the image
  IMAGE_SIZE: 640
  # The device to run the detector
  DEVICE: cuda:0
  # F16 precision
  HALF: False
  # The path of the yolov6 label file
  YOLOV6_YAML_FILE: torchyolo/configs/yolov6/coco.yaml
  # The path of the yolovx config file
  YOLOX_CONFIG_PATH: configs.yolox.yolox_s
  # The path of the Hugging Face model
  HUGGING_FACE_MODEL: False 

DATA_CONFIG:
  # The path of the output video
  OUTPUT_PATH: output.mp4
  # Save the video
  SHOW: False 
  # Show the video
  SAVE: True

Tracker Config File

ByteTrack: https://github.com/kadirnar/torchyolo/releases/download/v0.0.5/default_config.yaml

OcSort: https://github.com/kadirnar/torchyolo/releases/download/v0.0.5/oc_sort.yaml

StrongSort: https://github.com/kadirnar/torchyolo/releases/download/v0.0.5/strong_sort.yaml

Norfair: https://github.com/kadirnar/torchyolo/releases/download/v0.0.5/norfair_track.yaml

Sort: https://github.com/kadirnar/torchyolo/releases/download/v0.0.5/sort_track.yaml

Model Architecture

from torchyolo import YoloHub

model = YoloHub(config_path="torchyolo/default_config.yaml")
result = model.view_model(file_format="pdf")

Contributing

Before opening a PR:

  • Install required development packages:
    pip install -e ."[dev]"
  • Reformat the code with black and isort:
    bash script/code_format.sh

Acknowledgement

A part of the code is borrowed from SAHI. Many thanks for their wonderful works.

Citation

@article{wang2022yolov7,
  title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
  author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
  journal={arXiv preprint arXiv:2207.02696},
  year={2022}
}
@article{li2022yolov6,
  title={YOLOv6: A single-stage object detection framework for industrial applications},
  author={Li, Chuyi and Li, Lulu and Jiang, Hongliang and Weng, Kaiheng and Geng, Yifei and Li, Liang and Ke, Zaidan and Li, Qingyuan and Cheng, Meng and Nie, Weiqiang and others},
  journal={arXiv preprint arXiv:2209.02976},
  year={2022}
}
@software{glenn_jocher_2020_4154370,
  author       = {Glenn Jocher and,Alex Stoken and,Jirka Borovec and,NanoCode012 and,ChristopherSTAN and,Liu Changyu and,Laughing and,tkianai and,Adam Hogan and,lorenzomammana and,yxNONG and,AlexWang1900 and,Laurentiu Diaconu and,Marc and,wanghaoyang0106 and,ml5ah and,Doug and,Francisco Ingham and,Frederik and,Guilhen and,Hatovix and,Jake Poznanski and,Jiacong Fang and,Lijun Yu 于力军 and,changyu98 and,Mingyu Wang and,Naman Gupta and,Osama Akhtar and,PetrDvoracek and,Prashant Rai},
  title={{ultralytics/yolov5: v7.2 - Bug Fixes and 
                   Performance Improvements}},
  month= oct,
  year= 2020,
  publisher= {Zenodo},
  version= {v3.1},
  doi= {10.5281/zenodo.4154370},
  url= {https://doi.org/10.5281/zenodo.4154370}
}
@article{cao2022observation,
  title={Observation-Centric SORT: Rethinking SORT for Robust Multi-Object Tracking},
  author={Cao, Jinkun and Weng, Xinshuo and Khirodkar, Rawal and Pang, Jiangmiao and Kitani, Kris},
  journal={arXiv preprint arXiv:2203.14360},
  year={2022}
}
@article{zhang2022bytetrack,
  title={ByteTrack: Multi-Object Tracking by Associating Every Detection Box},
  author={Zhang, Yifu and Sun, Peize and Jiang, Yi and Yu, Dongdong and Weng, Fucheng and Yuan, Zehuan and Luo, Ping and Liu, Wenyu and Wang, Xinggang},
  booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},
  year={2022}
}
@article{du2022strongsort,
  title={Strongsort: Make deepsort great again},
  author={Du, Yunhao and Song, Yang and Yang, Bo and Zhao, Yanyun},
  journal={arXiv preprint arXiv:2202.13514},
  year={2022}
}
@inproceedings{Bewley2016_sort,
  author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
  booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
  title={Simple online and realtime tracking},
  year={2016},
  pages={3464-3468},
  keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},
  doi={10.1109/ICIP.2016.7533003}
}
@article{torchreid,
    title={Torchreid: A Library for Deep Learning Person Re-Identification in Pytorch},
    author={Zhou, Kaiyang and Xiang, Tao},
    journal={arXiv preprint arXiv:1910.10093},
    year={2019}
} 
@inproceedings{Bewley2016_sort,
  author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
  booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
  title={Simple online and realtime tracking},
  year={2016},
  pages={3464-3468},
  keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},
  doi={10.1109/ICIP.2016.7533003}
}
@inproceedings{zhou2019osnet,
    title={Omni-Scale Feature Learning for Person Re-Identification},
    author={Zhou, Kaiyang and Yang, Yongxin and Cavallaro, Andrea and Xiang, Tao},
    booktitle={ICCV},
    year={2019}
}
@inproceedings{Bewley2016_sort,
  author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
  booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
  title={Simple online and realtime tracking},
  year={2016},
  pages={3464-3468},
  keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},
  doi={10.1109/ICIP.2016.7533003}
}
@article{zhou2021osnet,
    title={Learning Generalisable Omni-Scale Representations for Person Re-Identification},
    author={Zhou, Kaiyang and Yang, Yongxin and Cavallaro, Andrea and Xiang, Tao},
    journal={TPAMI},
    year={2021}
}

torchyolo's People

Contributors

kadirnar 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  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  avatar  avatar  avatar  avatar

torchyolo's Issues

Does it support yolo segmentation?

hi sir
yolo v5 v7 v8 provides segmentation function.
so does torchyolo support yolo segmentation?
i want to detect small object via segmentation.
thanks.

Conda Channel package

Hi Kadir,

I think providing supporting installation through conda channels would be beneficial as conda-forge channel is somewhat popular for package management.

If this seems like a good idea to you, I can help with this on how to integrate torchyolo into conda-forge channel.

Also, managing python only packages is pretty automated when it comes to conda-forge channel

Tell me how to Command

Hi,Thank you for your amazing code. when I see this code,I immidiately try but I'm not sure how to command.
I wanna Yolov8 + OCSORT. What Should I do?
I've already pip install torchyolo. and pip install -e ."[dev]".
Would you tell me how to do it

AttributeError when using Strong Sort tracker in TorchYOLO

When attempting to use the Strong Sort tracker with the TorchYOLO framework, users encounter an AttributeError. The error occurs when executing the following command:

torchyolo tracker --config_path torchyolo/configs/default_config.yaml --model_type yolov5 --model_path yolov5s.pt --tracker_config_path torchyolo/configs/tracker/strong_sort.yaml --source yl.mp4
Error Message:
YOLOv5 2024-3-25 Python-3.8.19 torch-1.13.0+cpu CPU

Fusing layers...
Model summary: 214 layers, 7022326 parameters, 0 gradients, 15.9 GFLOPs
Adding AutoShape...
Traceback (most recent call last):
File "C:\Users\elkis\anaconda3\envs\env2\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\elkis\anaconda3\envs\env2\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\elkis\anaconda3\envs\env2\Scripts\torchyolo.exe_main
.py", line 7, in
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\cli.py", line 10, in app
Fire(torchyolo_app)
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\fire\core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\fire\core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\predict.py", line 88, in tracker_predict
result = model.tracker_predict(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\predict.py", line 56, in tracker_predict
tracker_prediction = self.model.tracker_predict(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\modelhub\yolov5.py", line 78, in tracker_predict
tracker_module = load_tracker_module(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\tracker\tracker_module.py", line 18, in load_tracker_module
tracker_module = load_tracker(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\tracker\tracker_zoo.py", line 148, in load_tracker
tracker_module = create_tracker(
File "C:\Users\elkis\anaconda3\envs\env2\lib\site-packages\torchyolo\tracker\tracker_zoo.py", line 79, in create_tracker
distance_function=config.NORFAIR_TRACK.DISTANCE_FUNCTION,
AttributeError: 'YamlParser' object has no attribute 'NORFAIR_TRACK'

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.