GithubHelp home page GithubHelp logo

yolo_slowfast's Introduction

Yolov5+SlowFast: Realtime Action Detection

A realtime action detection frame work based on PytorchVideo.

Here are some details about our modification:

  • we choose yolov5 as an object detector instead of Faster R-CNN, it is faster and more convenient
  • we use a tracker(deepsort) to allocate action labels to all objects(with same ids) in different frames
  • our processing speed reached 24.2 FPS at 30 inference batch size (on a single RTX 2080Ti GPU)

Relevant infomation: FAIR/PytorchVideo; Ultralytics/Yolov5

Demo comparison between original(<-left) and ours(->right).

Update Log:

  • 2023.03.31 fix some bugs(maybe caused by yolov5 version upgrade), support real time testing(test on camera or video stearm).

  • 2022.01.24 optimize pre-process method(no need to extract video to image before processing), faster and cleaner.

Installation

  1. clone this repo:

    git clone https://github.com/wufan-tb/yolo_slowfast
    cd yolo_slowfast
    
  2. create a new python environment (optional):

    conda create -n {your_env_name} python=3.7.11
    conda activate {your_env_name}
    
  3. install requiments:

    pip install -r requirements.txt
    
  4. download weights file(ckpt.t7) from [deepsort] to this folder:

    ./deep_sort/deep_sort/deep/checkpoint/
    
  5. test on your video/camera/stream:

    python yolo_slowfast.py --input {path to your video/camera/stream}
    

    The first time execute this command may take some times to download the yolov5 code and it's weights file from torch.hub, keep your network connection.

    set --input 0 to test on your local camera, set --input {stream path, such as "rtsp://xxx" or "rtmp://xxxx"} to test on viewo stream.

References

Thanks for these great works:

[1] Ultralytics/Yolov5

[2] ZQPei/deepsort

[3] FAIR/PytorchVideo

[4] AVA: A Video Dataset of Spatio-temporally Localized Atomic Visual Actions. paper

[5] SlowFast Networks for Video Recognition. paper

Citation

If you find our work useful, please cite as follow:

{   yolo_slowfast,
    author = {Wu Fan},
    title = { A realtime action detection frame work based on PytorchVideo},
    year = {2021},
    url = {\url{https://github.com/wufan-tb/yolo_slowfast}}
}

Stargazers over time

Stargazers over time

yolo_slowfast's People

Contributors

wufan-tb 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

yolo_slowfast's Issues

Use this code on a mac

Hello,

I was wondering what the correct command would be if I wanted to run your script on a mac?

I tried the default:
python yolo_slowfast.py --input 0
and got

Adding AutoShape... 
Traceback (most recent call last):
  File "yolo_slowfast.py", line 201, in <module>
    main(config)
  File "yolo_slowfast.py", line 120, in main
    model = torch.hub.load('ultralytics/yolov5', 'yolov5l6').to(device)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 673, in to
    return self._apply(convert)
  File "/Users/elinxie/.cache/torch/hub/ultralytics_yolov5_master/models/common.py", line 648, in _apply
    self = super()._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/Users/elinxie/.cache/torch/hub/ultralytics_yolov5_master/models/yolo.py", line 155, in _apply
    self = super()._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 409, in _apply
    param_applied = fn(param)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/nn/modules/module.py", line 671, in convert
    return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
  File "/Users/elinxie/anaconda3/envs/yolo_slowfast/lib/python3.7/site-packages/torch/cuda/__init__.py", line 164, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")

I tried python yolo_slowfast.py --input 0 --device cpu and got

processing...
[W NNPACK.cpp:80] Could not initialize NNPACK! Reason: Unsupported hardware.
processing 0th second clips

What device should I use?

问题

Traceback (most recent call last):
File "D:\yolo_slowfast-master\yolo_slowfast.py", line 201, in
main(config)
File "D:\yolo_slowfast-master\yolo_slowfast.py", line 127, in main
video_model = slowfast_r50_detection(True).eval().to(device)
File "D:\Anaconda3\envs\cnslowfast\lib\site-packages\pytorchvideo\models\hub\slowfast.py", line 178, in slowfast_r50_detection
**kwargs,
File "D:\Anaconda3\envs\cnslowfast\lib\site-packages\pytorchvideo\models\hub\slowfast.py", line 30, in _slowfast
checkpoint_path, progress=progress, map_location="cpu"
File "D:\Anaconda3\envs\cnslowfast\lib\site-packages\torch\hub.py", line 528, in load_state_dict_from_url
return torch.load(cached_file, map_location=map_location)
File "D:\Anaconda3\envs\cnslowfast\lib\site-packages\torch\serialization.py", line 585, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "D:\Anaconda3\envs\cnslowfast\lib\site-packages\torch\serialization.py", line 242, in init
super(_open_zipfile_reader, self).init(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: [enforce fail at ..\caffe2\serialize\inline_container.cc:145] . PytorchStreamReader failed reading zip archive: failed finding central directory
RuntimeError: [enforce fail at ..\caffe2\serialize\inline_container.cc:145] . PytorchStreamReader failed reading zip archive: failed finding central directory
你好,在pycharm运行,出现上述报错 这个错误表明在尝试从zip文件中读取模型状态字典时出现问题。这可能是由于zip文件损坏或不完整导致的。请问怎么解决呢?麻烦您抽空给出回答

Detection on custom yolo weights

I have a custom trained yolo weights and there the person class is not having 0 class index. How to handle that?
As far as I understood you are taking the 0th index and passing it to slowfast_r50, since person class is in 0th index at coco dataset

Real time testing

Hai @wufan-tb

How to test with real-time videos from video surveillance. is that possible and how to test the modal with multiple video surveillance cameras

Thanks

the issue on the windows

it doesn't work properly on windows, just like this
image
and for many peoples in a classroom, it doesn't work. just like this
image
so I want to the site of its application scenarios

some Exception

Exception: CUDA error: CUBLAS_STATUS_INTERNAL_ERROR when calling cublasCreate(handle). Cache may be out of date, try force_reload=True or see ultralytics/yolov5#36 for help.

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.