MasoomChoudhury/processor
0
Real-Time Batch Image Processing Pipeline
This project implements a real-time, event-driven batch image processing pipeline using Supabase for database, storage, and real-time capabilities. The system processes images through OCR and AI analysis using Google Gemini and Anthropic Claude.
Features
- Real-time image upload detection using Supabase Realtime
- Intelligent batching of image processing tasks
- OCR processing using Google Gemini
- Dual AI analysis using Google Gemini and Anthropic Claude
- Event-driven architecture with no polling
- Docker containerization for easy deployment
Prerequisites
- Python 3.10 or higher
- Supabase account with database and storage set up
- Google Gemini API key
- Anthropic Claude API key
- Docker (for deployment)
Setup
- Database Setup
- Run the SQL commands from
db_setup.sqlin your Supabase SQL Editor - This will create the necessary tables and enable real-time functionality
- Environment Variables Create a
.envfile with the following variables:
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_KEY=your_supabase_service_key
GEMINI_API_KEY=your_gemini_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key- Installation
# Install dependencies
pip install -r requirements.txtRunning Locally
python main.pyDeployment on Hugging Face Spaces
- Create a new Space on Hugging Face
- Choose Docker as the Space type
- Add your environment variables as Secrets in the Space settings
- Push your code to the Space repository
The Docker container will automatically build and start running the application.
Architecture
The system follows an event-driven architecture:
- Images are uploaded to Supabase Storage
- A record is inserted into the
jobstable - The backend receives real-time notifications via WebSocket
- Images are processed in batches with a 7-second window
- OCR and AI analysis are performed concurrently
- Results are stored back in the database
Database Schema
The system uses two main tables:
batches: Manages groups of image processing jobsjobs: Tracks individual image processing tasks
For detailed schema information, refer to db_setup.sql.
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT
