Follow these steps to set up and run the Text-to-Image Generator application:
-
Navigate to the backend directory:
-
Install the required Python packages:
pip install fastapi uvicorn requests Pillow
- Open
main.py
and replaceYOUR_HUGGINGFACE_API_KEY
with your actual Hugging Face API key.
In the backend directory, start the FastAPI server with the following command:
uvicorn main:app --reload
The server will start at http://127.0.0.1:8000
.
-
Navigate to the frontend directory
-
Install dependencies using bun:
bun install
In the frontend directory, start the React application with the following command:
bun dev
The frontend will be available at http://localhost:5173
.
- Open your browser and go to
http://localhost:5173
. - Enter your text prompt in the input field and click "Generate Image".
- The generated image will be displayed below the input form.
- Ensure both the backend and frontend servers are running for the application to function properly.
- If you encounter a timeout issue while generating images, consider increasing the timeout in the
main.py
file.