Table of Contents
Yolor-trt is a pioneering open-source project providing an efficient, predictive personal protective equipment (PPE) detection system. This revolutionary technology leverages high-performance object detection models paired with convenient API endpoints, orchestrated services and asynchronous tasks handling. Designed for businesses, developers, and researchers, it ensures a safer workplace by accurately identifying PPE in visual content, delivering streamlined image processing, and facilitating rapid deployment.
Feature | Summary | |
---|---|---|
⚙️ | Architecture |
|
🔩 | Code Quality |
|
📄 | Documentation |
|
🔌 | Integrations |
|
🧩 | Modularity |
|
🧪 | Testing |
|
⚡️ | Performance |
|
🛡️ | Security |
|
📦 | Dependencies |
|
└── yolor-trt/
├── PPEDetection
│ ├── .gitignore
│ ├── Dockerfile
│ ├── main.py
│ ├── requirements.txt
│ └── src
├── README.md
└── docker-compose.yml
YOLOR-TRT/
__root__
docker-compose.yml - The docker-compose.yml orchestrates service creation for a predictive personal protective equipment (PPE) detection system, encompassing a main PPE detection service, an associated worker service, and two additional required services: Redis and RabbitMQ
- These coordinated services ensure efficient message brokering and task queuing for robust, high-performance PPE detection.
PPEDetection
main.py - MaineCoon is a FastAPI-based application outlined in PPEDetection/main.py, offering a comprehensive routing solution within the project structure through the integration of the API router
- It ensures smooth navigation and efficient functionality of various endpoints, contributing significantly to the architectural integrity of the entire codebase.requirements.txt - PPEDetection/requirements.txt lists the specific software dependencies required for the PPEDetection project
- It enables the setup of a uniform development environment and guarantees the smooth running of the project
- It includes packages necessary for computer vision tasks, web server operation, data serialization, and handling asynchronous tasks.Dockerfile - The Dockerfile in the PPEDetection directory sets up an environment for running a TensorRT-based application
- It begins with an Nvidia TensorRT base image, installs necessary Python packages, copies project requirements, and installs them
- Additionally, it updates system packages and installs utilities required for multimedia processing.src
routes
model_route.py - Model_route.py forms part of the routing system in the PPEDetection application
- It handles image data sent via API calls for inference, initiates processing, and manages responses
- It also retrieves processing results once ready, converting them to a viewable image format for return to the client.routes.py - Routes.py in PPEDetection/src/routes acts as a connection point, integrating model_route with the APIRouter from FastAPI
- Predominantly, it assigns a specific "/model" prefix and "model" tag, enhancing the traceability and organization of the routes related to the model within the broader codebase architecture.controllers
model_controller.py - Model Controller in the PPEDetection project facilitates image inference tasks
- Leveraging helper functions, it converts image bytes to string format, then dispatches this data for further processing
- Thus, it serves as an important touchpoint for managing image parsing and initiating subsequent AI analysis tasks.queue
worker.py - Worker.py configures and initializes the Celery application within the Personal Protective Equipment (PPE) Detection project
- It leverages environment variables for the broker and backend URI setups
- Additionally, it includes task definitions from the tasks file located within the same queue module, facilitating distributed task execution across worker nodes.tasks.py - The 'tasks.py' within the PPEDetection/src/queue directory serves as the primary component for managing machine learning model prediction tasks
- It utilizes an abstraction of the Celery's Task class to efficiently load models for the first task call, eliminating the need to reload for each subsequent task
- It also provides an inference function for image data processing.utils
asserts
coco.names - The utility file 'coco.names' within the PPEDetection project serves as a predefined dictionary for object recognition
- It lists common objects from everyday items like 'bottle' or 'clock', to animals like 'dog', and transportation mediums like 'bicycle'
- It aids in identifying and labeling these objects within images or video frames for the personal protective equipment detection system.helper
model_utils.py - The code in 'model_utils.py' provides various utility functions geared towards image processing and detection tasks
- Key functionalities include converting and resizing images, performing Non-Maximum Suppression (NMS) on prediction results, drawing bounding boxes for detection results, and handling image formats for further processing
- These functions support the primary tasks of the PPEDetection project.services
trt_loader.py - The 'trt_loader.py' file in the PPEDetection project is responsible for managing NVIDIA's TensorRT models
- It prepares, executes, and retrieves results from the inference engine
- Specifically, it handles memory allocation for the engine's inputs and outputs, performs inference, and manages the transfer of data between host and device
- Furthermore, it also reorganizes the model's flattened outputs back to their original shapes.model_service.py - The code in 'model_service.py' is responsible for coordinating the entire object detection process
- It manages the loading and configuration of the YOLOR model, preprocesses images for detection, handles detection and results from the model, and conducts post-processing activities including drawing bounding boxes and scaling results back to original image size.
Before getting started with yolor-trt, ensure your runtime environment meets the following requirements:
- Programming Language: Python
- Package Manager: Pip
- Container Runtime: Docker
Install yolor-trt using one of the following methods:
Build from source:
- Clone the yolor-trt repository:
❯ git clone https://github.com/RTae/yolor-trt
- Navigate to the project directory:
❯ cd yolor-trt
- Install the project dependencies:
❯ pip install -r PPEDetection/requirements.txt
❯ docker build -t RTae/yolor-trt .
Run yolor-trt using the following command:
Using pip
❯ python {entrypoint}
❯ docker run -it {image_name}