This repo contains demo for generating image based on user prompt. It runs model locally for the sake of PoC and is not suitable for production. Require NVIDIA GPU to run.
- Implement quantized Stable Diffusion 3.5.
- Implement quantized Flux.1 Schnell.
- Implement factory pattern to handle models.
- Add model switching feature.
- Implement NiceGUI ui.storage to store session states.
- Better code modularization.
- Add brush and inpainting features.
- Add models outputs comparison feature.
- Use javascript for brush to bring the feature to client side.
- To explore Auto1111sdk. (Dec 27, 2024: Only support Stable Diffusion as of the date, so won't implement soon.)
- Install Conda
- Create environment:
conda create -n sd python=3.11
- Activate environment:
conda activate sd
- Install Pytorch
- Install the required libraries:
pip install -r requirements.txt
- Follow this to create access token.
- Visit the following links to register:
- In terminal, after activating
sd
environment, typehuggingface-cli login
and key in the created access token to login.
- Run the following command:
python src/main.py
- Open the Local URL (default: http://localhost:8080/) in a browser.
- Select "Flux.1" in the top dropdown list and click "INITIALIZE T2I MODEL" button to load the text to image model.
- Describe what you want to draw in the text box.
- Click "DRAW" button and wait for the image to be generated.
- If modification is desired, select "Stable Diffusion 2 Inpaint" in the bottom dropdown list and click "INITIALIZE FILL MODEL" button to load inpainting model.
- Brush the image to mask the area you want to modify.
- Describe what to add to the area in the text box.
- Click "FILL" to apply the modification.
Quantized Stable Diffusion 3.5 Large Turbo (StabilityAI) | Stable Diffusion 3.5 Medium Turbo (TensorArt) | Quantized Flux.1 Schnell (Black Forest Labs) |
Original Image generated by Quantized Stable Diffusion 3.5 Large Turbo | Brush the image with a mask on the canvas directly | Fill a spaceship to the region with Stable Diffusion 2 Inpainting |