YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
β¬ PixelForge
Transform any photo into stunning pixel art β with AI-powered face detection.
A full-stack platform inspired by Kling AI, built with Python (FastAPI) backend and React frontend. Upload any image and convert it to colored pixel art with smart face awareness (keep faces sharp or pixelate them for privacy).
β¨ Features
| Feature | Description |
|---|---|
| π² Pixel Art Engine | Convert any image to blocky pixel art (2β64px block size) |
| π¨ Color Palettes | Game Boy, NES, Commodore 64, Cyberpunk, Pastel, Auto |
| π€ Face Detection | OpenCV Haar cascade β protect or pixelate detected faces |
| πΌοΈ Drag & Drop Upload | Direct upload from browser |
| β¨ AI Generation | Generate images from text prompt (requires OpenAI API key) |
| π₯ Download | Export final PNG with one click |
| π² Grid Overlay | Optional pixel grid for that authentic retro look |
ποΈ Project Structure
pixelforge/
βββ backend/
β βββ main.py # FastAPI server β all image processing logic
β βββ requirements.txt # Python dependencies
βββ frontend/
β βββ public/index.html
β βββ src/
β βββ index.js
β βββ App.jsx # React UI
βββ .env # Environment variables (DO NOT COMMIT)
βββ .env.example # Template β safe to commit
βββ README.md
π Quick Start
1. Clone / unzip the repo
unzip pixelforge.zip
cd pixelforge
2. Configure environment
cp .env.example .env
# Edit .env with your values (optional: add OPENAI_API_KEY for AI generation)
3. Start the Python backend
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.py
# Server runs at http://localhost:8000
4. Start the React frontend
cd frontend
npm install
npm start
# App opens at http://localhost:3000
βοΈ Environment Variables
| Variable | Default | Description |
|---|---|---|
HOST |
0.0.0.0 |
Backend host |
PORT |
8000 |
Backend port |
DEBUG |
False |
Reload on code change |
UPLOAD_DIR |
uploads |
Where uploads are temporarily stored |
OUTPUT_DIR |
outputs |
Where processed images are saved |
MAX_FILE_SIZE_MB |
20 |
Max upload size |
DEFAULT_PIXEL_SIZE |
16 |
Default block size |
OPENAI_API_KEY |
(optional) | Enables AI prompt β image β pixel pipeline |
STABILITY_API_KEY |
(optional) | Alternative: Stability AI generation |
SECRET_KEY |
β | Change before deploying to production |
π¨ Pixel Art Pipeline
Original Image
β
βΌ
Color Quantization β reduces palette to N colors
β
βΌ
Pixelation β downscale + upscale (nearest neighbor)
β
βΌ
Face Detection β OpenCV Haar cascade
β
ββ protect_faces=True β restore sharp face region
ββ protect_faces=False β apply heavier pixelation to faces
β
βΌ
Palette Mapping β (optional) snap to preset palette
β
βΌ
Grid Overlay β (optional) draw pixel grid lines
β
βΌ
Output PNG
π API Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/ |
Health check |
GET |
/palettes |
List available palette names |
POST |
/upload |
Upload image file β base64 |
POST |
/process |
Pixelate a base64 image |
POST |
/generate-prompt |
Text β AI image β pixelate |
GET |
/outputs/{filename} |
Download processed image |
/process Request Body
{
"image_b64": "data:image/png;base64,...",
"pixel_size": 16,
"num_colors": 16,
"protect_faces": true,
"face_pixel_size": 8,
"add_grid": false,
"palette": "nes"
}
π οΈ Tech Stack
- Backend: Python 3.10+, FastAPI, Uvicorn, Pillow, OpenCV, NumPy
- Frontend: React 18, plain CSS-in-JS (no extra deps)
- AI (optional): OpenAI DALL-E 3 via
openaiSDK
π License
MIT β use freely, attribution appreciated.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support