File size: 1,501 Bytes
8247a04 |
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 |
# 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)
|