Code for the paper "MASTER: Multi-Aspect Non-local Network for Scene Text Recognition" (Pattern Recognition 2021)

Overview

MASTER-PyTorch

PyTorch reimplementation of "MASTER: Multi-Aspect Non-local Network for Scene Text Recognition" (Pattern Recognition 2021). This project is different from our original implementation that builds on the privacy codebase FastOCR of the company. You can also find Tensorflow reimplementation at MASTER-TF repository, and the performance is almost identical. (PS. Logo inspired by the Master Oogway in Kung Fu Panda)

Honors based on MASTER

Contents

Introduction

MASTER is a self-attention based scene text recognizer that (1) not only encodes the input-output attention, but also learns self-attention which encodes feature-feature and target-target relationships inside the encoder and decoder and (2) learns a more powerful and robust intermediate representation to spatial distortion and (3) owns a better training and evaluation efficiency. Overall architecture shown follows.

Requirements

  • python==3.6
  • torchvision==0.6.1
  • pandas==1.0.5
  • torch==1.5.1
  • numpy==1.16.4
  • tqdm==4.47.0
  • Distance==0.1.3
  • Pillow==7.2.0
pip install -r requirements.txt

Usage

Prepare Datasets

  1. Prepare the correct format of files as provided in data folder.
  2. Modify train_dataset and val_dataset args in config.json file, including txt_file, img_root, img_w, img_h.
  3. Modify keys.txt in utils/keys.txt file if needed according to the vocabulary of your dataset.
  4. Modify STRING_MAX_LEN in utils/label_util.py file if needed according to the text length of your dataset.

Distributed training with config files

Modify the configurations in configs/config.json and dist_train.sh files, then run:

bash dist_train.sh

The application will be launched via launch.py on a 4 GPU node with one process per GPU (recommend).

This is equivalent to

python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=4 \
--master_addr=127.0.0.1 --master_port=5555 \
train.py -c configs/config.json -d 1,2,3,4 --local_world_size 4

and is equivalent to specify indices of available GPUs by CUDA_VISIBLE_DEVICES instead of -d args

CUDA_VISIBLE_DEVICES=1,2,3,4 python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=4 \
--master_addr=127.0.0.1 --master_port=5555 \
train.py -c configs/config.json --local_world_size 4

