mxin262 / ESTextSpotter

(ICCV 2023) ESTextSpotter: Towards Better Scene Text Spotting with Explicit Synergy in Transformer
72 stars 7 forks source link

UnboundLocalError: local variable 'output_rec' referenced before assignment #3

Closed YuMJie closed 1 year ago

YuMJie commented 1 year ago

When I run the code bash scripts/Pretrain.sh /path/to/your/dataset The code line if dn_meta and dn_meta['pad_size'] > 0: is False, which causes

2023-10-08T01:57:36.081286320Z   File "main.py", line 388, in <module>
2023-10-08T01:57:36.081436633Z     main(args)
2023-10-08T01:57:36.081439500Z   File "main.py", line 299, in main
2023-10-08T01:57:36.081513158Z     train_stats = train_one_epoch(
2023-10-08T01:57:36.081528337Z   File "/code/engine.py", line 50, in train_one_epoch
2023-10-08T01:57:36.081543318Z     outputs = model(samples, targets)
2023-10-08T01:57:36.081546900Z   File "/root/miniconda3/envs/ESTS/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
2023-10-08T01:57:36.081702549Z     return forward_call(*input, **kwargs)
2023-10-08T01:57:36.081707533Z   File "/root/miniconda3/envs/ESTS/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 886, in forward
2023-10-08T01:57:36.081823121Z     output = self.module(*inputs[0], **kwargs[0])
2023-10-08T01:57:36.081827242Z   File "/root/miniconda3/envs/ESTS/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
2023-10-08T01:57:36.081951831Z     return forward_call(*input, **kwargs)
2023-10-08T01:57:36.081955473Z   File "/code/models/ests/ests.py", line 316, in forward
2023-10-08T01:57:36.082017499Z     dn_post_process(outputs_class, outputs_coord_list, outputs_beziers_list, outputs_rec_list,
2023-10-08T01:57:36.082021148Z   File "/code/models/ests/dn_components.py", line 168, in dn_post_process
2023-10-08T01:57:36.082060873Z     return outputs_class, outputs_coord, outputs_beziers, output_rec
2023-10-08T01:57:36.082073189Z UnboundLocalError: local variable 'output_rec' referenced before assignment

How can I fix it? Thank you!

mxin262 commented 1 year ago

Can you provide more detail? I can't reproduce this problem

YuMJie commented 1 year ago

Can you provide more detail? I can't reproduce this problem

Thank for your reply! I set the --train_dataset totaltext_train:ic13_train \ and due to the limitation of the memory, the batch_size = 1 is set. Others are set as same as the original code. What is more, it sometime can run correctly if set --train_dataset totaltext_train \ , I provide the structure tree of the dataset as follow:

├── CTW1500
│   ├── annotations
│   ├── ctwtest_text_image
│   ├── ctwtrain_text_image
│   ├── weak_voc_new.txt
│   └── weak_voc_pair_list.txt
├── icdar2013
│   ├── ic13_train.json
│   └── train_images
├── icdar2015_all
│   ├── GenericVocabulary.txt
│   ├── GenericVocabulary_new.txt
│   ├── GenericVocabulary_pair_list.txt
│   ├── ch4_test_vocabulary.txt
│   ├── ch4_test_vocabulary_new.txt
│   ├── ch4_test_vocabulary_pair_list.txt
│   ├── ic15_test.json
│   ├── ic15_train.json
│   ├── new_strong_lexicon
│   ├── strong_lexicon
│   ├── test_images
│   └── train_images
├── mlt2017
│   ├── MLT_train_images
│   ├── images
│   └── train.json
├── syntext1
│   ├── images
│   ├── syntext_word_eng
│   └── train.json
├── syntext2
│   ├── emcs_imgs
│   ├── images
│   └── train.json
└── totaltext
    ├── test.json
    ├── test_images
    ├── train.json
    ├── train_images
    ├── weak_voc_new.txt
    └── weak_voc_pair_list.txt

Looking forward to your reply!

mxin262 commented 1 year ago

You can try using the new file

YuMJie commented 1 year ago

You can try using the new file

Thank for your help, I can correctly run the code with your method!