This repository presents a full process of training a pedestrian tracking model using `deep-person-reid` repository. Further, a complete web-application service based on FastAPI is provided that extracts features using YoloV5 and trained model.

Overview

Person Tracking DeepSORT Yolov5

Person tracking/re-identification is one of the major deep learning problems that is very popular in surveillance applications. This repository presents a full process of training a person tracking model using deep-person-reid repository. Further, a complete web-application service based on FastAPI is provided that extracts features using YoloV5 and trained model.

Preparing Dataset

Based on the instructions provided by deep-person-reid in their blog, 3 subset of data should be generated:

  1. train: Main training set should be larger than the others
  2. gallery: Used for evaluation
  3. query: Used for evaluation

Link-to-instruction

For the sake of this project, 2 dataset are used:

  1. Market1501
  2. Cuhk03

The market1501 dataset is automatically downloaded using torchreid. Cuhk03, however, should be downloaded manually. You can find the download link in the following website or your can download it directly from the following Google drive link also provided in the mentioned website.

  1. Website: https://chowdera.com/2022/01/202201041911261238.html
    1. make sure to download cuhk03-np because it is compatible with torchreid's training process...
  2. Google Drive: https://drive.google.com/file/d/1pBCIAGSZ81pgvqjC-lUHtl0OYV1icgkz/view

After downloading teh chuk03 dataset, unzip the file and get folders inside the labeled directory, and copy them to reid-data\cuhk03-np. The output directory should like the following image:

Install Requirements

pip install -r requirements.txt

Install torchreid. For a thorough instruction, check the following link: https://kaiyangzhou.github.io/deep-person-reid/#installation

Or follow the instruction below:

git clone https://github.com/KaiyangZhou/deep-person-reid.git
cd deep-person-reid
pip install -r requirements
python setup.py develop

Train

Clone the deep-person-reid repo and install the requirements:

git clone https://github.com/KaiyangZhou/deep-person-reid.git
cd deep-person-reid
pip install -r requirements.txt
# install torch and torchvision (select the proper cuda version to suit your machine)
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
python setup.py develop

For training run the train.py module

# cd to project's root
python train.py --model_type osnet_x1_0 --epochs 50

The output should be like the following:

** Results **
Rank-1  : 92.3%
Rank-5  : 96.9%
Rank-10 : 98.0%
Rank-20 : 98.8%
Checkpoint saved to "log/osnet_x1_0/model/model.pth.tar-50"
Elapsed 0:35:08

Inference

Inference can be applied on any video. To make it easier, there is sample that can be downloaded with the following command:

cd videos
./get_videos.sh

For Tracking deep_sort architecture is used which is taken from Yolov5_DeepSort_Pytorch GitHub repository and wrapped by deep_utils. In addition to a re-identification model, an object detection model is required which in this case yolov5 with deep_utils wrapper is used as well!

Used the pretrained models

Download yolov5s.pt & person-reid models using the following commands:

gdown --id 1vqycd7HQMPZdZvcP-QH2ZGfYxhWRntZy
gdown --id 1WY3z5om3ldRpHL6w04hKH-zP0-33Ruhg

For inference run the following command:

# pretrained
python demo.py --video_path videos/test_person_1.mp4 --model_path model.pth.tar-50 --model_type osnet_x1_0
# trained by you
python demo.py --video_path videos/test_person_1.mp4 --model_path log/osnet_x1_0/model/model.pth.tar-50 --model_type osnet_x1_0
# Save gif
python demo.py --video_path videos/test_person_1.mp4 --model_path model.pth.tar-50 --model_type osnet_x1_0 --get_gif

The result should be like the following gif:

Person Tracking Web Service with FastAPI

Download weights

cd app/weights
bash get_weights.sh

Download a sample Video

cd videos
bash get_videos.sh

RUN Docker-Compose

sudo docker-compose up --build

Check service health:

curl -X GET localhost:8000/tracking

Send a single image:

(echo -n '{"image_file": "'; base64 ./samples/sample_01.png; echo '"}') | curl -H "Content-Type: application/json" -d @-  http://127.0.0.1:8000/tracking

output: The output is a dictionary/json with the following items:

  1. features: byte array features of extracted from detected objects
  2. confidences: object-detection confidence for each detected object
  3. names: object-detection's class names
  4. boxes: detected boxes
  5. classes: predicted class indices

Run a video

python client.py --endpoint-url  http://localhost:8000/tracking --video_path videos/test_traffic.mp4

References

  1. https://github.com/KaiyangZhou/deep-person-reid.git
  2. https://kaiyangzhou.github.io/deep-person-reid/user_guide#use-your-own-dataset
  3. https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
  4. https://github.com/pooya-mohammadi/deep_utils
You might also like...

This repo presents you the official code of "VISTA: Boosting 3D Object Detection via Dual Cross-VIew SpaTial Attention"

This repo presents you the official code of

VISTA VISTA: Boosting 3D Object Detection via Dual Cross-VIew SpaTial Attention Shengheng Deng, Zhihao Liang, Lin Sun and Kui Jia* (*) Corresponding a

Nov 22, 2022

Spotify data ETL - This repo presents a self-authored project from a Spotify data pipeline

Spotify data ETL - This repo presents a self-authored project from a Spotify data pipeline

Spotify data ETL This repo presents a self-authored project from a Spotify data pipeline. The idea is to create an Airflow with Docker instance, extra

