运行StableDiffusionInpaintPipeline的Example时报错:OSError: Cannot load model runwayml/stable-diffusion-...

这篇具有很好参考价值的文章主要介绍了运行StableDiffusionInpaintPipeline的Example时报错:OSError: Cannot load model runwayml/stable-diffusion-...。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

项目地址:

https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/inpainthttps://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/inpaint在云服务器端运行下面给出的Example的时候出现报错:

(myconda) root@wnyrpE:/mnt/Diffusers/inpainting# python3 SD_inpaint_eg.py
Couldn't connect to the Hub: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/runwayml/stable-diffusion-inpainting (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa6c5357dc0>: Failed to establish a new connection: [Errno 110] Connection timed out'))"), '(Request ID: bebba422-c4d8-4797-a818-a00fe02957e8)').
Will try to load from local cache.
Traceback (most recent call last):
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
    conn.connect()
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa6c5357dc0>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/runwayml/stable-diffusion-inpainting (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa6c5357dc0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 1656, in download
    info = model_info(pretrained_model_name, token=token, revision=revision)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2084, in model_info
    r = get_session().get(path, headers=headers, timeout=timeout, params=params)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 67, in send
    return super().send(request, *args, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/runwayml/stable-diffusion-inpainting (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa6c5357dc0>: Failed to establish a new connection: [Errno 110] Connection timed out'))"), '(Request ID: bebba422-c4d8-4797-a818-a00fe02957e8)')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "SD_inpaint_eg.py", line 20, in <module>
    pipe = StableDiffusionInpaintPipeline.from_pretrained(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 1096, in from_pretrained
    cached_folder = cls.download(
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 1905, in download
    raise EnvironmentError(
OSError: Cannot load model runwayml/stable-diffusion-inpainting: model is not cached locally and an error occured while trying to fetch metadata from the Hub. Please check out the root cause in the stacktrace above. 
原因是:国内无法服务器无法直接连接上huggingface。

解决办法是:开代理把模型下载到本地再上传到服务器端。(不管是下载到本地,还是直接同步到服务器端,只要是国内的网络都要把代理打开)

我运行的Example代码是:

import PIL
import requests
import torch
from io import BytesIO

from diffusers import StableDiffusionInpaintPipeline


def download_image(url):
    response = requests.get(url)
    return PIL.Image.open(BytesIO(response.content)).convert("RGB")


img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"

init_image = download_image(img_url).resize((512, 512))
mask_image = download_image(mask_url).resize((512, 512))

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")

prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[0]

从Example代码里面看到,应该是要下载runwayml/stable-diffusion-inpainting模型文章来源地址https://www.toymoban.com/news/detail-837423.html

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
注意修改脚本中的代码:
pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "/本地/模型/路径", torch_dtype=torch.float16
)

pipe = pipe.to("cuda")

到了这里,关于运行StableDiffusionInpaintPipeline的Example时报错:OSError: Cannot load model runwayml/stable-diffusion-...的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • [含泪解决]OSError: [Errno 99] Cannot assign requested address__踩坑记录——app.py绑定IP失败

    踩坑记录下。 是这个样子的,前几天帮别人部署Python的Flask项目到云服务器上,然后在 这行代码中,xxx.xxx.xxx.xxx代表我的IP地址,port代表我的端口号。 然后不是要部署到服务器上么,所以我的这个IP地址理所应当就肯定要是我的服务器的IP地址了。 但是,它老是给我报[OSEr

    2024年02月04日
    浏览(39)
  • maven install时报错 Cannot run program “java”

    在 /usr/bin 查看有没有java的命令 没有则创建软连接: sudo ln -s /media/hygd/Data/jdk/linux/jdk/jdk/jdk1.8.0_131/bin/java java 路径需要换成自己jdk路径 附:linux配置java和maven和tomcat环境变量 java命令新打开shell窗口不生效,需要source /etc/profile才生效

    2024年02月16日
    浏览(35)
  • 运行Django项目报错解决,OSError: [WinError 123] 文件名、目录名或卷标语法不正确。

    终端输入 python3 manage.py runserver 运行 Django 项目 OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ‘frozen importlib._bootstrap’ 如图所示 产生错误的原因很多,将终端上滑查看问题原因,这里找到的问题是 找不到某个 module 如图所示 这意味着这个 module 在某个

    2023年04月21日
    浏览(67)
  • typescript项目中import 图片时报错:TS2307: Cannot find module ‘...’

    最近在用typescript写项目时,我用import来加载一个图片,webpack编译文件是会报错如下: 报错: 解决: 如果在js中引入本地静态资源图片时使用import img from \\\'./img/bd_logo1.png’这种写法是没有问题的,但是在typscript中是无法识别非代码资源的,所以会报错TS2307: cannot find module ‘

    2024年02月15日
    浏览(48)
  • STM32使用Jlink下载时报错:cannot read Jlink version number

    最近在学习32遇到的一个问题,浅浅的记录一下。 在魔术棒中进行下载代码的设置时,发现选择Jlink之后,没有识别出来,提示 cannot read Jlink version number。   这个问题只要是因为电脑没有安装Jlink的驱动,所以安装一下Jlink的驱动就可以解决了,Jlink驱动可以去Jlink驱动下载官

    2024年02月11日
    浏览(37)
  • 解决:Python通过pip安装库时报错:ERROR: Cannot unpack file ...; ERROR: Cannot determine archive format of ...

    在使用之前的代码时,报错: ERROR: Cannot unpack file C:UsersMatchaAppDataLocalTemppip-unpack-qdrm7q1esimple.htm (downloaded from C:UsersMatchaAppDataLocalTemppip-req-build-xkgrt0zv, content-type: text/html); cannot detect archive format ERROR: Cannot determine archive format of C:UsersMatchaAppDataLocalTemppip-req-build-xkgrt0

    2024年02月04日
    浏览(47)
  • Hadoop在启动yarn时报错:Cannot set priority of resourcemanager process xxxxx

    着急看解决方法的请直接奔文末。 今天刚开始弄Hadoop,启动完namenode和hadoop之后,开始启动yarn,结果直接报错了: Cannot set priority of resourcemanager process 93826 翻译过来就是说:无法设置resourcemanager进程的优先级(大概)。 然后就开始百度,stackOverflow上有说是没有设置ssh免密登

    2023年04月12日
    浏览(41)
  • wordpress发表文章时报错: rest_cannot_create,抱歉,您不能为此用户创建文章(已解决)

    使用wordpress 的rest api发布文章,首先使用wp-json/jwt-auth/v1/token接口获取token,然后再使用/wp-json/wp/v2/posts 接口发表文章,但是使用axios请求时,却报错: 但是,我在postman上却是可以的,我这里axios的方式是axios.post(url, option) postman的实例代码使用的axios(option)的方式:   我也该了

    2024年02月14日
    浏览(37)
  • 重启Mysql时报错rm: cannot remove ‘/var/lock/subsys/mysql‘: Permission denied

    只有用mysql重启时报错,用root不报错 [mysql@t3-dtpoc-dtpoc-web04 bin]$ service mysql restart Shutting down MySQL.. SUCCESS!  rm: cannot remove \\\'/var/lock/subsys/mysql\\\': Permission denied Starting MySQL.. SUCCESS!  [root@t3-dtpoc-dtpoc-web04 ~]# service mysql restart Shutting down MySQL.. SUCCESS!  Starting MySQL.. SUCCESS!  [root@t3-dtpoc-dtp

    2024年02月11日
    浏览(50)
  • 【Android】使用build.gradle.kt配置目标架构(abiFIlters)时报错 Val cannot be reassigned

    传统上我们会使用 groovy 语言的配置文件 build.gradle 来配置: 在app级别的build.gradle中的 android defaultConfig 添加子项 新版本的默认使用 kotlin 语言的配置文件 build.gradle.kt 来配置gradle: 相应地会想到使用下列代码来指定abi: 此时进行sync就会报错: Val cannot be reassigned Type mismatch.

    2024年01月25日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包