RizwanMunawar / yolov7-object-tracking

YOLOv7 Object Tracking Using PyTorch, OpenCV and Sort Tracking
GNU General Public License v3.0
552 stars 165 forks source link
deep-learning object-detection opencv-python tracking-algorithm yolov7

yolov7-object-tracking

New Features

Coming Soon

Ready to Use Google Colab

  1. Update pip and install libraries

    # Upgrade pip with mentioned command below.
    pip install --upgrade pip
    
    # Install requirements with mentioned command below.
    pip install -r requirements.txt
  2. Run the script

    Select the appropirate command from the following list of command according to your need. (by default, pretrained yolov7 weights will be automatically downloaded into the working directory if they don't already exist).

    # for detection only
    python detect.py --weights yolov7.pt --source "your video.mp4"
    
    #if you want to change source file
    python detect_and_track.py --weights yolov7.pt --source "your video.mp4"
    
    #for WebCam
    python detect_and_track.py --weights yolov7.pt --source 0
    
    #for External Camera
    python detect_and_track.py --weights yolov7.pt --source 1
    
    #For LiveStream (Ip Stream URL Format i.e "rtsp://username:pass@ipaddress:portno/video/video.amp")
    python detect_and_track.py --source "your IP Camera Stream URL" --device 0
    
    #for specific class (person)
    python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --classes 0
    
    #for colored tracks 
    python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --colored-trk
    
    #for saving tracks centroid, track id and bbox coordinates
    python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --save-txt --save-bbox-dim
  3. Output file will be created in the working-dir/runs/detect/obj-tracking with original filename.

Results

YOLOv7 Detection Only YOLOv7 Object Tracking with ID YOLOv7 Object Tracking with ID and Label

References

My Medium Articles

For more details, you can reach out to me on Medium or can connect with me on LinkedIn