banner
寸雨逢叶

寸雨逢叶

🌑 那黑的终点可有光 ✨ 🌃 那夜的尽头可会亮 🌟

Deploying Stable Diffusion WebUI on Colab Cloud

Introduction#

For friends who want to experience AI drawing, they often retreat due to complicated installation steps, insufficient computer configuration, and other issues ☹️
Fortunately, Google provides the Colab service, which allows us to execute Stable Diffusion WebUI on it and experience the fun of AI drawing 🥳

  • Colaboratory, abbreviated as "Colab," is a product developed by the Google Research team. In Colab, anyone can write and execute any Python code through a browser. It is particularly suitable for machine learning, data analysis, and educational purposes. Technically, Colab is a hosted Jupyter notebook service. It can be used directly as long as you can access Google and have a Google account, and it also provides free GPU/CPU computing resources.
  • Stable diffusion web UI is an AI-based image generation tool that uses an algorithm model called "stable diffusion" for image generation. Users can generate new images by applying different operations and parameters in the stable diffusion network using their own uploaded images or preset images. Stable diffusion web UI provides an easy-to-use web interface where users can easily adjust parameters, browse generated images, and export them. This tool can be used in various fields such as image generation, art creation, and image processing.

In summary, we can use Colab to freely use Stable Diffusion WebUI, enjoying the benefits of free usage 😊

About Cloud Deployment#

  • Please make sure you have tools for magic internet access, which are used for Google Colab machine learning and are within the legal scope.
  • Advantages: No need for a graphics card, can be used on mobile phones, and fast cloud execution speed (provides 12GB memory, 15GB graphics card).
  • Due to the large number of people, the time for each Google Colab account is about 4-6 hours. You can create multiple accounts and give them editing permissions in the main account's JSON file in Google Drive to achieve shared usage.
  • The notebook is single-threaded and cannot execute two tasks simultaneously.
  • During peak hours, when there are many people, it is normal to encounter connection errors or disconnections. You can try using the ngrok tunnel for acceleration.
  • You can associate Google Drive, and choose to output images in the "outputs" folder in Google Drive.

If one day Colab displays a warning message similar to the following:
You may be executing code that is disallowed which may terminate your runtime without warning. Colab prioritizes interactive notebook compute and disallows some types of usage when executing code without compute units as outlined in the FAQ.

Please do not click "Reconnect"!

About Stable-Diffusion-Web-UI#

  • The Google Colab runtime environment has 12GB memory and 15GB graphics memory. Due to the large graphics memory and small memory, it is recommended to use half-precision for calculations.
  • If the image information reads "not a stable diffusion image," it means that the uploaded image has been compressed. Please choose another image or manually enter the text and seed.
  • The recommended sampling methods are DDIM and DPM++ 2M for high-definition enlargement. For latent variables, bicubic and latent variables nearest neighbor are recommended.
  • The speed of generating images is unrelated to the speed of executing code or internet speed. Even if you are disconnected from the internet for a few minutes, the code will still execute.
  • If you want to draw locally using a mobile phone, please use the Edge browser as Google Chrome is not compatible.
  • For mobile operations, you can choose "anapnoe."

Notes#

The currently popular 📒 is: https://github.com/camenduru/stable-diffusion-webui-colab/tree/community
You can click on the "Readme Page" to view the instructions for each 📒, choose the one you want, and click on the "Open In Colab" icon to execute.

Modified by the author: ennnnny/sd_colab
This version is based on s4afa451dgf415f/colab_stable_diffusion with some modifications made on May 13, 2023:

  1. Added default plugin: infinite-image-browsing, a image browser
  2. Added default plugin: segment-anything, currently popular semantic segmentation, matting, and other tools
  3. Added default plugin: Civitai-Helper, convenient for managing models
  4. Added default plugin: rembg by the UI author, convenient for matting
  5. Added optional theme plugin: kitchen-theme, looks cooler than the original version
  6. Additional potentially useful tools: Keep running on mobile devices (?)
  7. Additional potentially useful tools: Compress and package the outputs directory, then download it
  8. Additional potentially useful tools: XTerm Terminal (command line)

image

Mysterious-Colab Anti-Disconnection Measures#

Sometimes disconnection is due to unstable network, and sometimes it is due to Google's verification mechanism. It is said that the frequency of disconnection can be reduced by automatically clicking. At this time, you can use JavaScript syntax to continuously click and obtain the following code. Press F12 on Google Colab, click on the console in the web page, and paste the following code:

function ClickConnect(){
  console.log("Working");
  document.querySelector("colab-toolbar-button#connect").click();
}
setInterval(ClickConnect,60000)
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.