huggingface 连不上 from_pretrained from_single_file

huggingface的缓存目录 ~/.cach  

cd ~/.cache
# pwd 后展示 /home/fxbox/.cache
pwd


pipe: StableDiffusionPipeline = StableDiffusionPipeline.from_pretrained(
    model_id_or_path,
).to(device=self.device, dtype=self.dtype)

改为:

if os.path.exists(model_id_or_path):
    pipe: StableDiffusionPipeline = StableDiffusionPipeline.from_single_file(
        model_id_or_path
    ).to(device=self.device, dtype=self.dtype)
else:
    pipe: StableDiffusionPipeline = StableDiffusionPipeline.from_pretrained(
        model_id_or_path,
    ).to(device=self.device, dtype=self.dtype)

参考:

https://www.cnblogs.com/FrostyForest/p/17841926.html

python diffusers StableDiffusionXLPipeline 离线使用_runwayml/stable-diffusion-v1-5 离线下载-CSDN博客 

你可能感兴趣的:(ai)