RizwanMunawar / yolov7-object-tracking

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

YOLOv7 Object Tracking 🚀

New Features ✨

Coming Soon 🔄

Ready-to-Use Google Colab 🔗 Launch Colab

How to Run the Code 🖥️

  1. Clone the repository:

    git clone https://github.com/RizwanMunawar/yolov7-object-tracking.git
  2. Navigate to the cloned folder:

    cd yolov7-object-tracking
  3. Create a virtual environment (Recommended to avoid conflicts):

    For Anaconda:

    conda create -n yolov7objtracking python=3.10
    conda activate yolov7objtracking

    For Linux:

    python3 -m venv yolov7objtracking
    source yolov7objtracking/bin/activate

    For Windows:

    python3 -m venv yolov7objtracking
    cd yolov7objtracking/Scripts
    activate
  4. Update pip and install dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
  5. Run the script:

    Select the appropriate command based on your requirements. Pretrained yolov7 weights will be downloaded automatically if needed.

    • Detection only:

      python detect.py --weights yolov7.pt --source "your video.mp4"
    • Object tracking:

      python detect_and_track.py --weights yolov7.pt --source "your video.mp4"
    • Webcam:

      python detect_and_track.py --weights yolov7.pt --source 0
    • External Camera:

      python detect_and_track.py --weights yolov7.pt --source 1
    • IP Camera Stream:

      python detect_and_track.py --source "your IP Camera Stream URL" --device 0
    • Specific class tracking (e.g., person):

      python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --classes 0
    • Colored tracks:

      python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --colored-trk
    • Save track centroids, IDs, and bounding box coordinates:

      python detect_and_track.py --weights yolov7.pt --source "your video.mp4" --save-txt --save-bbox-dim
  6. Output files will be saved in working-dir/runs/detect/obj-tracking with the original filename.

Results 📊

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

References 🔗

Some of my articles/research papers | computer vision awesome resources for learning | How do I appear to the world? 🚀

Ultralytics YOLO11: Object Detection and Instance Segmentation🤯 Published Date

Parking Management using Ultralytics YOLO11 Published Date

My 🖐️Computer Vision Hobby Projects that Yielded Earnings Published Date

Best Resources to Learn Computer Vision Published Date

Roadmap for Computer Vision Engineer Published Date

How did I spend 2022 in the Computer Vision Field Published Date

Domain Feature Mapping with YOLOv7 for Automated Edge-Based Pallet Racking Inspections Published Date

Exudate Regeneration for Automated Exudate Detection in Retinal Fundus Images Published Date

Feature Mapping for Rice Leaf Defect Detection Based on a Custom Convolutional Architecture Published Date

Yolov5, Yolo-x, Yolo-r, Yolov7 Performance Comparison: A Survey Published Date

Explainable AI in Drug Sensitivity Prediction on Cancer Cell Lines Published Date

Train YOLOv8 on Custom Data Published Date

Session with Ultralytics Team about Computer Vision Journey Published Date