Building Space

This is a guide to Space Builder

🗓️ Event Period: 14th August, 00:00 (EST) - 17th September, 23:59 (EST)

Rules

How to participate:

1. Fork a space from the provided Stable Diffusion Base Space and successfully run it.

2. Update your forked Space following the Tutorial.

3. Share your Space on Twitter

4. Submit the form here with the required details, including

  • Link to your Space

  • Link to the tweet you shared

How to Be Eligible:

  • Eligible Space Builders shall build at least one Space that generates at least one image and remains operational for the duration of the event.

  • The form must be submitted upon task completion.

Rewards:

  • All eligible Space Builders have a chance to split the prize pool of 300,000 LAG tokens based on the popularity of the space you build. The more popular your space, the greater your reward!

  • Prizes:

    • Top 1: 20,000 LAG

    • Top 2-5: 10,000 LAG each

    • Top 6-10: 4,000 LAG each

    • Top 11-50: 2,000 LAG each

    • All other participants (rank 51 and beyond) will share the remaining 140,000 LAG pool.

Note: The ranking will be based on the popularity of the space they build.

Tutorial

Table of Content

Introduction

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 Space: 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. 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, 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.

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>

How to Get Your Space Running

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 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.

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.

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.

Note:

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

Last updated