Code Monkey home page Code Monkey logo

realtime-reid's Introduction

⚡Real-Time Person Re-ID in Multi-Camera Surveillance Systems⚡

Build with

kafka spark torch flask python

Introduction

This project leverages a combination of cutting-edge technologies, including Apache Kafka and Apache Spark, along with straightforward Deep Learning Models like YOLOv5 (for Human Detection) and ResNet (for Person Re-identification). The primary objective is to tackle the challenge of Person Re-identification in real-time within a given scenario.

In the context of a building equipped with multiple cameras, the aim is to detect individuals across these camera feeds and assign unique IDs to each person. Notably, a person may initially appear in one camera and subsequently reappear in another. The overarching objective is to seamlessly identify the same individual across these cameras by associating them with a consistent ID—a task commonly referred to as Person Re-identification.

Project overview

This project presents a real-time Person Re-identification System using Deep Learning techniques. The system is designed to (1) process video streams, (2) detect persons in the video and (3) identify them based on their features.

The project is structured around several key components:

  • The Producer.py and Consumer.py scripts handle the ingestion and consumption of data.
  • The realtime_reid module contains the core functionality of the system, including person detection (person_detector.py), feature extraction (feature_extraction.py), and person identification (classifier.py).
  • The streaming module includes services for video production (kafka_services/video_producer.py) and data processing (spark_services/spark_processing.py).
  • The project is configured via a settings.json file (TODO) and dependencies are managed through a requirements.txt file.

Prerequisites

  • Python 3.11
  • Apache Spark (>= 3.5.0)
  • Apache Kafka (>= 3.6.0)

Note:

  • I tested this on python=3.12 (November 2023) but it didn't work. You can test it on the latest version, if it still doesn't work, I recommend using python=3.11.

Getting Started

  • Install Apache Spark and Apache Kafka (Remember to test if it works).

  • Clone this repository

  • Create a Python environment and install the necessary packages

conda create -n human_reid python=3.11
conda activate human_reid
pip install -r requirements.txt
  • There are 2 models needed for this project:
    • A YOLOv5 model (yolov5s.pt) for Human Detection. The model will be automatically downloaded when you run the code for the first time, or if you want to use your own yolov5 model, you can put it in the checkpoints/ folder.
    • A ResNet50 model (resnet50_model.pt) for Person Re-identification (Feature Extraction specifically). This model is required, put it in the checkpoints/ folder.

Usage

  • Run Zookeeper
/path/to/your/kafka/bin/zookeeper-server-start.sh /path/to/your/kafka/config/zookeeper.properties
  • Run Kafka
/path/to/your/kafka/bin/kafka-server-start.sh /path/to/your/kafka/config/server.properties
  • Run the Consumer. You can run python Consumer.py --help to see the arguments.
python Consumer.py --topic topic_name --topic-2 topic_name_2 --reid y
  • Run Producers to publish recorded footage from our cameras on these topics (run each producer separately).
python Producer.py --topic topic_name --camera /path/to/your/video.mp4
python Producer.py --topic topic_name_2 --camera /path/to/your/video.mp4
  • A cv2 window will pop up if the producer is running successfully (2 windows if run 2 topics).

Contribution

This repo is continuously fixed and updated over time, feel free to fix some issues/bugs, all are welcome here!

About Us

We are a Group of Students majoring in Data Science at University of Information Technology (UIT), VNU-HCM of Vietnam.

realtime-reid's People

Contributors

tannd-ds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

realtime-reid's Issues

Initial Partial Visibility Challenges

Note: By saying "initial partial visibility" I mean where the visible parts of a person in the images are just part of their body (feet, forehead, etc.).

While my feature extraction (currently using ResNet50) is effective, the classification part is not. When the model can only see part of a person in a picture, like their feet or forehead, it is tricky. The problem is, that these parts look similar for most people, so if the model thinks it's one person and gets it wrong, it keeps making more mistakes in a row.

Incorrect Labeling of Images Featuring Multiple Objects (People)

  • Problem: Upon analysis, I observed that when there are multiple individuals captured within the same frame (in my specific test case, there are two), the model incorrectly assigns IDs, reversing their correct order.

  • Reson: The issue arises due to the separation of the "identification" and "annotation" steps. I employed the output of the .crop() function for feature extraction and identification while relying on the complete output of Yolov5 to annotate the final result.

  • Solution: To address this problem, I propose abandoning the output of the .crop() function. Instead, we can achieve the same results by manually cropping the image using the .xyxy function. Subsequently, we should employ this manually cropped detection for annotation purposes, replacing the output of the .crop() function.

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.