Automated alt-text, social media captions, and SEO metadata for product images β powered by Moondream & BLIP vision models.
An intelligent image captioning system that generates SEO-optimized alt-text, platform-specific social media captions, and complete SEO metadata from a single product image. Supports both local GPU inference (zero cost) and Moondream Cloud API (no GPU required).
| Feature | Benefit |
|---|---|
| Zero-cost local GPU inference | Run entirely on your own hardware β no API fees, no data leaves your server |
| Moondream Cloud fallback | No GPU? Use Moondream Cloud API ($5 free/month) with identical quality |
| Production-grade security | Rate limiting, input sanitization, timing-safe auth, request size enforcement |
| Batch processing | Process up to 50 images in parallel with real-time progress tracking |
| 5 platforms at once | Instagram, Twitter, Facebook, LinkedIn, Pinterest β optimized per platform |
| SEO metadata included | Filename, title tag, meta description, Open Graph, Schema.org markup |
| Docker-ready | One command to deploy: docker-compose up |
| 100% open source | MIT license, no vendor lock-in |
- E-commerce developers β Auto-generate alt-text and SEO metadata for product catalogs
- Social media managers β Create platform-optimized captions with hashtags in bulk
- Accessibility compliance officers β Meet WCAG alt-text requirements at scale
- SEO agencies β Generate optimized metadata for client image assets
- Dropshippers & resellers β Process large product image inventories quickly
git clone https://github.com/Dynamic-Web-Lab/dynamicweblab-ai-image-caption.git
cd dynamicweblab-ai-image-caption
cp .env.example .env # Edit with your settings
docker-compose up -d- API:
http://localhost:8000 - Frontend:
http://localhost:3000 - Swagger docs:
http://localhost:8000/docs
git clone https://github.com/Dynamic-Web-Lab/dynamicweblab-ai-image-caption.git
cd dynamicweblab-ai-image-caption
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # Edit with your settings
python main.py # Backend on :8000In a second terminal for the frontend:
cd frontend
npm install
npm run dev # Frontend on :3000Descriptive, keyword-rich alt-text for accessibility and SEO.
- Multiple length variations (short, medium, standard, descriptive)
- SEO score calculation (0-100)
- Keyword integration
- WCAG-compliant descriptions
Example: "Red A-line cotton dress with floral pattern"
Platform-optimized captions with hashtags and CTAs.
| Platform | Max Length | Optimal Hashtags |
|---|---|---|
| 2,200 chars | 11 | |
| 280 chars | 1 | |
| 63,206 chars | 2 | |
| 3,000 chars | 3 | |
| 500 chars | 10 |
Features: brand voice selection, engagement score prediction, CTA integration.
Complete metadata package for search visibility.
- SEO-friendly filename generation
- Title tag (50-60 chars optimal)
- Meta description (150-160 chars optimal)
- Open Graph tags for social sharing
- Schema.org JSON-LD markup
- Keyword density analysis & recommendations
Process up to 50 images in parallel.
- Semaphore-based concurrency (5 concurrent tasks)
- Real-time progress tracking with ETA
- CSV and JSON export
- Per-image success/failure tracking
- Automatic cleanup after processing
Base analysis using Moondream or BLIP vision models.
- Dominant color detection
- Object/element recognition
- Image dimensions and orientation
- Multi-model support (Moondream Cloud, Moondream Local, BLIP)
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/generate/complete |
Full package: alt-text + captions + SEO |
POST |
/api/v1/generate/alt-text |
Alt-text only |
POST |
/api/v1/generate/social-caption |
Single platform caption |
POST |
/api/v1/generate/seo-metadata |
SEO metadata only |
POST |
/api/v1/analyze |
Raw image analysis |
POST |
/api/v1/batch/upload |
Batch process multiple images |
GET |
/api/v1/batch/status/{id} |
Check batch progress |
GET |
/api/v1/batch/results/{id} |
Get batch results |
GET |
/api/v1/batch/export/{id}?format=csv |
Export as CSV/JSON |
GET |
/api/v1/rate-limit/status |
Your rate limit quota |
GET |
/api/v1/health |
Health check |
GET |
/api/v1/platforms |
Supported platforms |
curl -X POST "http://localhost:8000/api/v1/generate/complete" \
-F "image=@product.jpg" \
-F "product_name=Cotton Dress" \
-F "product_category=Women's Fashion" \
-F "keywords=dress,fashion,summer"Response:
{
"success": true,
"alt_text": {
"standard": "Red A-line cotton dress with floral pattern",
"short": "Red cotton dress",
"medium": "Red A-line cotton dress",
"seo_score": 85
},
"social_captions": {
"instagram": {
"caption": "Obsessed with this red cotton dress! π\n\nShop now! Link in bio\n\n#fashion #dress #summerstyle",
"engagement_score": 75,
"hashtag_count": 3
}
},
"seo_metadata": {
"filename": "womens-fashion-cotton-dress-red.jpg",
"title": "Cotton Dress - Women's Fashion",
"meta_description": "Red A-line cotton dress with floral pattern. Made from Cotton. Shop now.",
"seo_score": 90
}
}Full API documentation: http://localhost:8000/docs (Swagger UI)
Free, no-login service with IP-based rate limiting:
| Limit | Free Tier |
|---|---|
| Requests per minute | 10 |
| Requests per hour | 100 |
| Requests per day | 500 |
| Images per day | 1,000 |
| Max batch size | 50 |
Rate limit headers are included in every response. See RATE_LIMITS.md for details, error handling, and best practices.
This project implements production-grade security measures:
- Timing-safe authentication β
hmac.compare_digest()for admin API key validation - Input sanitization β HTML stripping, length limits, UUID-only batch IDs
- File upload security β MIME validation, size limits, UUID-prefixed filenames, path traversal prevention
- Rate limiting β IP-based with persistent storage across restarts
- Request size enforcement β Streaming body check (not just Content-Length header)
- Security headers β CSP, X-Frame-Options, X-Content-Type-Options, Permissions-Policy
- No secrets in code β All credentials via environment variables
- Error sanitization β Internal errors never exposed to clients
See SECURITY_FIXES.md and MEDIUM_SECURITY_ISSUES.md for the full security audit.
| Layer | Technology |
|---|---|
| Backend | FastAPI (Python) with async support |
| AI/ML | Moondream 2 (primary), BLIP (fallback), HuggingFace Transformers, PyTorch |
| Image Processing | Pillow, OpenCV |
| Frontend | Next.js 14 (App Router), TypeScript, Tailwind CSS, react-dropzone |
| Deployment | Docker, Docker Compose |
| Security | Rate limiting, input validation, secure file handling |
The system supports three vision model backends, tried in order:
- Moondream Cloud API β Best quality, requires API key, $5 free/month
- Moondream Local (GPU) β Free, runs on CUDA/MPS/CPU, same model weights
- BLIP (Fallback) β Always available, lower quality, larger model size
Configure in .env:
USE_MOONDREAM=True
MOONDREAM_API_KEY= # Optional: enables cloud API
MOONDREAM_MODEL=vikhyatk/moondream2
MOONDREAM_REVISION=2025-06-21
CAPTION_MODEL=Salesforce/blip-image-captioning-largedynamicweblab-ai-image-caption/
βββ api/
β βββ __init__.py
β βββ routes.py # All API endpoints
βββ core/
β βββ __init__.py
β βββ image_analyzer.py # Vision model abstraction
β βββ alt_text_generator.py # Alt-text generation
β βββ social_caption_generator.py # Platform-specific captions
β βββ seo_optimizer.py # SEO metadata optimization
β βββ batch_processor.py # Parallel batch processing
β βββ rate_limiter.py # IP-based rate limiting
βββ middleware/
β βββ __init__.py
β βββ rate_limit_middleware.py # Rate limit enforcement
β βββ security_headers.py # CSP, X-Frame-Options, etc.
β βββ request_size_limit.py # Body size enforcement
βββ utils/
β βββ __init__.py
β βββ security.py # File validation, input sanitization
β βββ executor.py # Thread pool for AI operations
βββ frontend/ # Next.js 14 frontend
β βββ app/
β β βββ page.tsx # Home
β β βββ single/page.tsx # Single image upload
β β βββ batch/page.tsx # Batch upload with progress
β βββ package.json
βββ static/
β βββ index.html # Legacy web interface
βββ uploads/ # Temporary upload directory
βββ batch_results/ # Persisted batch results
βββ config.py # Settings via environment variables
βββ main.py # FastAPI application entry point
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ Dockerfile
βββ docker-compose.yml
βββ SECURITY_FIXES.md # Security audit report
βββ RATE_LIMITS.md # Rate limit documentation
βββ README.md
All settings are configured via environment variables (see .env.example):
# Server
API_HOST=127.0.0.1
API_PORT=8000
DEBUG=False
# AI Models
USE_MOONDREAM=True
MOONDREAM_API_KEY= # Optional cloud API
ANTHROPIC_API_KEY= # Optional Claude captions
USE_CLAUDE_API=False
# Security
ADMIN_API_KEY=<generate-a-random-key>
ALLOWED_ORIGINS=http://localhost:3000
TRUST_PROXY_HEADERS=False
# Rate Limits
RATE_LIMIT_ENABLED=True
REQUESTS_PER_MINUTE=10
REQUESTS_PER_HOUR=100
REQUESTS_PER_DAY=500
IMAGES_PER_DAY=1000
BATCH_LIMIT=50Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
pytest) - Submit a pull request
- Batch processing with parallel execution
- Moondream Cloud + Local GPU support
- Production security hardening
- Next.js frontend with drag-and-drop
- Rate limiting with persistent storage
- Multiple language support
- Custom model fine-tuning
- E-commerce platform integrations (Shopify, WooCommerce)
- Advanced analytics dashboard
- A/B testing for captions
- Brand voice customization profiles
- Image editing suggestions
MIT License β see LICENSE for details.
- Issues: GitHub Issues
- Email: support@dynamicweblab.com
Built by DynamicWebLab
