M3DM复现时的huggingface_hub.utils._errors.LocalEntryNotFoundError

M3DM复现时的huggingface_hub.utils._errors.LocalEntryNotFoundError

按作者在github上给出的流程,以此进行如下步骤:
1、Data Download and Preprocess
(1)Dataset
(2)Datapreprocess
(3)Checkpoints
我此处选择的特征提取预训练模型是Point Transformer[Point-MAE]及ViT-b/8[DINO]
下载相应的权重文件,放在了checkpoints文件夹下
在这里插入图片描述

2、Train and Test
终端输入以下命令

python3 main.py \
--method_name DINO+Point_MAE \
--memory_bank multiple \
--rgb_backbone_name vit_base_patch8_224_dino \
--xyz_backbone_name Point_MAE \
--save_feature \

此时出现以下错误提示,大致意思是希望访问某网页下载所请求的文件,但存在网络连接问题

最后一行是:

huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

附全部的错误信息:

model = create_fn(
Traceback (most recent call last):
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connection.py", line 309, in connect
    conn = self._new_conn()
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa5333fa4c0>: Failed to establish a new connection: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/urllib3/util/retry.py", line 446, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /timm/vit_base_patch8_224.dino/resolve/main/pytorch_model.bin (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa5333fa4c0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1722, in _get_metadata_or_catch_error
    metadata = get_hf_file_metadata(url=url, proxies=proxies, timeout=etag_timeout, headers=headers)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1645, in get_hf_file_metadata
    r = _request_wrapper(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 372, in _request_wrapper
    response = _request_wrapper(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 395, in _request_wrapper
    response = get_session().request(method=method, url=url, **params)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 66, in send
    return super().send(request, *args, **kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/requests/adapters.py", line 700, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /timm/vit_base_patch8_224.dino/resolve/main/pytorch_model.bin (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa5333fa4c0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))"), '(Request ID: 5703a7e1-588d-4ac3-993b-f88464b60e40)')

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

Traceback (most recent call last):
  File "main.py", line 161, in <module>
    run_3d_ads(args)
  File "main.py", line 44, in run_3d_ads
    model = M3DM(args)
  File "/home/zn/Workspace/M3DM-main/m3dm_runner.py", line 42, in __init__
    "DINO+Point_MAE": multiple_features.DoubleRGBPointFeatures(args),
  File "/home/zn/Workspace/M3DM-main/feature_extractors/features.py", line 33, in __init__
    self.deep_feature_extractor = Model(
  File "/home/zn/Workspace/M3DM-main/models/models.py", line 29, in __init__
    self.rgb_backbone = timm.create_model(model_name=rgb_backbone_name, pretrained=True, checkpoint_path=checkpoint_path,
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/_factory.py", line 117, in create_model
    model = create_fn(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/_registry.py", line 145, in _fn
    return current_fn(pretrained=pretrained, pretrained_cfg=pretrained_cfg or current_tag, **kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/vision_transformer.py", line 2122, in vit_base_patch8_224
    model = _create_vision_transformer('vit_base_patch8_224', pretrained=pretrained, **dict(model_args, **kwargs))
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/vision_transformer.py", line 2002, in _create_vision_transformer
    return build_model_with_cfg(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/_builder.py", line 418, in build_model_with_cfg
    load_pretrained(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/_builder.py", line 196, in load_pretrained
    state_dict = load_state_dict_from_hf(pretrained_loc)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/timm/models/_hub.py", line 188, in load_state_dict_from_hf
    cached_file = hf_hub_download(hf_model_id, filename=filename, revision=hf_revision)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1221, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1325, in _hf_hub_download_to_cache_dir
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "/home/zn/myvenv3.8+1.12/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1826, in _raise_on_head_call_error
    raise LocalEntryNotFoundError(
huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

问题所在:

找到出现问题之处:

 ## RGB backbone
        self.rgb_backbone = timm.create_model(model_name=rgb_backbone_name, pretrained=True, checkpoint_path=checkpoint_path,
                                          **kwargs)

出现问题的原因:
由于网络问题导致的权重文件下载失败,此处可尝试手动加载以下载的权重文件
在这里插入图片描述

附此处的详细代码:

class Model(torch.nn.Module):

    def __init__(self, device, rgb_backbone_name='vit_base_patch8_224_dino', out_indices=None, checkpoint_path='',
                 pool_last=False, xyz_backbone_name='Point_MAE', group_size=128, num_group=1024):
        super().__init__()
        # 'vit_base_patch8_224_dino'
        # Determine if to output features.
        self.device = device

        kwargs = {'features_only': True if out_indices else False}
        if out_indices:
            kwargs.update({'out_indices': out_indices})

        ## RGB backbone
        self.rgb_backbone = timm.create_model(model_name=rgb_backbone_name, pretrained=True, checkpoint_path=checkpoint_path,
                                          **kwargs)
        
        ## XYZ backbone
        
        if xyz_backbone_name=='Point_MAE':
            self.xyz_backbone=PointTransformer(group_size=group_size, num_group=num_group)
            self.xyz_backbone.load_model_from_ckpt("checkpoints/pointmae_pretrain.pth")
        elif xyz_backbone_name=='Point_Bert':
            self.xyz_backbone=PointTransformer(group_size=group_size, num_group=num_group, encoder_dims=256)
            self.xyz_backbone.load_model_from_pb_ckpt("checkpoints/Point-BERT.pth")

解决办法:

将__init__() 函数中的checkpoint_path置为自己的图像特征权重文件所在之处,将pretrained置为False即可,越过网络问题,使用自己下载好的权重问题【ps:对于出现的网络的问题,暂时没找到合适的解决办法】

class Model(torch.nn.Module):

    def __init__(self, device, rgb_backbone_name='vit_base_patch8_224_dino', out_indices=None, checkpoint_path='自己的图像特征权重文件所在之处',
                 pool_last=False, xyz_backbone_name='Point_MAE', group_size=128, num_group=1024):
        super().__init__()
        # 'vit_base_patch8_224_dino'
        # Determine if to output features.
        self.device = device

        # 根据out_indices的值决定是否只提取特征,不更新索引。
        kwargs = {'features_only': True if out_indices else False}
        
        # 当需要输出特定索引时,更新kwargs以包含这些索引。
        if out_indices:
            kwargs.update({'out_indices': out_indices})
            
        ## RGB backbone
        # 使用timm库根据提供的模型名称和预训练权重路径创建一个RGB backbone模型
        # 这里解释了为什么使用这个库和这个方法:因为它们支持广泛的标准卷积神经网络模型和预训练权重
        # 当你设置pretrained=True时,timm库会自动从互联网上下载对应模型的预训练权重。
        # 如果你已经下载了权重文件,并且想要从本地加载,你可以通过设置pretrained=False,然后使用load_state_dict方法手动加载权重。
        self.rgb_backbone = timm.create_model(model_name=rgb_backbone_name, pretrained=False, checkpoint_path=checkpoint_path,
                                          **kwargs)
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
huggingface_hub.utils._errors.localentrynotfounderrorHuggingface Hub库中的一个错误,通常表示连接错误。当我们使用Huggingface Hub来访问和下载模型或其他资源,可能会遇到这个错误。 这个错误的原因可能是网络连接不稳定或无法连接到Huggingface Hub服务器。可能的解决办法包括: 1. 检查网络连接:确保你的设备连接到互联网并且网络连接稳定。你可以尝试重新连接网络,或者尝试使用其他网络来解决问题。 2. 检查Huggingface Hub服务器状态:有Huggingface Hub的服务器可能出现故障或维护,导致无法正常连接。你可以通过查看Huggingface Hub的官方网站或社交媒体来了解服务器的状态。 3. 检查代码中的输入:在使用Huggingface Hub,你可能需要输入正确的模型名称或标识符来下载相应资源。检查你的代码中是否有拼写错误或其他错误导致无法找到对应资源。 4. 使用其他方式下载资源:如果尝试多次仍然无法连接到Huggingface Hub,你可以考虑使用其他方式来下载所需的资源。例如,你可以尝试从其他源或仓库下载相应的模型。 总之,huggingface_hub.utils._errors.localentrynotfounderror表示连接错误,可能是由于网络问题或其他问题导致无法连接到Huggingface Hub。你可以通过检查网络连接、确认Huggingface Hub服务器状态、检查代码输入或使用其他方式来解决该问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值