The simplest way to get started with Stable Diffusion on Ubuntu

这篇具有很好参考价值的文章主要介绍了The simplest way to get started with Stable Diffusion on Ubuntu。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

link1

link2

Stable Diffusion is a machine learning model that can generate images from natural language descriptions. Because it’s open source, it’s also easy to run it locally, which makes it very convenient to experiment with in your own time. The simplest and best way of running Stable Diffusion is through the Dream Script Stable Diffusion fork, which comes with some convenience functions.

Setup

Install Anaconda

Download the Anaconda installer script from their website and install it. The download URL may change over time, so replace it.:

wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
chmod +x Anaconda3-2022.05-Linux-x86_64.sh
# Install Anaconda without prompts
./Anaconda3-2022.05-Linux-x86_64.sh -b

Once installation is finished, initialise conda, but tell it not to activate each time the shell starts.

~/anaconda3/bin/conda config --set auto_activate_base false
~/anaconda3/bin/conda init

Get the model file

The model file needed by Stable Diffusion is hosted on Hugging Face. You will need to register with any email address. Once registered, head to the latest model repository, which at the time of writing is stable-diffusion-v-1-4-original. Under the ‘files and versions’ tab, download the checkpoint file, sd-v1-4.ckpt.

Get the Dream Script Stable Diffusion repository

The Dream Script Stable Diffusion repo is a fork of Stable Diffusion, it comes with some convenience functions to accept a text prompt, as well as a web interface.

git clone https://github.com/lstein/stable-diffusion.git
cd stable-diffusion

Next, move the model file downloaded previously, into this repo, renaming it to model.ckpt

mkdir -p models/ldm/stable-diffusion-v1/
mv ~/Downloads/sd-v1-4.ckpt models/ldm/stable-diffusion-v1/model.ckpt

Create the conda environment

While still in the Stable Diffusion repo, create the conda environment in which the scripts will run.

conda env create -f environment.yaml

The first time this step runs, it will take a long time, due to the numerous dependencies involved.

Run Stable Diffusion

Once the setup is done, these are the steps to run Stable Diffusion. Activate the conda environment, preload models, and run the dream script.

conda activate ldm
python scripts/preload_models.py
python scripts/dream.py

A prompt will appear where you can enter some natural language text.

* Initialization done! Awaiting your command (-h for help, 'q' to quit)
dream>

As an example, try

dream> photograph of highly detailed closeup of victoria sponge cake

Wait a few seconds, and an image gets generated in the outputs/img-sample folder.

Example

Conveniently, a dream_log.txt file shows you all the prompts you’ve run in case you want to refer back to something. Against each line, you will also see a seed number that looks something like this: -S2420237860. This allows you to regenerate the exact same image by specifying the seed with your text prompt.

dream> photograph of highly detailed closeup of victoria sponge cake -S2420237860

Using an image as a source

You can also use a crude image as a source for the prompt with the --init_img flag.

dream> mountains and river, Artstation, Golden Hour, Sunlight, detailed, elegant, ornate, rocky mountains, Illustration, by Weta Digital, Painting, Saturated, Sun rays  --init_img=/home/mendhak/Desktop/rough_drawing.png

You can take the output from one step and re-feed it as the input again, and come up with some interesting results.

Mountains and river, output re-fed multiple times

Generating larger images

By default the output is 512x512 pixels. There is a separate module you can use to upscale the output, called Real-ESRGAN.
It’s really simple to install, while in the conda ldm environment, run:

pip install realesrgan

After it’s installed, go back into the dream script, generate an image, and this time add the -U flag at the end of the prompt (either 2 or 4)

dream> butterfly -U 4

Face restoration

The module for face restoration is called GFPGAN. Follow its installation instructions here, clone the GFPGAN directory alongside the stable-diffusion directory. And be sure to download the pre-trained model as shown. You can then use the -G flag as shown in the Dream Script Stable Diffusion repo.

Notes and further reading

Type --help at the dream> prompt to see a list of options. You can use flags like -n5 to generate multiple images, -s for number of steps, and -g to generate a grid.

More details, including how to use an image as a starting prompt, can be found in the README.

