首页 >>  正文

painting+class

来源:baiyundou.net   日期:2024-08-06

stable diffusion安装与简单评测

最近可以在各个平台上看到stable diffusion的相关案例,各种text2img或是img2img的应用都有非常惊艳的效果。

虽然类似功能的DALL-E已经发布很久了,甚至性能更为强大,但是stable diffusion模型开源所带来的影响力是DALL-E所远远不能比拟的,投石入河激起的涟漪层层荡开,许多新的服务、网站衍生而出,不禁让人吃惊:怎么会那么火?

相关资源

这里简单罗列下stable diffusion相关的各类资源,包括代码、模型等等。

  • 官网:https://ommer-lab.com/research/latent-diffusion-models/
  • 论文:https://arxiv.org/abs/2112.10752
  • Github地址:https://github.com/CompVis/stable-diffusion
  • 模型下载地址:
    • https://huggingface.co/CompVis/stable-diffusion-v1-2
    • https://huggingface.co/CompVis/stable-diffusion-v1-4/tree/main/safety_checker

huggingface权限申请

目前stable diffusion的模型都已经在huggingface上开源发布了,主页上也说明了具体的使用方法,但是由于这种生成式的模型容易被滥用,因此使用受限无法直接下载,还需要在huggingface上注册个人账号后申请使用。

注册账号后,在https://huggingface.co/settings/tokens可以得到对应的tokens,然后本地huggingface-cli login后输入,就可以愉快的使用stable diffusion的相关模型了。如果没有token,代码运行会报错:

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/models/CompVis/stable-diffusion-v1-2/revision/main (Request ID: 95rKMncm_EoF-0t_W39_F)\n

另外Access repository后,就可以下载模型了。

依赖库安装

huggingface中所提供的示例代码,所依赖的是diffusers这个库,访问这个库的GitHub地址:https://github.com/huggingface/diffusers,官方的说法是pip安装就可以。

不过实际测试发现,pip默认安装的版本是0.1.2,而不是推荐的0.2.4,同时即使强制安装了0.2.4,img2img和in-painting所使用的类在这个包中也并不存在,因此更建议的安装方法是clone GitHub仓库到本地后,通过python3 setup.py install安装实现。

text2img测评

简单测评下text2img的功能:输入一段text文字,模型会基于这段描述性文字生成图像img。

代码使用官方提供的示例就可以,由于模型已经下载,因此将路径指定为模型地址即可:

# make sure you're logged in with `huggingface-cli login`\nfrom torch import autocast\nfrom diffusers import StableDiffusionPipeline\n\npipe = StableDiffusionPipeline.from_pretrained('/stable-diffusion-v1-4')\nprompt = "a photo of a flying dog"\nimage = pipe(prompt, guidance_scale=7.5)["sample"][0]\nimage.save("/test.png”)\n

其中pipe的结构如下:

# pipe结构\n>>> pipe\nStableDiffusionPipeline {\n "_class_name": "StableDiffusionPipeline",\n "_diffusers_version": "0.2.4",\n "feature_extractor": [\n "transformers",\n "CLIPFeatureExtractor"\n ],\n "safety_checker": [\n "stable_diffusion",\n "StableDiffusionSafetyChecker"\n ],\n "scheduler": [\n "diffusers",\n "PNDMScheduler"\n ],\n "text_encoder": [\n "transformers",\n "CLIPTextModel"\n ],\n "tokenizer": [\n "transformers",\n "CLIPTokenizer"\n ],\n "unet": [\n "diffusers",\n "UNet2DConditionModel"\n ],\n "vae": [\n "diffusers",\n "AutoencoderKL"\n ]\n}\n

随意测试了一些prompt的生成效果如下:

  • a photo of a flying dog
  • a photo of an astronaut riding a horse on moon
  • a photo of a smiling Chinese women
  • a photo of a smiling American women

可以看到大部分图像的生成效果其实都还可以,不过这个Chinese women看的让人头秃,训练数据怕不是有眯眯眼的歧视问题。。。

在线资源

除了通过本地下载模型调试代码,stable diffusion还有很多开源的服务,便于做快速测试。 以https://huggingface.co/spaces/stabilityai/stable-diffusion 为例,同样可以输入一句prompt生成图像,不过由于资源紧张需要排队使用,排队时间也可能比较长。

这里同样测试了几个prompt,效果如下:

  • a photo of a smiling Chinese women
  • a robot reading the book and playing the piano

嗯,看起来训练数据的眯眯眼问题是没跑了。

此外,还有一个开源的prompt网站:https://lexica.art/,可以提供参考的prompt用于生成图像,支持DALL-E,stable diffusion等模型。

不过目前stable diffusion的相关服务还不完善,摘录部分DALL-E的prompt与图像示例如下:

  • ultra nekopara fantastically detailed reflecting eyes modern anime style art cute detailed ears cat girl neko dress portrait shinkai makoto vibrant Studio ghibli kyoto animation hideaki anno Sakimichan Stanley Artgerm Lau Rossdraws James Jean Marc Simonetti elegant highly detailed digital painting artstation pixiv cyberpunk
  • a hyperdetailed matte painting of a german romantic tree emerging from an oceanographic landscape, magic realism painting, trending on artstation

