error raise when finetuning groundingdino 微调groudingdino train test报错
xuans29 opened this issue · 0 comments
i downloaded branch dev-3.x and builded the environment with following commands on ubuntu system:
conda create --name mmdet python=3.8 -y conda activate mmdet pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu118 pip install -U openmim mim install mmengine mim install "mmcv>=2.0.0" mim install mmdet mim install mmdet[multimodal]
then i downloaded the catdataset and copied following codes to grounding_dino_swin-t_finetune_16xb2_1x_coco.py for i cant connet to hugginface directly:
`
base = [
'../base/datasets/coco_detection.py',
'../base/schedules/schedule_1x.py', '../base/default_runtime.py'
]
load_from = 'https://download.openmmlab.com/mmdetection/v3.0/grounding_dino/groundingdino_swint_ogc_mmdet-822d7e9d.pth' # noqa
lang_model_name = 'bert-base-uncased'
################
from transformers import BertConfig, BertModel
from transformers import AutoTokenizer
config = BertConfig.from_pretrained("bert-base-uncased")
model = BertModel.from_pretrained("bert-base-uncased", add_pooling_layer=False, config=config)
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
config.save_pretrained("E:\pythonProject\post_graduate\mmdet\mmdetection-dev-3.x\bert-base-uncased")
model.save_pretrained("E:\pythonProject\post_graduate\mmdet\mmdetection-dev-3.x\bert-base-uncased")
tokenizer.save_pretrained("E:\pythonProject\post_graduate\mmdet\mmdetection-dev-3.x\bert-base-uncased")
#################
model = dict(
type='GroundingDINO',
num_queries=900,
with_box_refine=True,
........
**i tried to run the code on 3090 GPU:**
cd mmdetection-dev-3.x
python tools/test.py configs/grounding_dino/grounding_dino_swin-t_finetune_8xb2_20e_cat.py https://download.openmmlab.com/mmdetection/v3.0/grounding_dino/groundingdino_swint_ogc_mmdet-822d7e9d.pth
`
whatever train or test,the same error occurs:
Traceback (most recent call last):
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf/pytree/pytree_utils.py", line 113, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 188, in parse_string
return self.parse_tokens(tokens, debug)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 157, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 230, in addtoken
return self._addtoken(ilabel, type, value, context)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 313, in _addtoken
raise ParseError('bad input', type, value, context)
yapf_third_party._ylib2to3.pgen2.parse.ParseError: bad input: type=20, value='<', context=('', (1, 14))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf/yapflib/yapf_api.py", line 198, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf/pytree/pytree_utils.py", line 116, in ParseCodeToTree
ast.parse(code)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/ast.py", line 47, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 1
AutoTokenizer=<class 'transformers.models.auto.tokenization_auto.AutoTokenizer'>
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/mmengine/config/config.py", line 1483, in pretty_text
text, _ = FormatCode(text, style_config=yapf_style)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/yapf/yapflib/yapf_api.py", line 201, in FormatCode
raise errors.YapfError(errors.FormatErrorMsg(e))
yapf.yapflib.errors.YapfError: <unknown>:1:15: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/test.py", line 149, in <module>
main()
File "tools/test.py", line 131, in main
runner = Runner.from_cfg(cfg)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/mmengine/runner/runner.py", line 462, in from_cfg
runner = cls(
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/mmengine/runner/runner.py", line 403, in init
self._log_env(env_cfg)
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/mmengine/runner/runner.py", line 2388, in _log_env
self.logger.info(f'Config:\n{self.cfg.pretty_text}')
File "/home/dell/Software/Anaconda3/envs/mmdet/lib/python3.8/site-packages/mmengine/config/config.py", line 1488, in pretty_text
raise SyntaxError('Failed to format the config file, please '
SyntaxError: Failed to format the config file, please check the syntax of:
AutoTokenizer=<class 'transformers.models.auto.tokenization_auto.AutoTokenizer'>
BertConfig=<class 'transformers.models.bert.configuration_bert.BertConfig'>
BertModel=<class 'transformers.models.bert.modeling_bert.BertModel'>
auto_scale_lr=dict(
base_batch_size=16,
enable=False)
backend_args=None
class_name=(
'cat',
)
data_root='data/'
dataset_type='CocoDataset'
default_hooks=dict(
checkpoint=dict(
.........
i think there might be something wrong in my steps,but i cant figure it out,i also tried to run on windows with different torch versions,but the error still occurs,maybe i didnt put the bert-base-uncased code in the correct position,looking forward to your reply