The simplest way to get started with Stable Diffusion on Ubuntu

news2024/9/20 19:39:45

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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/384094.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

万字长文漫谈高可用高并发技术

互联网应用通常面向海量用户,其后台系统必须支撑高并发请求。在后端开发面试中,高并发技术也是一个常见的考察点。 那么,高并发系统通常是怎么设计的呢?需要采用哪些技术呢?本文就简单聊一聊高并发背后的各种技术栈。…

蓝桥杯任意刷

这里写目录标题受伤的皇后全球变暖&#xff08;最大联通子集&#xff0c;一趟递归记得不要嵌套计数&#xff09;游园问题金额查错蓝肽子序列&#xff08;最长公共子序列&#xff09;受伤的皇后 #include <iostream> #include <bits/stdc.h> using namespace std; …

运动带什么蓝牙耳机好,最适合运动佩戴的蓝牙耳机分享

运动时汗如雨下&#xff01;这可如何是好&#xff0c;这时候一款运动专用的防水耳机就成为人们的最爱。现在&#xff0c;市面上的耳机种类已经多到数不胜数。价格也不一&#xff0c;到底是一分钱一分货&#xff0c;还是打着低价卖你一个小型音响。到底怎么挑才能找到一款性价比…

联邦学习(fate)从主机安装到实现联邦学习

联邦学习&#xff08;fate&#xff09;从主机安装到实现联邦学习一、单机部署1.1虚拟机配置1.2安装python1.3端口检查1.4获取安装包&#xff0c;并解压1.5安装1.6启动1.7测试1.8安装FATE-Client、FATE-Test、FATE-Flow、jupyter notebook1.8.1FATE-Client、FATE-Test1.8.2FATE-…

Newman+Jenkins实现接口自动化测试

一、是什么Newman Newman就是纽曼手机这个经典牌子&#xff0c;哈哈&#xff0c;开玩笑啦。。。别当真&#xff0c;简单地说Newman就是命令行版的Postman&#xff0c;查看官网地址。 Newman可以使用Postman导出的collection文件直接在命令行运行&#xff0c;把Postman界面化运…

【C++】stack 与 queue

stack 与 queuestackSTL 容器中 stack 的使用模拟实现 stackqueueSTL 容器中 queue 的使用模拟实现 queuestack 在数据结构中&#xff0c;我们了解到&#xff0c;stack 栈结构&#xff0c;是一种先进后出的结构&#xff0c;并且我们是使用顺序表来进行实现栈的操作的。 STL 容…

如何使用FindFunc在IDA Pro中寻找包含指定代码模式的函数代码

关于FindFunc FindFunc是一款功能强大的IDA Pro插件&#xff0c;可以帮助广大研究人员轻松查找包含了特定程序集、代码字节模式、特定命名、字符串或符合其他各种约束条件的代码函数。简而言之&#xff0c;FindFunc的主要目的就是在二进制文件中寻找已知函数。 使用规则过滤 …

C++回顾(六)—— 对象动态建立

6.1 new 和 delete 用法 6.1.1 概述 在软件开发过程中&#xff0c;常常需要动态地分配和撤销内存空间&#xff0c;例如对动态链表中结点的插入与删除。在C语言中是利用库函数malloc和free来分配和撤销内存空间的。C提供了较简便而功能较强的运算符new和delete来取代malloc和f…

smart-doc Java Restful API 文档生成工具

smart-doc简介 官方地址smart-doc smart-doc 是一款同时支持 JAVA REST API 和 Apache Dubbo RPC 接口文档生成的工具&#xff0c;smart-doc 在业内率先提出基于 JAVA 泛型定义推导的理念&#xff0c; 完全基于接口源码来分析生成接口文档&#xff0c;不采用任何注解侵入到业…

vue基础学习笔记

1.v-text 设置标签的文本值&#xff0c;将标签内的内容完全替换为v-text绑定的值。 如果想要保留标签内的值&#xff0c;可以采用差值表达式的方式&#xff08;<h2>text{{message}}</h2>&#xff09; 内部值支持拼接 <!DOCTYPE html> <html lang"en…

Unity Asset Bundle学习 - 加载网络资源

