Skip to content

Latest commit

 

History

History
177 lines (100 loc) · 11.3 KB

File metadata and controls

177 lines (100 loc) · 11.3 KB

Lagrange Mars Testnet Base Space

Table of Content

Introduction

Space Link: https://lagrangedao.org/spaces/0x231fe9090f4d45413474BDE53a1a0A3Bd5C0ef03/Stable-Diffusion-Base-LoRA/files

This tutorial guides you on how to complete Task 2: Space Builder Task, to fork and run a Stable Diffusion Space. It covers the deployment of Stable-diffusion in Lagrange Space, adding LoRA models to Automatic1111 for image generation, and further customizing your Space with additional models.

What is Stable Diffusion

Stable Diffusion is a state-of-the-art text-to-image model that generates an image from text.

What is Lagrange Space

Lagrange Space is a simple way to host ML demo apps on Lagrange.

What is LoRA

LoRA (Low-Rank Adaptation) is a training technique for fine-tuning Stable Diffusion models. and LoRA models are specific versions of the Stable Diffusion model that have undergone fine-tuning.

What is Automatic111

Stable Diffusion web UI (AUTOMATIC1111 or A1111 for short) is the de facto GUI for advanced users.

How to Fork the Base Space and Rename it

1. Visit [https://lagrangedao.org/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. Click on the Just Fork, choose config later

In your forked Space, click the Settings button and scroll down to the Rename section to rename your Space.

How to Add More Models

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
RUN wget <model_download_link> -O /stable-diffusion-webui/models/Lora/<your_model_name>
image image

How to Run Your Space

To set up your Stable Diffusion Space for generating images from textual descriptions, you must

  • (1) deploy the Stable Diffusion Web UI, a user-friendly interface that facilitates interaction with the model. Additionally,
  • (2) installing LoRA extensions enhances the Web UI's capabilities, enabling support for LoRA models.
  • (3) installing the actual LoRA models to enable image generation.

Step1: Deploy the Stable Diffusion web UI (Automatic 111)

1. Click on Settings and select your preferred hardware meeting the below requirements:

  • At least one GPU
  • At least 4 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.

Step 2: Install a LoRA Model Into Automatic1111

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.

Step 3: Set Up LoRA Models

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(Click the Model).

For example, if you Click "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.

NOTES

If you have not previously added any models and now wish to include additional ones, please Click on Redeploy after following the steps outlined in How to Add More Models.

Once the redeployment is complete(almost 10 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.

Reference