当前位置:   article > 正文

对Stable Diffusion做fine-tune时遇见的bug_diffusion safety checker

diffusion safety checker

 由于我的显卡比较垃圾(3050),加载模型时都用的

torch.dtype=float16

 后来用下列方式保存模型:

  1. pipeline = StableDiffusionPipeline(
  2. text_encoder=text_encoder,
  3. vae=vae,
  4. unet=unet,
  5. tokenizer=tokenizer,
  6. scheduler=PNDMScheduler(beta_start=0.00085,
  7. beta_end=0.012,
  8. beta_schedule='scaled_linear',
  9. skip_prk_steps=True),
  10. safety_checker=StableDiffusionSafetyChecker.from_pretrained(
  11. 'CompVis/stable-diffusion-safety-checker'),
  12. feature_extractor=CLIPFeatureExtractor.from_pretrained(
  13. 'openai/clip-vit-base-patch32'),
  14. )
  15. pipeline.save_pretrained('../modules/cat_toy')

报了错:

TypeError: Object of type dtype is not JSON serializable

在网上查到的各种方法都无法解决,折腾了一天后(想紫砂),又审视了一下这句话,意思是"dtype"这种类型不能JSON序列化,我的理解是,因为我的模型的dtype=float16,因此不能用这种方式保存。之后试了float32的模型,可以正常保存,但因为显存、内存太小,在本地跑不了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/879733
推荐阅读
相关标签