A vision pipeline for object and car make classification with CLI
Project description
Pax Case: Object and Car Make Classification
This project provides a vision pipeline for object and car make classification. It includes a command-line interface (CLI) for processing images and a Gradio-based web interface for interactive demonstrations.
Problem Statement
The goal is to build a tool that can:
- Object Classification: Identify whether an image contains a car, truck, bicycle, or person.
- Car Make Classification: If the image contains a car, identify its make (e.g., Volkswagen, Chevrolet).
The solution must be scalable to handle up to 10 million images daily and be flexible enough to accommodate future classification tasks.
Features
- Two-Stage Pipeline:
- Object Detection: Uses a YOLOv8 model to detect objects (person, bicycle, car, truck).
- Car Make Classification: Uses a Vision Transformer (ViT) model fine-tuned on the Stanford Cars dataset to classify the make of detected cars.
- CLI Tool (
cli.py):- Process single images from the command line.
- Adjustable confidence threshold for object detection.
- Output results in JSON format to the terminal or a file.
- Gradio Web Demo (
gradio_demo.py):- Interactive, user-friendly interface for image uploads.
- Real-time processing and display of annotated images with bounding boxes.
- Shows top-5 car make predictions with confidence scores.
- Scalability and Extensibility:
- The architecture is designed to be scalable and extensible. See
SCALING_STRATEGY.mdfor a detailed plan on scaling to 10M images/day and adding new classification types.
- The architecture is designed to be scalable and extensible. See
Project Structure
.pax-case/
├── classification/
│ ├── makes/ # Car make classification model and logic
│ └── objects/ # Object detection model and logic
├── datasets/
│ └── car-camera/ # Example dataset
├── pipeline/
│ └── vision_pipeline.py # Core processing pipeline
├── cli.py # Command-line interface
├── gradio_demo.py # Gradio web interface
├── pyproject.toml # Project dependencies
└── README.md # This file
Setup and Installation
-
Clone the repository:
git clone <repository-url> cd pax-case
-
Install dependencies: It is recommended to use a virtual environment. This project uses
uvfor package management.python -m venv .venv source .venv/bin/activate pip install uv uv pip install -r requirements.txt # Or from pyproject.toml
Usage
Command-Line Interface (CLI)
The CLI tool (cli.py) is used for processing individual images.
Basic Usage:
python cli.py --image_path /path/to/your/image.jpg
Arguments:
--image_path: (Required) Path to the input image.--output: (Optional) Path to save the JSON output file.--confidence: (Optional) Confidence threshold for object detection (default: 0.5).
Example:
python cli.py --image_path datasets/car-camera/images/00001.jpg --confidence 0.4 --output results.json
This will process the image, save the output to results.json, and print the path to the output file.
Gradio Web Demo
The Gradio demo (gradio_demo.py) provides an interactive web interface to test the pipeline.
To run the demo:
python gradio_demo.py
This will start a local web server. Open your browser and navigate to the URL provided (usually http://127.0.0.1:7860) to access the interface.
How to use the demo:
- Drag and drop an image file into the upload box or click to browse.
- The pipeline will automatically process the image.
- View the annotated image with bounding boxes, a summary of the results, and detailed classification outputs.
Extensibility
For details on how to add more classification types (e.g., helmet color, t-shirt color), please refer to the SCALING_STRATEGY.md document, which outlines the proposed architecture for extending the pipeline.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pax_detector-0.1.3.tar.gz.
File metadata
- Download URL: pax_detector-0.1.3.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b052cac76254660d23e8f82b1b29f61cf41aea200717cde5857fa6b94bb48a58
|
|
| MD5 |
a022db4efcf89449ebdf8918a8d0c4a7
|
|
| BLAKE2b-256 |
8ccbde293a3c9f32b5831b116d311224c8f70df6c35c9fb67a01f74e4c4ef0a5
|
File details
Details for the file pax_detector-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pax_detector-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1af671d27da84449ceb7974ac6c71a41709edd975fd0b6ee20719ffe59f34ec
|
|
| MD5 |
b04bb2f04496d880f3d3c5777e8ace44
|
|
| BLAKE2b-256 |
f4cca9e7c9c265f13554c6de962fb1fd03de89c0e60ca03fd0e17365117ca2eb
|