昨天调试了一下加载本地资源 Unity Asset Bundle学习 - 加载本地资源 今天试一下用Asset Bundle加载网络数据 接着按照文档走 发现 有问题 引用命名空间一直报错 按文档走不通 就直接百度查了 查了好多 这个东西有很多前辈的经验 直接拷贝代码拿过来用的 下面这段是测试没问题…

技术分享 | OceanBase 集群扩容缩容

作者&#xff1a;杨文 DBA&#xff0c;负责客户项目的需求与维护&#xff0c;会点数据库&#xff0c;不限于MySQL、Redis、Cassandra、GreenPlum、ClickHouse、Elastic、TDSQL等等。 本文来源&#xff1a;原创投稿 *爱可生开源社区出品&#xff0c;原创内容未经授权不得随意使用…

面试官:为什么说ArrayList线程不安全?

本博客知识点收录于&#xff1a;⭐️《JavaSE系列教程》⭐️ 1&#xff09;线程安全与不安全集合 我们学习集合的时候发现集合存在由线程安全集合和线程不安全集合&#xff1b;线程安全效率低&#xff0c;安全性高&#xff1b;反之&#xff0c;线程不安全效率高&#xff0c;安…

Yuga Labs发布“TwelveFold“进军BTC,新大陆的探索即将开启

Yuga Labs 正在将新的 NFT 引入比特币区块链&#xff0c;并于 2 月 28 日推出了一个名为 TwelveFold 的系列。该系列是比特币网络上“刻在 satoshis 上”的 300 个生成作品的限量版。据官方说明&#xff0c;TwelveFold将限量发行三百幅的生成式NFT 画作&#xff0c;每件NFT 作品…

AcWing3696. 构造有向无环图

先看题&#xff1a; 首先来看一下题目的要求&#xff1a;利用给定的边来构造一个有向无环图。 那么什么是有向无环图呢&#xff1f;我们来搜索一番&#xff1a;"所谓有向无环图其实就是&#xff1a;有方向的边&#xff1b;这些边在一个图中不会构成一个闭合的环路。"…

学习大数据应该掌握哪些技能

想要了解大数据开发需要掌握哪些技术&#xff0c;不妨先一起来了解一下大数据开发到底是做什么的~ 1、什么是大数据&#xff1f; 关于大数据的解释&#xff0c;比较官方的定义是指无法在一定时间范围内用常规软件工具进行捕捉、管理和处理的数据集合&#xff0c;是需要新处理模…

C++STL详解(四)—— vector模拟实现

文章目录vector内置成员变量默认成员函数初始化列表构造迭代器区间构造函数赋个数赋值构造函数赋值构造的相关问题拷贝构造函数赋值运算符重载函数析构函数迭代器及迭代器相关函数begin和end范围for容量与扩容相关函数size和capacityreserveresizeemptyvector中的增删查改&…

「攻略手册」:ShardingSphere 与 Java 应用性能优化

笔者曾经写过一篇文章&#xff0c;介绍 ShardingSphere 在具体代码细节上的优化案例&#xff0c;但文章中没有介绍如何发现代码优化点。本文将结合之前笔者在 ShardingSphere 相关性能问题排查、优化经验&#xff0c;简要地介绍 ShardingSphere 性能问题排查、优化应如何入手。…

解决Sql WorkBench中数据库不能重命名的问题

解决Sql WorkBench中数据库不能重命名的问题mysql不支持直接重命名数据库1. 连接到数据库2. 打开菜单&#xff0c;选择迁移向导3. 点击Start Migration4. 填写源数据库的相应参数5. 填写目标数据库的响应参数6. 稍等片刻&#xff0c;点击Next7. 选择你要迁移的数据库。8. 进入一…

B站依然面临巨大风险,盈利之路可能会更加艰难

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 哔哩哔哩(BILI)虽然得到了阿里巴巴(BABA)和腾讯(00700)的支持&#xff0c;在扩大和多样化用户数量方面也取得了巨大的成绩。但哔哩哔哩还在继续亏损&#xff0c;随着国家的监管环境朝着对游戏行业有利的方向变化&#xff0…