Prompts

If you’re like me, you will need ideas for prompts. The best place to start, I’ve found, the Lexica.art site. Find something interesting, and copy the prompt used, then try modifying it.文章来源地址https://www.toymoban.com/news/detail-498745.html

到了这里,关于The simplest way to get started with Stable Diffusion on Ubuntu的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz‘ failed with error: Get “http://loc

    问题: 初始化K8S master时报错 问题分析: 之前我的Docker是用yum安装的,docker的cgroup驱动程序默认设置为systemd。默认情况下Kubernetes cgroup为system,我们需要更改Docker cgroup驱动, 解决方法

    2024年02月11日
    浏览(59)
  • Getting started with Java

    : 是Java中被赋予特殊意义的单词, 例如: class 定义了一个模块, 它的代码形式如下: 在class后面紧跟着类名, 类名后的大括号中是类实现的方法 字面量: 数据在程序中的书写格式 字面量类型 说明 举例 整数类型 不带小数点的数字 666, -88 小数类型 带小数点的数字

    2024年04月26日
    浏览(30)
  • Python Project Getting started with Django

    As the internet has evolved , the line between website and mobile apps has blurred. we can use Django to build a single project that serves a dynamic website as well as a set of mobile apps. Django is Python\\\'s most popular web framework, a set of tools designed for building interactive web applications. We will learn how to use Django to build a project call

    2024年04月25日
    浏览(35)
  • 【SpringBoot项目】Tomcat started on port(s): 8080 (http) with context path ‘‘

    运行程序后出现下面的错误,并且在postman中无法获取到数据 在idea中的错误显示的如下   如果你不是以下原因可以参考下面的文章: Initializing Servlet ‘dispatcherServlet‘最全问题解决方法_wjh2580的博客-CSDN博客 

    2024年02月16日
    浏览(36)
  • Error encountered when following the spring boot getting started document.

    https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started Follow the instructions on the document, create exactly the file src/main/java/MyApplication.java with a default package (without a package ), paste exactly the code. Then I found that there’s a complain from my IDE, said “Spring Boot Application in defaul

    2024年02月02日
    浏览(41)
  • 《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks)

    《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks) Before we discuss the essentials of Jupyter notebooks, let us discuss what an integrated development environment (or IDE) is. An IDE brings together the various activities involved in programming, like including writing and editing code, debugging, and crea

    2024年01月20日
    浏览(40)
  • ORACLE 11.2.0.4 RAC Cluster not starting cssd with Cannot get GPnP profile

          最近,处理一次oracle 11.2.0.4 rac cluster由于cssd无法启动,导致集群一个节点的CRS集群无法正常启动的故障。原本,计划变更是从ASM剔除磁盘,解除存储到数据库服务器的映射;磁盘已经成功从ASM剔除,也已经成功从存储解除到操作系统的映射,为了验证磁盘剔除是否对集

    2024年02月09日
    浏览(36)
  • Failed to start: app/proxyman/inbound: failed to listen TCP on 10808

    启动 v2xxx-With-Core 失败,报错信息如下: 1. 分析端口占用问题 分析结果 :未查询到端口被占用 2. 分析端口是否被禁用 查看禁用端口 分析 端口 10808 确实在禁用端口范围内 既然分析到问题的原因是端口被系统禁用,那么解决方案可以分为两种。 修改当前应用的启动端口(修

    2024年02月04日
    浏览(52)
  • ubuntu22.04@laptop OpenCV Get Started: 015_deep_learning_with_opencv_dnn_module

    计算机视觉领域自20世纪60年代末以来就存在。图像分类和物体检测是计算机视觉中一些最古老的问题,研究人员尝试解决这些问题已经数十年。 目前,使用神经网络和深度学习,已经达到了一个阶段,计算机可以开始以高精度实际理解和识别对象,甚至在许多情况下超过人

    2024年02月20日
    浏览(43)
  • Unable to start the daemon process.解决方案

     错误信息如下: Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html Process command line: D:Javajdk-1.8binjava.exe -Xmx2048m -Dfil

    2024年02月14日
    浏览(73)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包