| title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned |
|---|---|---|---|---|---|---|---|
Loomi Clothing Detection API |
🏢 |
indigo |
red |
docker |
1.0.0 |
main.py |
false |
AI-powered clothing analysis and segmentation API, optimized for Hugging Face Spaces.
This is currently a demo version on Hugging Face Spaces with limitations:
- Sequential processing - Multiple requests are accepted but queue up and wait for the model to finish the previous request
- If you see "offline" status → wait until current request completes
- Requests will be processed in order - your request will be queued and processed when ready
- For production use → deploy to your own server with higher concurrency
- 🧠 AI-Powered: Uses Segformer model for clothing detection
- 🖼️ Image Processing: Background removal and dominant color detection
- ⚡ Fast: Optimized for single-request processing with automatic caching
- 🔧 HF Optimized: Built specifically for Hugging Face Spaces
- 📱 Smart Compression: WebP format with PNG fallback for optimal file sizes
- 🎯 Efficient Workflow: Two-step process for maximum performance
GET /- API overview and documentationGET /health- System health and statusGET /performance- Performance statistics and cache infoPOST /detect- Detect clothing types with segmentation dataPOST /analyze- Analyze clothing using segmentation data (fast, no re-upload)
import requests
# Step 1: Upload image for clothing detection
with open('image.jpg', 'rb') as f:
response = requests.post(
'https://your-hf-space.hf.space/detect',
files={'file': f}
)
result = response.json()
print(result)
# Step 2: Analyze using segmentation data (much faster!)
analyze_response = requests.post(
'https://your-hf-space.hf.space/analyze',
json={
'segmentation_data': result['segmentation_data'],
'selected_clothing': 'shirt' # Optional: specify clothing type
}
)
analysis = analyze_response.json()
print(analysis)- FastAPI: Modern, fast web framework
- Efficient Processing: Optimized for single requests with smart caching
- Model Management: Efficient ML model loading
- Automatic Caching: Smart caching for repeated images and segmentation data
- Image Optimization: WebP compression with PNG fallback for optimal file sizes
The API automatically detects Hugging Face Spaces and applies optimizations:
- Single worker process
- Optimized cache sizes
- HF-specific environment variables
- Smart image compression (WebP/PNG)
Perfect for:
- Mobile apps (React Native, Flutter)
- Web applications
- E-commerce platforms
- Fashion analysis tools
# Simple startup
python run.py
# Or with uvicorn directly
uvicorn main:app --host 0.0.0.0 --port 7860- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Segformer B2 for Clothing Segmentation -
mattmdjaga/segformer_b2_clothes- Pre-trained model specifically designed for clothing and fashion item detection
- Based on the Segformer architecture for semantic segmentation
- Transformers (Hugging Face) - Apache 2.0 License
- PyTorch - BSD License
- Segformer - MIT License
- Rembg - MIT License (background removal)
- FastAPI - MIT License
- Pillow (PIL) - HPND License
- NumPy - BSD License
- scikit-learn - BSD License
The model can detect and segment 18 different categories:
- Background, Hat, Hair, Sunglasses, Upper-clothes, Skirt, Pants, Dress, Belt
- Left/Right-shoe, Face, Left/Right-leg, Left/Right-arm, Bag, Scarf
- WebP Format: Primary format with excellent compression (70-85% smaller than PNG)
- PNG Fallback: Optimized PNG with maximum compression for compatibility
- Smart Resizing: Automatic optimization for large images
- Quality Preserved: Visual quality maintained while reducing file sizes
This project is licensed under the MIT License - see the LICENSE file for details.
Note: While this project is MIT licensed, it uses pre-trained models and libraries with their own licenses. Please ensure compliance with all respective licenses when using this API.
Made with ❤️ by the Loomi Team
AI-powered clothing analysis, simplified and ready! 🎯