IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
14.85k stars 1.37k forks source link

About Network Connect #346

Closed aiyb1314 closed 4 weeks ago

aiyb1314 commented 1 year ago

requests.exceptions.ConnectionError: (ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')), '(Request ID: ea7dea4f-6b82-401c-84a6-3d970e2416ba)')

rentainhe commented 1 year ago

requests.exceptions.ConnectionError: (ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')), '(Request ID: ea7dea4f-6b82-401c-84a6-3d970e2416ba)')

It may be that your network is not stable when connecting to Huggingface, you can also try to download the pre-trained BERT-based model from Huggingface to your local directory and set a specific path to it.

MrTHMX commented 1 year ago

requests.exceptions.ConnectionError: (ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')), '(Request ID: ea7dea4f-6b82-401c-84a6-3d970e2416ba)')

It may be that your network is not stable when connecting to Huggingface, you can also try to download the pre-trained BERT-based model from Huggingface to your local directory and set a specific path to it.

Can you be more specific about the method of downloading the file, I had this problem too, it used to work, now it doesn't work.

rentainhe commented 1 year ago

requests.exceptions.ConnectionError: (ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')), '(Request ID: ea7dea4f-6b82-401c-84a6-3d970e2416ba)')

It may be that your network is not stable when connecting to Huggingface, you can also try to download the pre-trained BERT-based model from Huggingface to your local directory and set a specific path to it.

Can you be more specific about the method of downloading the file, I had this problem too, it used to work, now it doesn't work.

You can try the following steps:

BertTokenizer.from_pretrained(PATH, local_files_only=True)  # PATH is your local file path

If there're some error when loading local checkpoint, you can try to check the hugging face's documentation for more details about the usage.

MrTHMX commented 1 year ago
ef get_pretrained_language_model(text_encoder_type):
    if text_encoder_type == "bert-base-uncased":
        return BertTokenizer.from_pretrained('bert-base-uncased', local_files_only=True)  # PATH is your local file path
        # return BertModel.from_pretrained(text_encoder_type)

is that right?

rentainhe commented 1 year ago
ef get_pretrained_language_model(text_encoder_type):
    if text_encoder_type == "bert-base-uncased":
        return BertTokenizer.from_pretrained('bert-base-uncased', local_files_only=True)  # PATH is your local file path
        # return BertModel.from_pretrained(text_encoder_type)

is that right?

I think it may work

You can refer to huggingface's documentation for more details

MrTHMX commented 1 year ago

File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 181, in model = load_model(config_file, grounded_checkpoint, device=device) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 46, in load_model model = build_model(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/init.py", line 17, in build_model model = build_func(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 372, in build_groundingdino model = GroundingDINO( File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 109, in init self.bert.pooler.dense.weight.requiresgrad(False) AttributeError: 'BertTokenizer' object has no attribute 'pooler'

It returns the question, can you help me to solve?Or the problem is hugging face?

rentainhe commented 1 year ago

File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 181, in model = load_model(config_file, grounded_checkpoint, device=device) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 46, in load_model model = build_model(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/init.py", line 17, in build_model model = build_func(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 372, in build_groundingdino model = GroundingDINO( File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 109, in init self.bert.pooler.dense.weight.requiresgrad(False) AttributeError: 'BertTokenizer' object has no attribute 'pooler'

It returns the question, can you help me to solve?Or the problem is hugging face?

There're something wrong with this, you use BertTokenizer instead of BertModel, they're different

rentainhe commented 1 year ago
ef get_pretrained_language_model(text_encoder_type):
    if text_encoder_type == "bert-base-uncased":
        return BertTokenizer.from_pretrained('bert-base-uncased', local_files_only=True)  # PATH is your local file path
        # return BertModel.from_pretrained(text_encoder_type)

is that right?

I think it may work

You can refer to huggingface's documentation for more details

Please use BertModel instead of BertTokenizer, one is the tokenizer for converting words into embeddings, the other is original BERT model

MrTHMX commented 1 year ago

/home/evsjtu2/miniconda3/envs/gmx-sam/lib/python3.9/site-packages/torch/functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1659484809662/work/aten/src/ATen/native/TensorShape.cpp:2894.) return _VF.meshgrid(tensors, *kwargs) # type: ignore[attr-defined] final text_encoder_type: bert-base-uncased Traceback (most recent call last): File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 181, in model = load_model(config_file, grounded_checkpoint, device=device) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/grounded_sam_demo.py", line 46, in load_model model = build_model(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/init.py", line 17, in build_model model = build_func(args) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 372, in build_groundingdino model = GroundingDINO( File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 107, in init self.tokenizer = get_tokenlizer.get_tokenlizer(text_encoder_type) File "/home/evsjtu2/disk1/gumingxiang/GSAM/Grounded-Segment-Anything/GroundingDINO/groundingdino/util/get_tokenlizer.py", line 17, in get_tokenlizer tokenizer = AutoTokenizer.from_pretrained(text_encoder_type) File "/home/evsjtu2/miniconda3/envs/gmx-sam/lib/python3.9/site-packages/transformers/models/auto/tokenization_auto.py", line 550, in from_pretrained return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, inputs, **kwargs) File "/home/evsjtu2/miniconda3/envs/gmx-sam/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 1695, in from_pretrained resolved_vocab_files[file_id] = cached_path( File "/home/evsjtu2/miniconda3/envs/gmx-sam/lib/python3.9/site-packages/transformers/file_utils.py", line 1776, in cached_path output_path = get_from_cache( File "/home/evsjtu2/miniconda3/envs/gmx-sam/lib/python3.9/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.

After I made the changes, I still prompted for network connectivity issues. Should there be no other areas in the model that require network connectivity besides the hooking face?

MrTHMX commented 1 year ago

I have already solved this problem. Thank you for your help!

flandrewries commented 1 year ago

I have already solved this problem. Thank you for your help!

hello, same question we meet, could you share your step-by-step solution for us to solve this problem? thank you very much for your kindest action.

MrTHMX commented 1 year ago

I have already solved this problem. Thank you for your help!

hello, same question we meet, could you share your step-by-step solution for us to solve this problem? thank you very much for your kindest action.

  1. First, download the pre-trained bert-base-uncased checkpoint from Huggingface's official link: https://huggingface.co/bert-base-uncased/tree/main
  2. Put it in your local directory, remember to download all the files from Huggingface
  3. Update the tokenizer instance in /Grounded-Segment-Anything/GroundingDINO/groundingdino/util/get_tokenlizer.py
    # tokenizer = AutoTokenizer.from_pretrained(text_encoder_type)
    tokenizer = AutoTokenizer.from_pretrained('YOUR PATH/bert-base-uncased', cache_dir='bert-base-uncased')
    # return BertModel.from_pretrained(text_encoder_type)
    return BertModel.from_pretrained('YOUR PATH/bert-base-uncased', local_files_only=True) 
stihuangyuan commented 1 year ago

I have already solved this problem. Thank you for your help!

hello, same question we meet, could you share your step-by-step solution for us to solve this problem? thank you very much for your kindest action.

  1. First, download the pre-trained bert-base-uncased checkpoint from Huggingface's official link: https://huggingface.co/bert-base-uncased/tree/main
  2. Put it in your local directory, remember to download all the files from Huggingface
  3. Update the tokenizer instance in /Grounded-Segment-Anything/GroundingDINO/groundingdino/util/get_tokenlizer.py
    # tokenizer = AutoTokenizer.from_pretrained(text_encoder_type)
    tokenizer = AutoTokenizer.from_pretrained('YOUR PATH/bert-base-uncased', cache_dir='bert-base-uncased')
    # return BertModel.from_pretrained(text_encoder_type)
    return BertModel.from_pretrained('YOUR PATH/bert-base-uncased', local_files_only=True) 

miss other error: final text_encoder_type: bert-base-uncased safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge

SynUW commented 7 months ago

LOL. I encountered this problem today because huggingface is under maintenance : )