huggingface/huggingface_hub

A runtimeerror with repositopry of CLAM

husterWL opened this issue · 3 comments

Describe the bug

When I call the pre-trained ResNet50 model using the CLAM repository, it throws a 'RuntimeError: Hugging Face hub model specified but package not installed. Run 'pip install huggingface_hub'.
Actually I already have huggingface_hub installed.

Error importing huggingface_hub.hf_api: cannot import name 'Mapping' from 'collections' (D:\Anaconda_WL\envs\clam_latest\lib\collections_init_.py)
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models_factory.py", line 114, in create_model
model = create_fn(
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models\resnet.py", line 1283, in resnet50
return _create_resnet('resnet50', pretrained, **dict(model_args, **kwargs))
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models\resnet.py", line 547, in _create_resnet
return build_model_with_cfg(ResNet, variant, pretrained, **kwargs)
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models_builder.py", line 397, in build_model_with_cfg
load_pretrained(
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models_builder.py", line 157, in load_pretrained
load_from, pretrained_loc = _resolve_pretrained_source(pretrained_cfg)
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models_builder.py", line 62, in _resolve_pretrained_source
if not old_cache_valid and hf_hub_id and has_hf_hub(necessary=True):
File "D:\Anaconda_WL\envs\clam_latest\lib\site-packages\timm\models_hub.py", line 112, in has_hf_hub
raise RuntimeError(
RuntimeError: Hugging Face hub model specified but package not installed. Run pip install huggingface_hub.

Above is the specific bug log.

Reproduction

that's a cmd command with CLAM repository, (python extract_features_fp.py --data_h5_dir C:/Users/WL/Desktop/WSI/RESULT_DIRECTORY/patches --data_slide_dir C:/Users/WL/Desktop/WSI/DATA_DIRECTORY --csv_path C:/Users/WL/Desktop/WSI/RESULT_DIRECTORY/process_list_autogen.csv --feat_dir C:/Users/WL/Desktop/WSI/FEATURES_DIRECTORY --batch_size 16 --slide_ext .tif)

Logs

No response

System info

- huggingface_hub version: 0.26.2
- python version: 3.10.0
- timm version: 0.9.8

Hi @husterWL, I'm sorry you're facing this issue. The error doesn't seem to be with huggingface_hub though. You can uninstall / reinstall it just in case (pip uninstall -y huggingface_hub && pip install huggingface_hubor even start a new virtualenv from scratch) but otherwise I think the problem is more to look into either CLAM repo or maybe timm. In any case,

Error importing huggingface_hub.hf_api: cannot import name 'Mapping' from 'collections'

seems to be the culprit here. This should be a long gone issue (see https://www.geeksforgeeks.org/python-importerror-cannot-import-name-mapping-from-collections/)

Thanks! The cause should be 'Mapping' form 'collections'.

closing this issue as it seems that it's not related to huggingface_hub as stated in this comment.