| # Diffusion Models App | |
| A Python application that uses Hugging Face inference endpoints for text-to-image and image-to-image generation with a Gradio UI and API endpoints. | |
| ## Features | |
| - Text-to-image generation | |
| - Image-to-image transformation with optional prompt | |
| - Gradio UI for interactive use | |
| - API endpoints for integration with other applications | |
| - Configurable models via text input | |
| ## Project Structure | |
| - `main.py` - Entry point that can run both UI and API | |
| - `app.py` - Gradio UI implementation | |
| - `api.py` - FastAPI server for API endpoints | |
| - `inference.py` - Core functionality for HF inference | |
| - `config.py` - Configuration and settings | |
| - `requirements.txt` - Dependencies | |
| ## Setup & Usage | |
| 1. Clone the repository | |
| 2. Create a .env file with your Hugging Face token (copy from .env.example) | |
| 3. Install dependencies: `pip install -r requirements.txt` | |
| 4. Run the application: `python main.py` | |
| ## Running Options | |
| - Run both UI and API: `python main.py` | |
| - Run only the API: `python main.py --mode api` | |
| - Run only the UI: `python main.py --mode ui` | |
| ## API Endpoints | |
| - `POST /text-to-image` - Generate an image from text | |
| - `POST /image-to-image` - Transform an image with optional prompt | |
| ## Environment Variables | |
| - `HF_TOKEN` - Your Hugging Face API token | |
| - `API_HOST` - Host for the API server (default: 0.0.0.0) | |
| - `API_PORT` - Port for the API server (default: 8000) | |
| - `GRADIO_HOST` - Host for the Gradio UI (default: 0.0.0.0) | |
| - `GRADIO_PORT` - Port for the Gradio UI (default: 7860) | |