由于我的显卡比较垃圾(3050),加载模型时都用的
torch.dtype=float16
后来用下列方式保存模型:
pipeline = StableDiffusionPipeline(
text_encoder=text_encoder,
vae=vae,
unet=unet,
tokenizer=tokenizer,
scheduler=PNDMScheduler(beta_start=0.00085,
beta_end=0.012,
beta_schedule='scaled_linear',
skip_prk_steps=True),
safety_checker=StableDiffusionSafetyChecker.from_pretrained(
'CompVis/stable-diffusion-safety-checker'),
feature_extractor=CLIPFeatureExtractor.from_pretrained(
'openai/clip-vit-base-patch32'),
)
pipeline.save_pretrained('../modules/cat_toy')
报了错:文章来源:https://www.toymoban.com/news/detail-532146.html
TypeError: Object of type dtype is not JSON serializable
在网上查到的各种方法都无法解决,折腾了一天后(想紫砂),又审视了一下这句话,意思是"dtype"这种类型不能JSON序列化,我的理解是,因为我的模型的dtype=float16,因此不能用这种方式保存。之后试了float32的模型,可以正常保存,但因为显存、内存太小,在本地跑不了😭😭😭文章来源地址https://www.toymoban.com/news/detail-532146.html
到了这里,关于对Stable Diffusion做fine-tune时遇见的bug的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!