Sep 17, 2022

This YOLOv5 script is for detecting fish using pre-trained weight in video

YOLOv5 for Fish Detection in Video Please follows all the instruction from the YOLOv5 repository: https://github.com/ultralytics/yolov5. Then, copy th

Sep 13, 2022

This is the Fire Detection App created with custom trained models using YoloV5

About This is the Fire Detection App created with custom trained models using YoloV5 Features Detect on Image Detect on Videos Live Detection Tech Sta

Oct 16, 2022

This project extracts (web scraping) movie data from IMDB and send a customized email letter with random popular movies.

This project extracts (web scraping) movie data from IMDB and send a customized email letter with random popular movies.

Email-Movie-Recommender-Web-Scrapping Web Scraping Project Description This project extracts movie data from IMDB and send a customized email letter w

Aug 9, 2022

Web Scraper made it with Python, it extracts a list of songs from spotify and downloads the songs in it

Web Scraper made it with Python, it extracts a list of songs from spotify and downloads the songs in it

Web_Scraper_pythonApi Web Scraper made it with Python, it extracts a list of songs from spotify and downloads the songs in it. Before running the scri

Aug 30, 2022

YOLOv5 Object Tracking + Detection + Object Blurring + Streamlit Dashboard Using OpenCV, PyTorch and Streamlit

YOLOv5 Object Tracking + Detection + Object Blurring + Streamlit Dashboard Using OpenCV, PyTorch and Streamlit

yolov5-object-tracking New Features YOLOv5 Object Tracking Using Sort Tracker Added Object blurring Option Added Support of Streamlit Dashboard Code c

Nov 17, 2022

A farm bot for Pokemeow. Solves captcha with custom trained weights with YOLOv5 and PyTorch.

A farm bot for Pokemeow. Solves captcha with custom trained weights with YOLOv5 and PyTorch.

PokeMeow With PyTorch A farm bot for Pokemeow. Solves captcha with custom trained weights with YOLOv5 and PyTorch. Youtube Tutorial : https://www.yout

Jun 30, 2022

AirBnB is a complete web application, integrating database storage, a back-end API, and front-end interface.

AirBnB is a complete web application, integrating database storage, a back-end API, and front-end interface.

AirBnB Clone Project DESCRIPTION AirBnB is a complete web application, integrating database storage, a back-end API, and front-end interface. This is

Aug 7, 2022
Owner
Pooya Mohammadi Kazaj
Open Source Enthusiast | AI Developer & Researcher
Pooya Mohammadi Kazaj
This project presents a full a process of creating face-detection & face-recognition web-application service using deep_utils library

Face-Detection-Recognition This project presents a full process of creating face-detection & face-recognition web-application service using deep_utils

Pooya Mohammadi Kazaj 4 Jun 28, 2022
null 5 Oct 6, 2022
FastAPI-User-Auth is a simple and powerful FastAPI user RBAC authentication and authorization library. Based on FastAPI-Amis-Admin and provides a freely extensible visual management interface.

项目介绍 FastAPI-User-Auth FastAPI-User-Auth是一个简单而强大的FastAPI用户RBAC认证与授权库. 基于FastAPI-Amis-Admin并提供可自由拓展的可视化管理界面. 源码 · 在线演示 · 文档 · 文档打不开? FastAPI-User-Auth是

AmisAdmin 151 Nov 23, 2022
YOLOv3、YOLOv4、YOLOv5、YOLOv5-Lite、YOLOv6、YOLOv7、YOLOX、YOLOX-Lite、TensorRT、NCNN、Tengine、OpenVINO

YOLOU:United, Study and easier to Deploy The purpose of our creation of YOLOU is to better learn the algorithms of the YOLO series and pay tribute to

null 631 Nov 25, 2022
Report and block camera service/microphone service/location service quickly.

Emergency-Brakes Report and block camera service/microphone service/location service quickly. Emergency-Brakes can detect whether the camera service /

liang4793 19 Nov 23, 2022
M2D2: A Massively Multi-domain Language Modeling Dataset (EMNLP 2022) by Machel Reid, Victor Zhong, Suchin Gururangan, Luke Zettlemoyer

M2D2: A Massively Multi-domain Language Modeling Dataset Scripts and data links for M2D2: A Massively Multi-domain Language Modeling Dataset (EMNLP 20

Machel Reid 35 Nov 11, 2022
Coreference resolution for English, French, German and Polish, optimised for limited training data and easily extensible for further languages

Coreferee Author: Richard Paul Hudson, Explosion AI 1. Introduction 1.1 The basic idea 1.2 Getting started 1.2.1 English 1.2.2 French 1.2.3 German 1.2

Explosion 64 Nov 24, 2022
A complete instruction for training a Persian spell checker and a language model based on SymSpell and KenLM, respectively using Wikipedia dataset.

Download Persian Wiki-Dump, Train Kenlm & Spell Checker In this project, I download persian wiki-dump dataset from wikipedia, preprocess it and finall

Pooya Mohammadi Kazaj 17 Oct 23, 2022
Repository for performing Airflow based on celeryExecutor. Perform ETL pipeline that extracts bitcoin and stock data and stores it in db

celery-airflow-api2db-exercise Prerequisites Install docker Install docker-compose Create .env like below to set an account AIRFLOW__MASTER__IP=host.d

jae hun hur 1 Aug 28, 2022