关于太乙模型加载的问题
使用半精度 Half precision FP16 (CUDA)
import torch
from diffusers import StableDiffusionPipeline
torch.backends.cudnn.benchmark = True
pipe = StableDiffusionPipeline.from_pretrained("IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1", torch_dtype=torch.float16)
pipe.to('cuda')
prompt = '飞流直下三千尺,油画'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
生成图片 报错text_config_dict
is provided which will be used to initialize CLIPTextConfig
. The value text_config["id2label"]
will be overriden.
/home/dt/.conda/envs/pytorch/lib/python3.11/site-packages/transformers/models/clip/feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.
warnings.warn(
100%|████████████████████████████████████████| 50/50 [02:23<00:00, 2.88s/it]
/home/dt/.conda/envs/pytorch/lib/python3.11/site-packages/diffusers/utils/pil_utils.py:38: RuntimeWarning: invalid value encountered in cast
images = (images * 255).round().astype("uint8")
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
老是生成黑色突破,请问如何解决?
可以关闭safety_checker试下
可以关闭safety_checker试下
还是不行
看报错就是safety_checker导致了图片被隐藏,你是怎么关闭safety_checker的?
看报错就是safety_checker导致了图片被隐藏,你是怎么关闭safety_checker的?
stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, safety_checker=None)
关闭了safety_checker,但是输出的还是黑色的图!
.conda/envs/pytorch/lib/python3.11/site-packages/transformers/models/clip/feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.
warnings.warn(
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing safety_checker=None
. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
100%|███████████████████████████████████████| 50/50 [02:07<00:00, 2.55s/it]
/home/dt/.conda/envs/pytorch/lib/python3.11/site-packages/diffusers/utils/pil_utils.py:38: RuntimeWarning: invalid value encountered in cast
images = (images * 255).round().astype("uint8")
关闭了safety_checker,不知道为哈,还是输出的黑色图片
.conda/envs/pytorch/lib/python3.11/site-packages/transformers/models/clip/feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.
warnings.warn(
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing safety_checker=None
. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
100%|███████████████████████████████████████| 50/50 [02:07<00:00, 2.55s/it]
/home/dt/.conda/envs/pytorch/lib/python3.11/site-packages/diffusers/utils/pil_utils.py:38: RuntimeWarning: invalid value encountered in cast
images = (images * 255).round().astype("uint8")
!pip install git+https://github.com/huggingface/accelerate
import torch
from diffusers import StableDiffusionPipeline
torch.backends.cudnn.benchmark = True
pipe = StableDiffusionPipeline.from_pretrained("Taiyi-Stable-Diffusion-1B-Chinese-EN-v0.1", torch_dtype=torch.float16, safety_checker=None)
pipe.to('cuda')
prompt = 'cat'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
你这个推理代码,我跑taiyi-anime模型是可以跑的呀
你这个推理代码,我跑taiyi-anime模型是可以跑的呀
换成cuda11.7可以了