本文主要是介绍huggingface连不上的解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
解决方法大全:
【Hugggingface.co】关于huggingface.co无法访问&大模型下载运行报错解决We couldn‘t connect to ‘https://huggingface.co‘ to.-CSDN博客
本文解决方法参考:
huggingface连不上的解决方案_huggingface offline mode-CSDN博客
搜素对应的库huggingface_hub
里面有个文件:constants.py
把里面的网址改为:
#HUGGINGFACE_CO_URL_HOME = "https://huggingface.co/"
HUGGINGFACE_CO_URL_HOME = "https://hf-mirror.com/"_staging_mode = _is_true(os.environ.get("HUGGINGFACE_CO_STAGING"))#_HF_DEFAULT_ENDPOINT = "https://huggingface.co"
_HF_DEFAULT_ENDPOINT = "https://hf-mirror.com"
使用例子:
import torch
import osif 'HF_HUB_OFFLINE' in os.environ:del os.environ['HF_HUB_OFFLINE']
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
from diffusers.utils import export_to_videoif 'HF_HUB_OFFLINE' in os.environ:del os.environ['HF_HUB_OFFLINE']# from huggingface_hub import snapshot_download
# snapshot_download(repo_id="THUDM/cerspense/zeroscope_v2_576w")# pipe = DiffusionPipeline.from_pretrained(r"D:\360安全浏览器下载", torch_dtype=torch.float16)
pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w")#,token=False)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()prompt = "Darth Vader is surfing on waves"
video_frames = pipe(prompt, num_inference_steps=40, height=320, width=576, num_frames=24).frames
video_path = export_to_video(video_frames)print(video_path)
这篇关于huggingface连不上的解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!