recognize-anything icon indicating copy to clipboard operation
recognize-anything copied to clipboard

python inference_ram_openset.py --image images/openset_example.jpg --pretrained ./ram_swin_large_14m.pth

Open xuboot opened this issue 1 year ago • 3 comments

openset_example.jpg --pretrained ./ram_swin_large_14m.pth Traceback (most recent call last): File "inference_ram_openset.py", line 45, in model = ram(pretrained=args.pretrained, File "/mnt/data/user/recognize-anything/recognize-anything/ram/models/ram.py", line 263, in ram model = RAM(**kwargs) File "/mnt/data/user/recognize-anything/recognize-anything/ram/models/ram.py", line 103, in init self.tokenizer = init_tokenizer() File "/mnt/data/user/recognize-anything/recognize-anything/ram/models/utils.py", line 131, in init_tokenizer tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') File "/home/gpu05/anaconda3/envs/env-name/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1695, in from_pretrained resolved_vocab_files[file_id] = cached_path( File "/home/gpu05/anaconda3/envs/env-name/lib/python3.8/site-packages/transformers/file_utils.py", line 1776, in cached_path output_path = get_from_cache( File "/home/gpu05/anaconda3/envs/env-name/lib/python3.8/site-packages/transformers/file_utils.py", line 2000, in get_from_cache raise ValueError( ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

xuboot avatar Aug 21 '23 09:08 xuboot

You can manually download the bert pretrained tokenizer and load it locally. Please change this code: https://github.com/xinyu1205/recognize-anything/blob/main/ram/models/utils.py#L131C5-L131C67

xinyu1205 avatar Aug 21 '23 12:08 xinyu1205

给需要帮助的人

  1. 首先去下载文件 https://huggingface.co/google-bert/bert-base-uncased/tree/main 只需要这几个 config.json 、tokenizer.json、tokenizer_config.json、vocab.txt、gitattributes、LICENSE、README.md 2.保存到项目目录下,如 resources/bert-base-uncased 3.在初始化时候指定目录即可 model = ram_plus(pretrained='resources/ram_plus_swin_large_14m.pth', image_size=384, vit='swin_l',text_encoder_type='resources/bert-base-uncased')

hainatravel avatar May 14 '24 06:05 hainatravel

  1. text_encoder_type='resources/bert-base-uncased'

大哥,贼吊

robinjoe93 avatar Jul 04 '24 03:07 robinjoe93