本人报错:OSError: Error no file named model_index.json found in directory /home/xxx/我的python学习/textToImage/sdxl-turbo.
原因:路径错误导致无法加载模型的配置文件
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
上面是本人的下载预训练模型的代码
通过使用fsearch搜索stabilityai找到下载路径为:
/home/jie/.cache/huggingface/hub/
于是直接使用绝对路径加载
pipe = AutoPipelineForText2Image.from_pretrained("/home/jie/.cache/huggingface/hub/models--stabilityai--sdxl-turbo/snapshots/8fce7b5546bfdbc5aa3562eafa1de9ee129e3b3c", torch_dtype=torch.float16, variant="fp16")
然后就成功了。
注意,这里要加载到
/home/jie/.cache/huggingface/hub/models--stabilityai--sdxl-turbo/snapshots/8fce7b5546bfdbc5aa3562eafa1de9ee129e3b3c(成功路径)
该层目录下面才有model_config.json文件
因为/home/jie/.cache/huggingface/hub/models--stabilityai--sdxl-turbo/(失败路径)下面是没有model_config.json文件的,直接加载会报错OSError: Error no file named model_index.json found in directory /home/jie/桌面/jiestudy/我的python学习/textToImage/sdxl-turbo.