open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
28.78k stars 9.33k forks source link

OSError: We couldn't connect to 'https://huggingface.co' to load this file. #11370

Closed douling843 closed 6 months ago

douling843 commented 6 months ago

Describe the bug I'm running grounding_dino in mmdetection and everything is implemented according to the official tutorial, but I'm encountering the following problem:

System environment: sys.platform: linux Python: 3.8.18 | packaged by conda-forge | (default, Dec 23 2023, 17:21:28) [GCC 12.3.0] CUDA available: True numpy_random_seed: 1146466060 GPU 0,1: NVIDIA GeForce RTX 2080 Ti CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 11.3, V11.3.58 GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.12.0 PyTorch compiling details: PyTorch built with:

Runtime environment: cudnn_benchmark: False mp_cfg: {'mp_start_method': 'fork', 'opencv_num_threads': 0} dist_cfg: {'backend': 'nccl'} seed: 1146466060 Distributed launcher: none Distributed training: False GPU number: 1

01/14 03:26:06 - mmengine - INFO - Config: auto_scale_lr = dict(base_batch_size=2, enable=False) backend_args = None data_root = 'data/ssdd_coco_style/' dataset_type = 'CocoDataset' default_hooks = dict( checkpoint=dict(interval=1, type='CheckpointHook'), logger=dict(interval=200, type='LoggerHook'), param_scheduler=dict(type='ParamSchedulerHook'), sampler_seed=dict(type='DistSamplerSeedHook'), timer=dict(type='IterTimerHook'), visualization=dict(type='DetVisualizationHook')) default_scope = 'mmdet' env_cfg = dict( cudnn_benchmark=False, dist_cfg=dict(backend='nccl'), mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0)) lang_model_name = 'bert-large-cased' launcher = 'none' load_from = None log_level = 'INFO' log_processor = dict(by_epoch=True, type='LogProcessor', window_size=50) max_epochs = 36 model = dict( as_two_stage=True, backbone=dict( depth=50, frozen_stages=1, init_cfg=dict(checkpoint='torchvision://resnet50', type='Pretrained'), norm_cfg=dict(requires_grad=False, type='BN'), norm_eval=True, num_stages=4, out_indices=( 1, 2, 3, ), style='pytorch', type='ResNet'), bbox_head=dict( contrastive_cfg=dict(bias=True, log_scale='auto', max_text_len=256), loss_bbox=dict(loss_weight=5.0, type='L1Loss'), loss_cls=dict( alpha=0.25, gamma=2.0, loss_weight=1.0, type='FocalLoss', use_sigmoid=True), loss_iou=dict(loss_weight=2.0, type='GIoULoss'), num_classes=1, sync_cls_avg_factor=True, type='GroundingDINOHead'), data_preprocessor=dict( bgr_to_rgb=True, mean=[ 123.675, 116.28, 103.53, ], pad_mask=False, std=[ 58.395, 57.12, 57.375, ], type='DetDataPreprocessor'), decoder=dict( layer_cfg=dict( cross_attn_cfg=dict(dropout=0.0, embed_dims=256, num_heads=8), cross_attn_text_cfg=dict(dropout=0.0, embed_dims=256, num_heads=8), ffn_cfg=dict( embed_dims=256, feedforward_channels=2048, ffn_drop=0.0), self_attn_cfg=dict(dropout=0.0, embed_dims=256, num_heads=8)), num_layers=6, post_norm_cfg=None, return_intermediate=True), dn_cfg=dict( box_noise_scale=1.0, group_cfg=dict(dynamic=True, num_dn_queries=100, num_groups=None), label_noise_scale=0.5), encoder=dict( fusion_layer_cfg=dict( embed_dim=1024, init_values=0.0001, l_dim=256, num_heads=4, v_dim=256), layer_cfg=dict( ffn_cfg=dict( embed_dims=256, feedforward_channels=2048, ffn_drop=0.0), self_attn_cfg=dict(dropout=0.0, embed_dims=256, num_levels=4)), num_cp=6, num_layers=6, text_layer_cfg=dict( ffn_cfg=dict( embed_dims=256, feedforward_channels=1024, ffn_drop=0.0), self_attn_cfg=dict(dropout=0.0, embed_dims=256, num_heads=4))), language_model=dict( add_pooling_layer=False, name='bert-large-cased', pad_to_max=False, special_tokens_list=[ '[CLS]', '[SEP]', '.', '?', ], type='BertModel', use_sub_sentence_represent=True), neck=dict( act_cfg=None, bias=True, in_channels=[ 512, 1024, 2048, ], kernel_size=1, norm_cfg=dict(num_groups=32, type='GN'), num_outs=4, out_channels=256, type='ChannelMapper'), num_queries=900, positional_encoding=dict( normalize=True, num_feats=128, offset=0.0, temperature=20), test_cfg=dict(max_per_img=300), train_cfg=dict( assigner=dict( match_costs=[ dict(type='BinaryFocalLossCost', weight=2.0), dict(box_format='xywh', type='BBoxL1Cost', weight=5.0), dict(iou_mode='giou', type='IoUCost', weight=2.0), ], type='HungarianAssigner')), type='GroundingDINO', with_box_refine=True) optim_wrapper = dict( clip_grad=dict(max_norm=0.1, norm_type=2), optimizer=dict(lr=0.0001, type='AdamW', weight_decay=0.0001), paramwise_cfg=dict( custom_keys=dict( absolute_pos_embed=dict(decay_mult=0.0), backbone=dict(lr_mult=0.1))), type='OptimWrapper') param_scheduler = [ dict( begin=0, by_epoch=True, end=36, gamma=0.1, milestones=[ 24, 33, ], type='MultiStepLR'), ] resume = False test_cfg = dict(type='TestLoop') test_dataloader = dict( batch_size=1, dataset=dict( ann_file='annotations/test.json', backend_args=None, data_prefix=dict(img='images/test/'), data_root='data/ssdd_coco_style/', pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 800, 1333, ), type='FixScaleResize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'text', 'custom_entities', ), type='PackDetInputs'), ], return_classes=True, test_mode=True, type='CocoDataset'), drop_last=False, num_workers=2, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) test_evaluator = dict( ann_file='data/ssdd_coco_style/annotations/test.json', backend_args=None, format_only=False, metric='bbox', type='CocoMetric') test_pipeline = [ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 800, 1333, ), type='FixScaleResize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'text', 'custom_entities', ), type='PackDetInputs'), ] train_cfg = dict(max_epochs=36, type='EpochBasedTrainLoop', val_interval=1) train_dataloader = dict( batch_sampler=dict(type='AspectRatioBatchSampler'), batch_size=2, dataset=dict( ann_file='annotations/train.json', backend_args=None, data_prefix=dict(img='images/train/'), data_root='data/ssdd_coco_style/', filter_cfg=dict(filter_empty_gt=False, min_size=32), pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(prob=0.5, type='RandomFlip'), dict( transforms=[ [ dict( keep_ratio=True, scales=[ ( 480, 1333, ), ( 512, 1333, ), ( 544, 1333, ), ( 576, 1333, ), ( 608, 1333, ), ( 640, 1333, ), ( 672, 1333, ), ( 704, 1333, ), ( 736, 1333, ), ( 768, 1333, ), ( 800, 1333, ), ], type='RandomChoiceResize'), ], [ dict( keep_ratio=True, scales=[ ( 400, 4200, ), ( 500, 4200, ), ( 600, 4200, ), ], type='RandomChoiceResize'), dict( allow_negative_crop=True, crop_size=( 384, 600, ), crop_type='absolute_range', type='RandomCrop'), dict( keep_ratio=True, scales=[ ( 480, 1333, ), ( 512, 1333, ), ( 544, 1333, ), ( 576, 1333, ), ( 608, 1333, ), ( 640, 1333, ), ( 672, 1333, ), ( 704, 1333, ), ( 736, 1333, ), ( 768, 1333, ), ( 800, 1333, ), ], type='RandomChoiceResize'), ], ], type='RandomChoice'), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'flip', 'flip_direction', 'text', 'custom_entities', ), type='PackDetInputs'), ], return_classes=True, type='CocoDataset'), num_workers=2, persistent_workers=True, sampler=dict(shuffle=True, type='DefaultSampler')) train_pipeline = [ dict(backend_args=None, type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(prob=0.5, type='RandomFlip'), dict( transforms=[ [ dict( keep_ratio=True, scales=[ ( 480, 1333, ), ( 512, 1333, ), ( 544, 1333, ), ( 576, 1333, ), ( 608, 1333, ), ( 640, 1333, ), ( 672, 1333, ), ( 704, 1333, ), ( 736, 1333, ), ( 768, 1333, ), ( 800, 1333, ), ], type='RandomChoiceResize'), ], [ dict( keep_ratio=True, scales=[ ( 400, 4200, ), ( 500, 4200, ), ( 600, 4200, ), ], type='RandomChoiceResize'), dict( allow_negative_crop=True, crop_size=( 384, 600, ), crop_type='absolute_range', type='RandomCrop'), dict( keep_ratio=True, scales=[ ( 480, 1333, ), ( 512, 1333, ), ( 544, 1333, ), ( 576, 1333, ), ( 608, 1333, ), ( 640, 1333, ), ( 672, 1333, ), ( 704, 1333, ), ( 736, 1333, ), ( 768, 1333, ), ( 800, 1333, ), ], type='RandomChoiceResize'), ], ], type='RandomChoice'), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'flip', 'flip_direction', 'text', 'custom_entities', ), type='PackDetInputs'), ] val_cfg = dict(type='ValLoop') val_dataloader = dict( batch_size=1, dataset=dict( ann_file='annotations/test.json', backend_args=None, data_prefix=dict(img='images/test/'), data_root='data/ssdd_coco_style/', pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 800, 1333, ), type='FixScaleResize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'text', 'custom_entities', ), type='PackDetInputs'), ], return_classes=True, test_mode=True, type='CocoDataset'), drop_last=False, num_workers=2, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) val_evaluator = dict( ann_file='data/ssdd_coco_style/annotations/test.json', backend_args=None, format_only=False, metric='bbox', type='CocoMetric') vis_backends = [ dict(type='LocalVisBackend'), ] visualizer = dict( name='visualizer', type='DetLocalVisualizer', vis_backends=[ dict(type='LocalVisBackend'), ]) work_dir = 'work_dirs/ssdd/grounding_dino_r50_scratch_8xb2_3x_ssdd'

Traceback (most recent call last): File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connectionpool.py", line 404, in _make_request self._validate_conn(conn) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn conn.connect() File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connection.py", line 363, in connect self.sock = conn = self._new_conn() File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connection.py", line 179, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f023d7215b0>, 'Connection to huggingface.co timed out. (connect timeout=10)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/urllib3/connectionpool.py", line 799, in urlopen retries = retries.increment( File "/opt/conda/envs/mmdetgdino/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: /bert-large-cased/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f023d7215b0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1238, in hf_hub_download metadata = get_hf_file_metadata( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(args, kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1631, in get_hf_file_metadata r = _request_wrapper( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 385, in _request_wrapper response = _request_wrapper( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 408, in _request_wrapper response = get_session().request(method=method, url=url, params) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 67, in send return super().send(request, args, **kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/requests/adapters.py", line 553, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-large-cased/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f023d7215b0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 657f390d-f0f6-4d3b-ae15-b15694c2a5e1)')

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

Traceback (most recent call last): File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/utils/hub.py", line 389, in cached_file resolved_file = hf_hub_download( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(*args, **kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1371, in hf_hub_download 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.

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

Traceback (most recent call last): File "tools/train.py", line 121, in main() File "tools/train.py", line 110, in main runner = Runner.from_cfg(cfg) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/runner/runner.py", line 462, in from_cfg runner = cls( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/runner/runner.py", line 429, in init self.model = self.build_model(model) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/runner/runner.py", line 836, in build_model model = MODELS.build(model) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build return self.build_func(cfg, args, kwargs, registry=self) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/workspace/mmdetection/mmdet/models/detectors/grounding_dino.py", line 58, in init super().init(args, kwargs) File "/workspace/mmdetection/mmdet/models/detectors/dino.py", line 30, in init super().init(*args, *kwargs) File "/workspace/mmdetection/mmdet/models/detectors/deformable_detr.py", line 69, in init super().init(args, decoder=decoder, bbox_head=bbox_head, kwargs) File "/workspace/mmdetection/mmdet/models/detectors/base_detr.py", line 77, in init self._init_layers() File "/workspace/mmdetection/mmdet/models/detectors/grounding_dino.py", line 79, in _init_layers self.language_model = MODELS.build(self.language_model_cfg) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build return self.build_func(cfg, *args, kwargs, registry=self) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/workspace/mmdetection/mmdet/models/language_models/bert.py", line 119, in init self.tokenizer = AutoTokenizer.from_pretrained(name) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/models/auto/tokenization_auto.py", line 752, in from_pretrained config = AutoConfig.from_pretrained( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/models/auto/configuration_auto.py", line 1082, in from_pretrained config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/configuration_utils.py", line 644, in get_config_dict config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, kwargs) File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/configuration_utils.py", line 699, in _get_config_dict resolved_config_file = cached_file( File "/opt/conda/envs/mmdetgdino/lib/python3.8/site-packages/transformers/utils/hub.py", line 429, in cached_file raise EnvironmentError( OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like bert-large-cased is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'. (mmdetgdino)

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

hhaAndroid commented 6 months ago

@douling843 https://github.com/open-mmlab/mmdetection/blob/main/configs/mm_grounding_dino/usage_zh-CN.md#bert-%E6%9D%83%E9%87%8D%E4%B8%8B%E8%BD%BD

douling843 commented 6 months ago

@hhaAndroid Thank you for your answer.