This project provides a FastAPI-based web service that uses the FLUX.1 model to generate images from text prompts. The service is built on the modal.com.
To install the project, clone the repository and install the dependencies:
git clone git@github.com:FelippeChemello/modal_flux.1.git
cd modal_flux.1
pip install -r requirements.txtTo use the service, you need to have a modal.com and run the following command to set up modal.com CLI:
modal setupon modal.com create a secret called flux.1-secret and set the value of API_KEY to a random string that will be used to authenticate the requests, also you need to create a secret called HF_TOKEN and set the value of your Hugging Face token.
You can create a Hugging Face token by going to your Hugging Face account settings and generating a new token with the read scope.
To run the service in development mode, use the following command:
modal serve app.pyTo deploy the service, use the following command:
modal deploy app.py --name flux1When deployed, modal.com will provide a URL for the service. The service has a single endpoint that accepts GET requests:
GET /?prompt=<text>&width=<width>&height=<height>
x-api-key: <API_KEY>
The prompt parameter is the text prompt that will be used to generate the image. The width and height parameters are the dimensions of the image. The X-API-KEY header must be set to the value of the API_KEY secret created in modal.com.
The response will be a PNG image generated by the FLUX.1 model.