惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News
博客园_首页
云风的 BLOG
云风的 BLOG
月光博客
月光博客
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
D
Docker
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
博客园 - 叶小钗
Martin Fowler
Martin Fowler
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog

StudyingLover's Blog

Diffusion Policy笔记 rwkv笔记 act笔记 nanovllm-block_manager opencode多智能体 nanobot-pre-train nanobot-rl nanobot-sft nanobot-checkpoint_manager nanobot-gpt nanobot-mid-train Vision Mamba (Vim)笔记 BPE演示 最后一遍学习Transformer YOLOv5 目标检测笔记 下载根服务器解析记录 Dynaseal A Backend-Controlled LLM API Key Distribution Scheme with Constrained Invocation Parameters 判断链表有环 王道25数据结构勘误 关于perplexity的open-sourcing-r1-1776 AI为什么不像人类一样进行多轮对话 新博客改造日记和功能测试 linuxqq只显示登陆背景图 数字设计和计算机体系结构(机械工业出版社)勘误(自制) Dynaseal:面向未来端侧llm agent的llm api key分发机制 A Definitive Guide to Markdown Style This post is using MDX, Where you can embed JSX and Astro components RT-Patch学习 pydantic实现的LLM ReAct fastapi 和 uvicorn 设置监听 ipv6
Diffusers去除NSFW限制
About the Author StudyingLover · 2023-06-11 · via StudyingLover's Blog

众所周知,涩涩是文字生成图片技术发展的重大推动力 . Huggingface的diffusers封装了大量的算法用于生成图片。但是,很不幸的,diffusers会检测生成的图片是否存在NSFW(not safe for work)的内容,这就给我们涩涩带来了不必要的麻烦。所以我将介绍如何去除限制

该方法来自网友,原链接

先给一段示例代码

import numpy as np
import matplotlib.pyplot as plt
from diffusers import StableDiffusionPipeline
import cv2 as cv
if __name__ == '__main__':
	pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
	new_image = pipe(prompt, num_inference_steps=20).images[0]
	plt.save('image.png',new_image)

我们只需要设置StableDiffusionPipeline 这个类的safety_checker函数,更改之后的代码

import numpy as np
import matplotlib.pyplot as plt
from diffusers import StableDiffusionPipeline
import cv2 as cv
def dummy(images, **kwargs): 
	return images, False
if __name__ == '__main__':
	pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
	pipe.safety_checker = dummy
	new_image = pipe(prompt, num_inference_steps=20).images[0]
	plt.save('image.png',new_image)

成功实现涩涩自由