How to Build Stable Diffusion Space
This tutorial guides you on how to fork and run a Stable Diffusion Space.
Last updated
This tutorial guides you on how to fork and run a Stable Diffusion Space.
Last updated
1. Visit [https://lagrange.computer/spaces] and log in to your account
2. Visit the Stable Diffusion Base Space, and click on the [Fork] button to create a duplicate of the Base Space.
3. You can either click on the [Just Fork, choose config later] or select your preferred hardware, and proceed with the payment.
It's recommended to choose "config later" if you anticipate adding more models to your Space in the future to avoid unnecessary redeployments.
In your forked Space, you can click the [Settings] button and scroll down to the Rename section to rename your Space.
Note: Please note that after you change the Space name, the Space link will also be updated. Make sure to share the new link with others as needed.
If you prefer to utilize the default LoRA models provided by Base Space, you can proceed directly to the section on How to Get Your Space Running.
However, if the available models do not precisely align with your image preferences, you have the option to enhance your Stable Diffusion Space by adding more models by following the below steps.
1. Find models you liked from Civitai and Hugging Face, and get the downloading link of the model.
2. Go to [Files and versions] and Update the Dockerfile, you need to replace the <model_download_link> and <your_model_name>, then add the below command to the Dockerfile:
# Command example:
To set up your Stable Diffusion Space for generating images from textual descriptions, you must
deploy the Stable Diffusion Web UI, a user-friendly interface that facilitates interaction with the model. Additionally,
installing LoRA extensions enhances the Web UI's capabilities, enabling support for LoRA models.
installing the actual LoRA models to enable image generation.
1. Click on [Settings] and select your preferred hardware meeting the below requirements:
At least one GPU
At least 8 vCPUs
Minimum 50GB SSD storage
Minimum 32GB memory
Minimum 50MB bandwidth
Here are the GPUs we recommend:
T4, RTX 4090, 3090Ti, 3090, 3080Ti, 3080, 3060Ti, 2060, 2070, 2080, 2080Ti, A100, H100
Ensure you choose hardware with at least one GPU; without it, Stable Diffusion Space won't function.
And proceed with the payment.
2. After payment confirmation, observe the status tag of your Space. It will transition from "Waiting for Transaction" to "Deploying," and finally to "Running" once the Stable Diffusion web UI is successfully deployed on your Space.
After a few minutes, you can access the Stable Diffusion web UI in the [App] tab of your Space.
*Note: Do not panic if you encounter a "404" or "502" error while accessing the web UI. These errors indicate that the web UI is currently deploying, and the process typically takes around 1-10 minutes to complete.
Before using LoRA models in your Stable Diffusion Web UI, you need to install the LoRA extension.
1. Click on the [App] tab to Launch the Stable Diffusion Web UI in the space.
2. Open the [Extensions] tab, click on [Install from URL], and copy the following link:
https://github.com/kohya-ss/sd-webui-additional-networks.git
And Click the "Install" button.
3. To verify if the installation was successful, switch to the [Installed] tab. and Click on the [Apply and restart UI] button.
4. Open the [Settings] tab and switch to the [Additional Networks] tab, paste stable-diffusion-webui/models/Lora in the input field of [Extra paths to scan for LoRA models] and then click [Apply settings].
Although the LoRA Extension has been installed successfully, it's not enough to start generating images. You need to install your actual LoRA Models to the specified folder as well.
1. Click the [App] tab in your Space to access the launched Stable Diffusion Web UI.
2. Choose your desired checkpoint model from the preloaded options (e.g., "chilloutmix-Ni.safetensors" or "V1-5-pruned-emaononly.safetensors").
3. Click on the [txt2img] tab and select the icon of "Additional Networks" under the "Generate" button, then choose [LoRA].
Several LoRA models will be displayed. Select the one you want to use.
4. Each LoRA model has a "Trigger Word." Ensure your prompts include the specific LoRA's trigger word, which is usually added automatically.
For example, if you choose "KsmRm," it will show <lora:KsmRm:1>.
5. Add the text or description for the image you want to create after the LoRA's trigger words.
Congratulations! An image has been generated from your forked Stable Diffusion Space using a LoRA model.
If you have not previously added any models and now wish to include additional ones, please redeploy your Space through selecting new hardwares after following the steps outlined in How to Add More Models.
Once the redeployment is complete(almost 30 minutes), continue by following the guidance provided in Install LoRA Extensions and Set Up LoRA Models once more to ensure the successful integration of your newly added models and guarantee their effective functioning within your Space.
Special thanks to AUTOMATIC1111 for the support.