Spaces:
Runtime error
Runtime error
File size: 6,016 Bytes
c6fda39 f179fb3 667cce7 c6fda39 667cce7 eec294f 667cce7 c6fda39 9edeecd c6fda39 667cce7 f179fb3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
---
title: Pixagram (stable)
emoji: ๐ฎ
colorFrom: purple
colorTo: pink
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: true
license: mit
short_description: Transform any images including portrait into real pixel art!
disable_embedding: false
cross-origin-embedder-policy: cross-origin
cross-origin-opener-policy: cross-origin
cross-origin-resource-policy: cross-origin
---
# ๐ฎ Pixagram Converter
Convert any image into stunning retro game art using advanced AI models!
## Features
- **Custom SDXL Checkpoint**: Uses the "Horizon" model optimized for artistic generation
- **Pixelate VAE**: Custom VAE that creates authentic 8x pixelated retro aesthetic
- **RetroArt LORA**: Style-specific LORA for enhanced retro game art look
- **Face Preservation**: Automatically detects and preserves facial features using InstantID with Antelopev2
- **Depth-Aware**: Uses ControlNet Zoe Depth to maintain realistic depth in the output
- **Aspect Ratio Preservation**: Maintains the original image proportions
## ๐ค Models
All custom models are loaded from the HuggingFace Hub repository: **[primerz/pixagram](https://huggingface.co/primerz/pixagram)**
- **horizon.safetensors**: Custom SDXL checkpoint (~7 GB)
- **retroart.safetensors**: RetroArt LORA (~50 MB)
- **pixelate.safetensors**: Pixelate VAE (~200 MB)
Models are automatically downloaded on first use and cached for subsequent runs.
## ๐ Installation & Setup
### Quick Deployment
This Space automatically loads models from the HuggingFace Hub repository **primerz/pixagram**.
**To deploy your own version:**
1. **Create a new HuggingFace Space**
- Go to https://huggingface.co/new-space
- Choose Gradio SDK
- Select a GPU (T4 or better recommended)
2. **Clone and upload files**
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
# Copy only these files:
# - app.py
# - requirements.txt
# - README.md
git add .
git commit -m "Initial commit"
git push
```
3. **Wait for build**
- The Space will automatically download models from primerz/pixagram
- First build may take 10-15 minutes
- Models are cached after first download
### Using Your Own Models
If you want to use your own custom models:
1. Create a HuggingFace model repository
2. Upload your `.safetensors` files:
- `horizon.safetensors` (SDXL checkpoint)
- `retroart.safetensors` (LORA)
- `pixelate.safetensors` (VAE)
3. Update `MODEL_REPO` in `app.py` to your repository name
## ๐ Usage
### Web Interface
Simply upload an image and click "Generate Retro Art"! The model will:
1. Detect faces (if any) and preserve facial features
2. Analyze depth information from the image
3. Apply the retro art style
4. Maintain aspect ratio while optimizing resolution
### API Usage
The Space exposes a full API. Here's how to use it:
```python
from gradio_client import Client
client = Client("YOUR_USERNAME/YOUR_SPACE_NAME")
result = client.predict(
image="path/to/your/image.jpg",
prompt="retro pixel art game, 16-bit style, vibrant colors",
negative_prompt="blurry, low quality, modern",
steps=30,
guidance_scale=7.5,
controlnet_scale=0.8,
lora_scale=0.85,
api_name="/predict"
)
print(result) # Path to output image
```
### API with cURL
```bash
curl -X POST "https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/api/predict" \
-H "Content-Type: application/json" \
-d '{
"data": [
"base64_encoded_image_or_url",
"retro pixel art game, 16-bit style",
"blurry, low quality",
30,
7.5,
0.8,
0.85
]
}'
```
## โ๏ธ Parameters
- **Prompt**: Describe the retro style you want
- **Negative Prompt**: What to avoid in the generation
- **Inference Steps** (20-50): More steps = better quality but slower
- **Guidance Scale** (1-15): How closely to follow the prompt
- **ControlNet Scale** (0-2): Strength of depth preservation
- **LORA Scale** (0-2): Strength of RetroArt style application
## ๐จ Tips for Best Results
1. **For Portraits**: The system automatically detects faces and enhances preservation
2. **For Scenes**: Use prompts like "retro game background, pixel art environment"
3. **For Characters**: Try "16-bit game character, sprite art, detailed"
4. **Adjust LORA Scale**: Lower (0.5-0.7) for subtle effect, higher (0.9-1.2) for strong retro look
## ๐ Technical Details
- **Base Model**: SDXL with custom "Horizon" checkpoint from primerz/pixagram
- **Model Repository**: [primerz/pixagram](https://huggingface.co/primerz/pixagram)
- **Face Detection**: Antelopev2 (InsightFace)
- **Depth Estimation**: DPT-Hybrid-MIDAS
- **ControlNet**: Zoe Depth SDXL
- **VAE**: Custom 8x pixelation VAE
- **Optimization**: xformers, model offloading, VAE slicing
### Fallback Behavior
If models cannot be downloaded from the Hub:
- **Checkpoint**: Falls back to `stabilityai/stable-diffusion-xl-base-1.0`
- **VAE**: Falls back to `madebyollin/sdxl-vae-fp16-fix`
- **LORA**: Runs without LORA (style will be less retro)
## ๐ Troubleshooting
### "Model download failed"
- Check internet connectivity in Space settings
- Verify the model repository (primerz/pixagram) is public
- Check Space logs for specific error messages
### Out of Memory
- Try reducing image resolution
- Lower inference steps
- Use a larger GPU (A10G or A100)
### Slow Generation
- First generation is always slower (model downloading + loading)
- Consider using a faster GPU tier
- Reduce inference steps to 20-25
### Models not loading
- Check Space logs for download errors
- Verify HuggingFace Hub access
- Ensure GPU is available
## ๐ License
MIT License - Feel free to use and modify!
## ๐ Credits
- SDXL by Stability AI
- ControlNet by Lvmin Zhang
- InsightFace for face analysis
- Diffusers library by HuggingFace
## ๐ค Contributing
Issues and pull requests are welcome!
---
**Note**: This Space requires a GPU. Free tier may experience queuing during high usage.
|