小结

人工智能喊得这些年,除了被吐槽人工智障外,自动驾驶看着还是有些远,下围棋也终究是少数人的爱好,但是目前stable diffusion代表的图像生成,倒是第一个如此贴近大众生活的应用,很有成为UGC工具的潜力。

","gnid":"9d87ec90eb12de29e","img_data":[{"flag":2,"img":[{"desc":"","height":"756","title":"","url":"https://p0.ssl.img.360kuai.com/t0170ab438c274c989b.webp","width":"720"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t0129544eaae17d6809.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t01326b5cfdb0aaf5e1.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t01aeee74784daf1904.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t01ce3e868a1df229b3.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t015c27d7d5da96feef.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t0137f934181b156c30.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t0105ead4ef42acea1c.webp","width":"512"},{"desc":"","height":"512","title":"","url":"https://p0.ssl.img.360kuai.com/t013e96697413a196e2.webp","width":"512"},{"desc":"","height":"1050","title":"","url":"https://p0.ssl.img.360kuai.com/t01b5bf1472755c6634.webp","width":"720"},{"desc":"","height":"719","title":"","url":"https://p0.ssl.img.360kuai.com/t01b12b73b0e4a4bf99.webp","width":"720"}]}],"original":0,"pat":"art_src_0,fts0,sts0","powerby":"hbase","pub_time":1683266624000,"pure":"","rawurl":"http://zm.news.so.com/887e6d5b24c497a475f12861aeb4d9cb","redirect":0,"rptid":"324b2f4cb8d2de3c","rss_ext":[],"s":"t","src":"浩然正气","tag":[],"title":"stable diffusion安装与简单评测

后码态964painting意思 -
厉爽任19456553680 ______ 绘画的意思 拓展:drawing, illustration, cartoon, diagram, picture, sketch, painting, portrait 这些名词都表示“画,图”之意. drawing: 指用线条或色彩绘成的图画. illustration: 指插入书页之间帮助说明的任何插图或图解. cartoon: 指幽默或讽刺性漫画. diagram: 多指科技书籍或文献中具有概括解说作用的图表、图样或略图. picture: 指广义的“图画”,现多用来指相片、画像. sketch: 通常只指画出物体主要特征的图画. painting: 指着色的画. portrait: 指肖像,只用于指人. 希望对你有帮助.

后码态964painting a room的英语作文 -
厉爽任19456553680 ______ Look , I have a nice room . Come and have a look . It's small and nice . There is a big bed , a small desk , a shelf and a closet . The bed is near the desk . There is a shelf near the closet too . Many good books are in the shelf . I like the books very ...

后码态964歌曲painting by chagall中文翻译 -
厉爽任19456553680 ______ chagall 应该是个人名 意思是:夏卡尔 的油画 希望我的回答可以帮到你 谢谢!

后码态964painting sleep doing 三词中哪个是不同类的 为什么? -
厉爽任19456553680 ______ Sleep 不是同类. 这三个词相当于Doing Do Doing Sleep是动词原型 另外两个是动名词也就是动词的ing形式

后码态964Painting By Chagall 是什么意思? -
厉爽任19456553680 ______ painting by chagall 歌手:the weepies 专辑:say i am you Thunder rumbles in the distance, a quiet intensity I am willful, your insistence is tugging at the best of me You\'re the moon, I\'m the water You\'re Mars, calling up Neptune\'s daughter ...

后码态964I am learning - - - (paint)in the ciass .This is - - - (I) in the class.要怎么填啊? -
厉爽任19456553680 ______ 我认为 painting 和to paint 都可以 painting是名词 :绘画;油画;着色 如果考虑learn to do 的话 填写 to paint也可以. 第二个填me 宾格

后码态964画画你的鞋子,用英语写一句话 -
厉爽任19456553680 ______ 画画你的鞋子Painting your shoespaint英[peɪnt] 美[pent] n.颜料,涂料; 绘画作品; 胭脂等化妆品; 色彩,装饰vt.绘画; 涂色于; (用语言,文字等)描写; 擦脂粉等vi.描绘...

后码态964It is impersonal process of painting that clairifies the self.这句话的定语从句的先行词是PAINTING ? -
厉爽任19456553680 ______ 如果句子这样写或者会清楚一点儿. It is (the) (impersonal) process of painting that clarifies the self.由此可见是 process (过程)是主体,即 过程辨清自我.另外, process 要加冠词 the .

后码态964painting怎样读? -
厉爽任19456553680 ______ 呸婷(*^__^*) 嘻嘻……

后码态964关于paint的句子 -
厉爽任19456553680 ______ They saw some large letters in white paint. 他们看见了用白漆写的几个大大的字母. They'll probably scrape the paint off and make it look like a regular patrol car. 他们可能会将油漆刮掉,使它看起来像一部普通的巡逻警车. I made a guitar and ...

(编辑:自媒体)
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图 @ 白云都 2024