|
| 1 | +# UV Setup for Stable Diffusion WebUI |
| 2 | + |
| 3 | +## ✅ Setup Complete! |
| 4 | + |
| 5 | +UV has been successfully configured for Stable Diffusion WebUI with Python 3.10.6. |
| 6 | + |
| 7 | +## 🚀 Quick Start |
| 8 | + |
| 9 | +### 1. Start the WebUI with API (Simplified!) |
| 10 | +```bash |
| 11 | +cd /Users/bost/git/stable-diffusion-webui |
| 12 | +./start-with-uv.sh |
| 13 | +``` |
| 14 | + |
| 15 | +**Note**: The first run will automatically: |
| 16 | +- Download the default Stable Diffusion model (~4GB) |
| 17 | +- Install any missing dependencies |
| 18 | +- Set up the API endpoints |
| 19 | + |
| 20 | +### 2. Test the API |
| 21 | +```bash |
| 22 | +# In a new terminal |
| 23 | +uv run python test-api.py |
| 24 | +``` |
| 25 | + |
| 26 | +### 3. Use with your Rust tool |
| 27 | +Update your `.env` file in the Rust project: |
| 28 | +```bash |
| 29 | +AI_API_KEY=not_required_for_local |
| 30 | +AI_API_ENDPOINT=http://localhost:7860/sdapi/v1/txt2img |
| 31 | +AI_MODEL=stable-diffusion-v1-5 |
| 32 | +``` |
| 33 | + |
| 34 | +## 📋 What Was Set Up |
| 35 | + |
| 36 | +### Files Created/Modified: |
| 37 | +- ✅ `.python-version` → Forces Python 3.10.6 |
| 38 | +- ✅ `pyproject.toml` → Updated for UV compatibility |
| 39 | +- ✅ `start-with-uv.sh` → UV-powered startup script |
| 40 | +- ✅ `test-api.py` → API connectivity test |
| 41 | +- ✅ `.venv/` → Virtual environment with all dependencies |
| 42 | + |
| 43 | +### Dependencies Installed: |
| 44 | +- 🐍 Python 3.10.6 (exactly as required) |
| 45 | +- 🎨 All Stable Diffusion WebUI requirements |
| 46 | +- 🚀 Optimized for food image generation |
| 47 | + |
| 48 | +## 🔧 Available Commands |
| 49 | + |
| 50 | +### Start WebUI |
| 51 | +```bash |
| 52 | +./start-with-uv.sh |
| 53 | +``` |
| 54 | + |
| 55 | +### Test API |
| 56 | +```bash |
| 57 | +uv run python test-api.py |
| 58 | +``` |
| 59 | + |
| 60 | +### Run any Python command |
| 61 | +```bash |
| 62 | +uv run python <your-script.py> |
| 63 | +``` |
| 64 | + |
| 65 | +### Install additional packages |
| 66 | +```bash |
| 67 | +uv add <package-name> |
| 68 | +``` |
| 69 | + |
| 70 | +### Check Python version |
| 71 | +```bash |
| 72 | +uv run python --version |
| 73 | +``` |
| 74 | + |
| 75 | +## 🌐 API Endpoints |
| 76 | + |
| 77 | +Once running, these will be available: |
| 78 | + |
| 79 | +- **WebUI Interface**: http://localhost:7860 |
| 80 | +- **API Documentation**: http://localhost:7860/docs |
| 81 | +- **Text-to-Image API**: http://localhost:7860/sdapi/v1/txt2img |
| 82 | +- **API Options**: http://localhost:7860/sdapi/v1/options |
| 83 | + |
| 84 | +## 🎯 Integration with Rust Tool |
| 85 | + |
| 86 | +Your Rust food image generation tool is now ready to connect! The API endpoint configuration is: |
| 87 | + |
| 88 | +```bash |
| 89 | +# In your Rust project's .env file: |
| 90 | +AI_API_KEY=not_required_for_local |
| 91 | +AI_API_ENDPOINT=http://localhost:7860/sdapi/v1/txt2img |
| 92 | +AI_MODEL=stable-diffusion-v1-5 |
| 93 | +AI_TIMEOUT_SECONDS=120 |
| 94 | +AI_MAX_RETRIES=3 |
| 95 | +AI_RETRY_DELAY_MS=2000 |
| 96 | +``` |
| 97 | + |
| 98 | +## 🐛 Troubleshooting |
| 99 | + |
| 100 | +### If the WebUI won't start: |
| 101 | +```bash |
| 102 | +# Check Python version |
| 103 | +uv run python --version # Should show 3.10.6 |
| 104 | + |
| 105 | +# Reinstall dependencies |
| 106 | +uv sync --reinstall |
| 107 | + |
| 108 | +# Check for errors |
| 109 | +./start-with-uv.sh |
| 110 | +``` |
| 111 | + |
| 112 | +### If API calls fail: |
| 113 | +```bash |
| 114 | +# Test connectivity |
| 115 | +curl http://localhost:7860/sdapi/v1/options |
| 116 | + |
| 117 | +# Run the test script |
| 118 | +uv run python test-api.py |
| 119 | +``` |
| 120 | + |
| 121 | +### If images are poor quality: |
| 122 | +1. Download better models to `models/Stable-diffusion/` |
| 123 | +2. Adjust the prompt templates in your Rust code |
| 124 | +3. Increase the `steps` parameter (30-50 for better quality) |
| 125 | + |
| 126 | +## 📦 Model Management |
| 127 | + |
| 128 | +### Download recommended models: |
| 129 | +```bash |
| 130 | +cd models/Stable-diffusion/ |
| 131 | + |
| 132 | +# For general use (good for food): |
| 133 | +wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors |
| 134 | + |
| 135 | +# For photorealistic food: |
| 136 | +wget https://civitai.com/api/download/models/130072 -O realistic-vision-v5.safetensors |
| 137 | +``` |
| 138 | + |
| 139 | +## 🔥 Performance Tips |
| 140 | + |
| 141 | +### For faster generation: |
| 142 | +- Use `--xformers` in the startup script (if installed) |
| 143 | +- Reduce image size to 512x512 for testing |
| 144 | +- Use fewer steps (20-30) for development |
| 145 | + |
| 146 | +### For better quality: |
| 147 | +- Use higher resolution (1024x1024) |
| 148 | +- More steps (30-50) |
| 149 | +- Better models (see model recommendations above) |
| 150 | + |
| 151 | +## ✨ Success Indicators |
| 152 | + |
| 153 | +You'll know everything is working when: |
| 154 | + |
| 155 | +1. ✅ `./start-with-uv.sh` starts without errors |
| 156 | +2. ✅ WebUI loads at http://localhost:7860 |
| 157 | +3. ✅ `uv run python test-api.py` generates a test image |
| 158 | +4. ✅ Your Rust tool can connect and generate food images |
| 159 | + |
| 160 | +## 🎉 Next Steps |
| 161 | + |
| 162 | +1. **Test the setup**: Run `./start-with-uv.sh` and `uv run python test-api.py` |
| 163 | +2. **Update your Rust tool**: Set the API endpoint in your `.env` file |
| 164 | +3. **Generate test images**: Use your Rust tool with the sample CSV |
| 165 | +4. **Download better models**: For higher quality food images |
| 166 | +5. **Optimize prompts**: Tweak the food-specific prompts in your Rust code |
| 167 | + |
| 168 | +Your local AI food image generation pipeline is now ready! 🍕🥗🍗 |
0 commit comments