Similarly, it can be launched with a single process that spans all 4 GPUs (if node has 4 available GPUs) using (don't recommend):

CUDA_VISIBLE_DEVICES=1,2,3,4 python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=1 \
--master_addr=127.0.0.1 --master_port=5555 \
train.py -c configs/config.json --local_world_size 1

Using Multiple Node

You can enable multi-node multi-GPU training by setting nnodes and node_rank args of the commandline line on every node. e.g., 2 nodes 4 gpus run as follows

Node 1, ip: 192.168.0.10, then run on node 1 as follows

CUDA_VISIBLE_DEVICES=1,2,3,4 python -m torch.distributed.launch --nnodes=2 --node_rank=0 --nproc_per_node=4 \
--master_addr=192.168.0.10 --master_port=5555 \
train.py -c configs/config.json --local_world_size 4  

Node 2, ip: 192.168.0.15, then run on node 2 as follows

CUDA_VISIBLE_DEVICES=2,4,6,7 python -m torch.distributed.launch --nnodes=2 --node_rank=1 --nproc_per_node=4 \
--master_addr=192.168.0.10 --master_port=5555 \
train.py -c configs/config.json --local_world_size 4  

Debug mode on one GPU/CPU training with config files

This option of training mode can debug code without distributed way. -dist must set to false to turn off distributed mode. -d specify which one gpu will be used.

python train.py -c configs/config.json -d 1 -dist false

Resuming from checkpoints

You can resume from a previously saved checkpoint by:

python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=4 \
--master_addr=127.0.0.1 --master_port=5555 \
train.py -d 1,2,3,4 --local_world_size 4 --resume path/to/checkpoint

Finetune from checkpoints

You can finetune from a previously saved checkpoint by:

python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=4 \
--master_addr=127.0.0.1 --master_port=5555 \
train.py -d 1,2,3,4 --local_world_size 4 --resume path/to/checkpoint --finetune true

Testing from checkpoints

You can predict from a previously saved checkpoint by:

python test.py --checkpoint path/to/checkpoint --img_folder path/to/img_folder \
               --width 160 --height 48 \
               --output_folder path/to/output_folder \
               --gpu 0 --batch_size 64

Note: width and height must be the same as the settings used during training.

Evaluation

Evaluate squence accuracy and edit distance accuracy:

python utils/calculate_metrics.py --predict-path predict_result.json --label-path label.txt

Note: label.txt: multi-line, every line containing {ImageFile:<ImageFile>, Label:<TextLabel>}

Customization

Checkpoints

You can specify the name of the training session in config.json files:

"name": "MASTER_Default",
"run_id": "example"

The checkpoints will be saved in save_dir/name/run_id_timestamp/checkpoint_epoch_n, with timestamp in mmdd_HHMMSS format.

A copy of config.json file will be saved in the same folder.

Note: checkpoints contain:

{
  'arch': arch,
  'epoch': epoch,
  'model_state_dict': self.model.state_dict(),
  'optimizer': self.optimizer.state_dict(),
  'monitor_best': self.monitor_best,
  'config': self.config
}

Tensorboard Visualization

This project supports Tensorboard visualization by using either torch.utils.tensorboard or TensorboardX.

  1. Install

    If you are using pytorch 1.1 or higher, install tensorboard by 'pip install tensorboard>=1.14.0'.

    Otherwise, you should install tensorboardx. Follow installation guide in TensorboardX.

  2. Run training

    Make sure that tensorboard option in the config file is turned on.

     "tensorboard" : true
    
  3. Open Tensorboard server

    Type tensorboard --logdir saved/log/ at the project root, then server will open at http://localhost:6006

By default, values of loss will be logged. If you need more visualizations, use add_scalar('tag', data), add_image('tag', image), etc in the trainer._train_epoch method. add_something() methods in this project are basically wrappers for those of tensorboardX.SummaryWriter and torch.utils.tensorboard.SummaryWriter modules.

Note: You don't have to specify current steps, since WriterTensorboard class defined at logger/visualization.py will track current steps.

TODO

  • Memory-Cache based Inference

Citations

If you find MASTER useful please cite our paper:

@article{Lu2021MASTER,
  title={{MASTER}: Multi-Aspect Non-local Network for Scene Text Recognition},
  author={Ning Lu and Wenwen Yu and Xianbiao Qi and Yihao Chen and Ping Gong and Rong Xiao and Xiang Bai},
  journal={Pattern Recognition},
  year={2021}
}

License

This project is licensed under the MIT License. See LICENSE for more details.

Acknowledgements

Comments
  • 使用debug模式进行单gpu训练报错,显示堆栈溢出

    使用debug模式进行单gpu训练报错,显示堆栈溢出

    您好,我在尝试使用debug模式进行单gpu训练时报错,暂时找不到原因? (torch) zhangzr@AI12:~/MASTER-pytorch-main$ python train.py -c configs/config.json -d 1 -dist false [2021-07-11 18:34:01,939 - train - INFO] - One GPU or CPU training mode start... train.py:137: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead logger.warn('You have chosen to deterministic training. ' [2021-07-11 18:34:01,943 - train - WARNING] - You have chosen to deterministic training. This will fix random seed, turn on the CUDNN deterministic setting, turn off the CUDNN benchmark which can slow down your training considerably! [2021-07-11 18:34:02,568 - train - INFO] - Dataloader instances have finished. Train datasets: 3067 Val datasets: 2 Train_batch_size/gpu: 8 Val_batch_size/gpu: 8. [2021-07-11 18:34:04,382 - train - INFO] - Model created, trainable parameters: 54600257. [2021-07-11 18:34:04,383 - train - INFO] - Optimizer and lr_scheduler created. [2021-07-11 18:34:04,383 - train - INFO] - Max_epochs: 600 Log_step_interval: 1 Validation_step_interval: 2000. [2021-07-11 18:34:04,383 - train - INFO] - Training start... [2021-07-11 18:34:04,412 - trainer - WARNING] - Training is using GPU 0! Fatal Python error: Cannot recover from stack overflow. Python runtime state: initialized

    Current thread 0x00007f13c82e3340 (most recent call first): File "/home/zhangzr/anaconda3/envs/torch/lib/python3.8/site-packages/PIL/_util.py", line 6 in isPath File "/home/zhangzr/anaconda3/envs/torch/lib/python3.8/site-packages/PIL/Image.py", line 2964 in open File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 78 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem File "/home/zhangzr/MASTER-pytorch-main/data_utils/datasets.py", line 101 in getitem ... Aborted (core dumped)

    opened by zezeze97 2
  • 预测脚本有bug

    预测脚本有bug

    您好,我在使用您的代码进行预测时报错: (torch) zhangzr@AI12:~/MASTER-pytorch-main$ python test.py --checkpoint /home/zhangzr/model_output/master_saved/models/MASTER_Default/example_0712_205619/model_best.pth --img_folder /home/zhangzr/table2latex_data/Training_TSR/train_images --width 400 --height 400 --output_folder /home/zhangzr/model_output/test --gpu 1 --batch_size 4 Loading checkpoint: /home/zhangzr/model_output/master_saved/models/MASTER_Default/example_0712_205619/model_best.pth with saved best metric 0.0000 test data size: 43138 steps: 10785 0it [00:00, ?it/s] Traceback (most recent call last): File "test.py", line 128, in predict(args) File "test.py", line 73, in predict outputs, probs = decode_util.greedy_decode_with_probability(model, images, LabelTransformer.max_length, TypeError: greedy_decode_with_probability() got an unexpected keyword argument 'padding_symbol'

    opened by zezeze97 1
  • fix combine 2 lmdb dataset

    fix combine 2 lmdb dataset

    Last commit met problem of incorrectly loading image_keys and label_keys and making the model not converge. This commit edit way to combine lmdb dataset ST+ MJ using torch.utils.data.ConcatDataset

    opened by cuongngm 1
  • 这一行代码要删除掉,不然回报错

    这一行代码要删除掉,不然回报错

    https://github.com/wenwenyu/MASTER-pytorch/blob/a8fdc2a658b6767fea5f3e84900fc57c85f0d372/data_utils/crop_synthtext.py#L281

    报错 ··· AttributeError: 'Process' object has no attribute 'close'···

    opened by jaffe-fly 1
  • test.py运行报错

    test.py运行报错

    Loading checkpoint: /1/dl_pzx/MASTER-pytorch/model_output/master_saved/models/MASTER_Default/example_0314_212753/model_best.pth with saved best metric 0.9623 test data size: 2 steps: 2 0%| | 0/2 [00:00<?, ?it/s]Fatal Python error: Cannot recover from stack overflow.

    Current thread 0x00007fe5b3b2b3c0 (most recent call first): File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/PIL/_util.py", line 6 in isPath File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/PIL/Image.py", line 2971 in open File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 82 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem File "/1/dl_pzx/MASTER-pytorch/data_utils/datasets.py", line 104 in getitem ... 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 990, in _try_get_data data = self._data_queue.get(timeout=timeout) File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/multiprocessing/queues.py", line 104, in get if not self._poll(timeout): File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/multiprocessing/connection.py", line 257, in poll return self._poll(timeout) File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/multiprocessing/connection.py", line 414, in _poll r = wait([self], timeout) File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/multiprocessing/connection.py", line 921, in wait ready = selector.select(timeout) File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/selectors.py", line 415, in select fd_event_list = self._selector.poll(timeout) File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler _error_if_any_worker_fails() RuntimeError: DataLoader worker (pid 31156) is killed by signal: Aborted.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last): File "/1/dl_pzx/MASTER-pytorch/test.py", line 130, in predict(args) File "/1/dl_pzx/MASTER-pytorch/test.py", line 61, in predict for step_idx, input_data_item in tqdm(enumerate(test_data_loader),total=len(test_data_loader)): File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/tqdm/std.py", line 1185, in iter for obj in iterable: File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1186, in _next_data idx, data = self._get_data() File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1152, in _get_data success, data = self._try_get_data() File "/home/dell10/anaconda3/envs/pzx/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1003, in _try_get_data raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly error is {}'.format(pids_str,e)) from e RuntimeError: DataLoader worker (pid(s) 31156) exited unexpectedly error is DataLoader worker (pid 31156) is killed by signal: Aborted.

    bs设置为了1,num_worker也为1,DataLoader报错的pid也一直在变化,请问是什么原因?

    opened by imMid-Star 0
  • 预测问题

    预测问题

    我训练尺寸是48*240,短文本识别效果蛮好,但是长文本就几乎全错了。 有时候还会出现这类现象:比如图像上内容是“年龄:15”,但是预测结果却是“年龄:1555555555555555555555555555555555555555555555555......”好多个。 请问对该问题有什么看法吗?

    opened by VixeruntR 0
  • Validation 精度很高,但是 test 精度很低

    Validation 精度很高,但是 test 精度很低

    我使用了你们提供的 lmdb 数据集来复现论文结果,训练过程中的验证集精度很高:

    [2021-10-30 06:14:34,656 - trainer - INFO] - [Step Validation] Epoch:[3/16] Step:[24000/24898] Word_acc: 0.961988 Word_acc_case_ins 0.976946Edit_distance_acc: 0.980846
    [2021-10-30 06:14:36,834 - trainer - INFO] - Saving checkpoint: /root/paddlejob/workspace/output/models/MASTER_Default/example_1027_102421/checkpoint-epoch3-step24000.pdparams ...
    [2021-10-30 06:14:42,358 - trainer - INFO] - Saving current best (at 3 epoch): model_best.pdparams Best word_acc: 0.961988
    

    但是使用 test.py 读取 lmdb evaluation 数据集进行预测时得到的 Sequence Accuracy 却相去甚远。而我把 lmdb 格式的数据读取成 Image 格式并保存成 jpg 图片后再使用 test.py 预测,能得到不错的 Case_ins 精度的结果,但是 Sequence Accuracy 还是很低:

    calculating metrics of IC03_867_pred
    current sample idx: 0
    2021-11-08 20:50:58,762 root  INFO     Sequence Accuracy: 0.429066 Case_ins: 0.950404
    2021-11-08 20:50:58,762 root  INFO     Edit Distance Accuracy: 0.494192
    

    我看到读取训练集时 transform 参数是这个类:CustomImagePreprocess,但是 test.py 的 transform 却是这个类:ResizeWeight,它们的作用都是 resize。test.py 默认读取的图片数据不是 lmdb,那么我换成直接读取 lmdb 格式的测试集:test.py,并使用跟读取训练集时 transform 参数同一个 CustomImagePreprocess 得到的测试精度就会很低。请问是什么原因呢?

    还有一个问题,config_lmdb.json 中指定的 n_class 应该是论文中说的 66 类吧?

    请问论文中这个表格的精度是 Case_ins 精度吗?

    opened by S-HuaBomb 1
Owner
Wenwen Yu
Hello World
Wenwen Yu
[CVPR 21] Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021.

Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, CVPR 2021. Ayan Kumar Bhunia, Pinaki nath Chowdhury, Yongxin Yan

Ayan Kumar Bhunia 44 Dec 12, 2022
Jittor Medical Segmentation Lib -- The assignment of Pattern Recognition course (2021 Spring) in Tsinghua University

THU模式识别2021春 -- Jittor 医学图像分割 模型列表 本仓库收录了课程作业中同学们采用jittor框架实现的如下模型: UNet SegNet DeepLab V2 DANet EANet HarDNet及其改动HarDNet_alter PSPNet OCNet OCRNet DL

null 48 Dec 26, 2022
Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition

Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition

null 107 Dec 2, 2022
Unified unsupervised and semi-supervised domain adaptation network for cross-scenario face anti-spoofing, Pattern Recognition

USDAN The implementation of Unified unsupervised and semi-supervised domain adaptation network for cross-scenario face anti-spoofing, which is accepte

null 11 Nov 3, 2022
BADet: Boundary-Aware 3D Object Detection from Point Clouds (Pattern Recognition 2022)

BADet: Boundary-Aware 3D Object Detection from Point Clouds (Pattern Recognition

Rui Qian 17 Dec 12, 2022
FindFunc is an IDA PRO plugin to find code functions that contain a certain assembly or byte pattern, reference a certain name or string, or conform to various other constraints.

FindFunc: Advanced Filtering/Finding of Functions in IDA Pro FindFunc is an IDA Pro plugin to find code functions that contain a certain assembly or b

null 213 Dec 17, 2022
a spacial-temporal pattern detection system for home automation

Argos a spacial-temporal pattern detection system for home automation. Based on OpenCV and Tensorflow, can run on raspberry pi and notify HomeAssistan

Angad Singh 133 Jan 5, 2023
Deep Halftoning with Reversible Binary Pattern

Deep Halftoning with Reversible Binary Pattern ICCV Paper | Project Website | BibTex Overview Existing halftoning algorithms usually drop colors and f

Menghan Xia 17 Nov 22, 2022
Local Similarity Pattern and Cost Self-Reassembling for Deep Stereo Matching Networks

Local Similarity Pattern and Cost Self-Reassembling for Deep Stereo Matching Networks Contributions A novel pairwise feature LSP to extract structural

null 31 Dec 6, 2022
Decision Transformer: A brand new Offline RL Pattern

DecisionTransformer_StepbyStep Intro Decision Transformer: A brand new Offline RL Pattern. 这是关于NeurIPS 2021 热门论文Decision Transformer的复现。 ?? 原文地址: Deci

Irving 14 Nov 22, 2022
Code of the lileonardo team for the 2021 Emotion and Theme Recognition in Music task of MediaEval 2021

Emotion and Theme Recognition in Music The repository contains code for the submission of the lileonardo team to the 2021 Emotion and Theme Recognitio

Vincent Bour 8 Aug 2, 2022
PyTorch code of my ICDAR 2021 paper Vision Transformer for Fast and Efficient Scene Text Recognition (ViTSTR)

Vision Transformer for Fast and Efficient Scene Text Recognition (ICDAR 2021) ViTSTR is a simple single-stage model that uses a pre-trained Vision Tra

Rowel Atienza 198 Dec 27, 2022
Code for the RA-L (ICRA) 2021 paper "SeqNet: Learning Descriptors for Sequence-Based Hierarchical Place Recognition"

SeqNet: Learning Descriptors for Sequence-Based Hierarchical Place Recognition [ArXiv+Supplementary] [IEEE Xplore RA-L 2021] [ICRA 2021 YouTube Video]

Sourav Garg 63 Dec 12, 2022
The LaTeX and Python code for generating the paper, experiments' results and visualizations reported in each paper is available (whenever possible) in the paper's directory

This repository contains the software implementation of most algorithms used or developed in my research. The LaTeX and Python code for generating the

João Fonseca 3 Jan 3, 2023
PyTorch reimplementation of the paper Involution: Inverting the Inherence of Convolution for Visual Recognition [CVPR 2021].

Involution: Inverting the Inherence of Convolution for Visual Recognition Unofficial PyTorch reimplementation of the paper Involution: Inverting the I

Christoph Reich 100 Dec 1, 2022
This repository is an open-source implementation of the ICRA 2021 paper: Locus: LiDAR-based Place Recognition using Spatiotemporal Higher-Order Pooling.

Locus This repository is an open-source implementation of the ICRA 2021 paper: Locus: LiDAR-based Place Recognition using Spatiotemporal Higher-Order

Robotics and Autonomous Systems Group 96 Dec 15, 2022
Official implementation for ICDAR 2021 paper "Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer"

Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer Description Convert offline handwritten mathematical expressi

Wenqi Zhao 87 Dec 27, 2022
Inference code for "StylePeople: A Generative Model of Fullbody Human Avatars" paper. This code is for the part of the paper describing video-based avatars.

NeuralTextures This is repository with inference code for paper "StylePeople: A Generative Model of Fullbody Human Avatars" (CVPR21). This code is for

Visual Understanding Lab @ Samsung AI Center Moscow 18 Oct 6, 2022
[CVPR 2021] Released code for Counterfactual Zero-Shot and Open-Set Visual Recognition

Counterfactual Zero-Shot and Open-Set Visual Recognition This project provides implementations for our CVPR 2021 paper Counterfactual Zero-S

null 144 Dec 24, 2022