GithubHelp home page GithubHelp logo

yuxiang1995 / icdar2021_mfd Goto Github PK

View Code? Open in Web Editor NEW
124.0 3.0 42.0 18.96 MB

1st Solution For ICDAR 2021 Competition on Mathematical Formula Detection(公式检测冠军方案)

License: Apache License 2.0

Python 99.89% Shell 0.08% Dockerfile 0.03%

icdar2021_mfd's Introduction

Update

25/12/2022: Fix the bug that resnest does not converge. Provide the download link of model trained with gfl_s50_fpn_2x_coco.py.

16/06/2022: Add the download link for Dataset

About The Project

This project releases our 1st place solution on ICDAR 2021 Competition on Mathematical Formula Detection. We implement our solution based on MMDetection, which is an open source object detection toolbox based on PyTorch. You can click here for more details about this competition.

Method Description

We built our approach on FCOS, A simple and strong anchor-free object detector, with ResNeSt as our backbone, to detect embedded and isolated formulas. We employed ATSS as our sampling strategy instead of random sampling to eliminate the effects of sample imbalance. Moreover, we observed and revealed the influence of different FPN levels on the detection result. Generalized Focal Loss is adopted to our loss. Finally, with a series of useful tricks and model ensembles, our method was ranked 1st in the MFD task.

Random Sampling(left) ATSS(right) Random Sampling(left) ATSS(right)

Getting Start

Prerequisites

  • Linux or macOS (Windows is in experimental support)
  • Python 3.6~3.8
  • PyTorch 1.3+
  • CUDA 9.2+ (If you build PyTorch from source, CUDA 9.0 is also compatible)
  • GCC 5+
  • MMCV

This project is based on MMDetection-v2.7.0, mmcv-full>=1.1.5, <1.3 is needed. Note: You need to run pip uninstall mmcv first if you have mmcv installed. If mmcv and mmcv-full are both installed, there will be ModuleNotFoundError.

If you are using A100, it is recommended to use pytorch==1.7.0+cu110 and mmcv==1.2.7

  conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch
  pip install mmcv-full==1.2.7 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7/index.html

Installation

  1. Install PyTorch and torchvision following the official instructions , e.g.,

    pip install pytorch torchvision -c pytorch

    Note: Make sure that your compilation CUDA version and runtime CUDA version match. You can check the supported CUDA version for precompiled packages on the PyTorch website.

    E.g.1 If you have CUDA 10.1 installed under /usr/local/cuda and would like to install PyTorch 1.5, you need to install the prebuilt PyTorch with CUDA 10.1.

    pip install pytorch cudatoolkit=10.1 torchvision -c pytorch

    E.g. 2 If you have CUDA 9.2 installed under /usr/local/cuda and would like to install PyTorch 1.3.1., you need to install the prebuilt PyTorch with CUDA 9.2.

    pip install pytorch=1.3.1 cudatoolkit=9.2 torchvision=0.4.2 -c pytorch

    If you build PyTorch from source instead of installing the prebuilt pacakge, you can use more CUDA versions such as 9.0.

  2. Install mmcv-full, we recommend you to install the pre-build package as below.

    pip install mmcv-full==latest+torch1.6.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html

    See here for different versions of MMCV compatible to different PyTorch and CUDA versions. Optionally you can choose to compile mmcv from source by the following command

    git clone https://github.com/open-mmlab/mmcv.git
    cd mmcv
    MMCV_WITH_OPS=1 pip install -e .  # package mmcv-full will be installed after this step
    cd ..

    Or directly run

    pip install mmcv-full
  3. Install build requirements and then compile MMDetection.

    pip install -r requirements.txt
    pip install tensorboard
    pip install ensemble-boxes
    pip install -v -e .  # or "python setup.py develop"

Usage

Data Preparation

Now, the organizer provides a free download link for Dataset

Firstly, you need to put the image files and the GT files into two separate folders as below.

Tr01
├── gt
│   ├── 0001125-color_page02.txt
│   ├── 0001125-color_page05.txt
│   ├── ...
│   └── 0304067-color_page08.txt
├── img
    ├── 0001125-page02.jpg
    ├── 0001125-page05.jpg
    ├── ...
    └── 0304067-page08.jpg

Secondly, run data_preprocess.py to get coco format label. Remember to change 'img_path', 'txt_path', 'dst_path' and 'train_path' to your own path.

python ./tools/data_preprocess.py

The new structure of data folder will become,

Tr01
├── gt
│   ├── 0001125-color_page02.txt
│   ├── 0001125-color_page05.txt
│   ├── ...
│   └── 0304067-color_page08.txt
│
├── gt_icdar
│   ├── 0001125-color_page02.txt
│   ├── 0001125-color_page05.txt
│   ├── ...
│   └── 0304067-color_page08.txt
│   
├── img
│   ├── 0001125-page02.jpg
│   ├── 0001125-page05.jpg
│   ├── ...
│   └── 0304067-page08.jpg
│
└── train_coco.json

Finally, change 'data_root' in ./configs/base/datasets/formula_detection.py to your path.

Train

  1. train with single gpu on ResNeSt50

    python tools/train.py configs/gfl/gfl_s50_fpn_2x_coco.py --gpus 1 --work-dir ${Your Dir}
  2. train with 8 gpus on ResNeSt101

    ./tools/dist_train.sh configs/gfl/gfl_s101_fpn_2x_coco.py 8 --work-dir ${Your Dir}

Inference

Run tools/test_formula.py

python tools/test_formula.py configs/gfl/gfl_s101_fpn_2x_coco.py ${checkpoint path} 

It will generate a 'result' file at the same level with work-dir in default. You can specify the output path of the result file in line 231.

Model Ensemble

Specify the paths of the results in tools/model_fusion_test.py, and run

python tools/model_fusion_test.py

Evaluation

evaluate.py is the officially provided evaluation tool. Run

python evaluate.py ${GT_DIR} ${CSV_Pred_File}

Note: GT_DIR is the path of the original data folder which contains both the image and the GT files. CSV_Pred_File is the path of the final prediction csv file.

Result

Train on Tr00, Tr01, Va00 and Va01, and test on Ts01. Some results are as follows, F1-score

Method embedded isolated total
ResNeSt50-DCN 95.67 97.67 96.03
ResNeSt101-DCN 96.11 97.75 96.41

Our final result, that was ranked 1st place in the competition, was obtained by fusing two Resnest101+GFL models trained with two different random seeds and all labeled data. The final ranking can be seen in our technical report.

License

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

Citations

@article{zhong20211st,
  title={1st Place Solution for ICDAR 2021 Competition on Mathematical Formula Detection},
  author={Zhong, Yuxiang and Qi, Xianbiao and Li, Shanjun and Gu, Dengyi and Chen, Yihao and Ning, Peiyang and Xiao, Rong},
  journal={arXiv preprint arXiv:2107.05534},
  year={2021}
}
@article{GFLli2020generalized,
  title={Generalized focal loss: Learning qualified and distributed bounding boxes for dense object detection},
  author={Li, Xiang and Wang, Wenhai and Wu, Lijun and Chen, Shuo and Hu, Xiaolin and Li, Jun and Tang, Jinhui and Yang, Jian},
  journal={arXiv preprint arXiv:2006.04388},
  year={2020}
}
@inproceedings{ATSSzhang2020bridging,
  title={Bridging the gap between anchor-based and anchor-free detection via adaptive training sample selection},
  author={Zhang, Shifeng and Chi, Cheng and Yao, Yongqiang and Lei, Zhen and Li, Stan Z},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={9759--9768},
  year={2020}
}
@inproceedings{FCOStian2019fcos,
  title={Fcos: Fully convolutional one-stage object detection},
  author={Tian, Zhi and Shen, Chunhua and Chen, Hao and He, Tong},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={9627--9636},
  year={2019}
}
@article{solovyev2019weighted,
  title={Weighted boxes fusion: ensembling boxes for object detection models},
  author={Solovyev, Roman and Wang, Weimin and Gabruseva, Tatiana},
  journal={arXiv preprint arXiv:1910.13302},
  year={2019}
}
@article{ResNestzhang2020resnest,
  title={Resnest: Split-attention networks},
  author={Zhang, Hang and Wu, Chongruo and Zhang, Zhongyue and Zhu, Yi and Lin, Haibin and Zhang, Zhi and Sun, Yue and He, Tong and Mueller, Jonas and Manmatha, R and others},
  journal={arXiv preprint arXiv:2004.08955},
  year={2020}
}
@article{MMDetectionchen2019mmdetection,
  title={MMDetection: Open mmlab detection toolbox and benchmark},
  author={Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and Liu, Ziwei and Xu, Jiarui and others},
  journal={arXiv preprint arXiv:1906.07155},
  year={2019}
}

Acknowledgements

icdar2021_mfd's People

Contributors

aemikachow avatar chrisfsj2051 avatar daavoo avatar erotemic avatar gt9505 avatar hellock avatar innerlee avatar johnson-wang avatar jshilong avatar korabelnikov avatar liaopeiyuan avatar lindahua avatar melikovk avatar michaelisc avatar mxbonn avatar myownskyw7 avatar oceanpang avatar runningleon avatar ryanxli avatar shinya7y avatar thangvubk avatar tianyuandu avatar v-qjqs avatar wangruohui avatar wswday avatar xvjiarui avatar yhcao6 avatar yuxiang1995 avatar yuzhj avatar zwwwayne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

icdar2021_mfd's Issues

what is the validation set?

In formula_detection.py, the annotation file is under Ts01, but the images are under Tr01. Also, the training set contains Va00, Va01. Shouldn't they belong to the validation set?

    val=dict(
        type=dataset_type,
        ann_file=data_root + 'Ts01/train_coco_sdk4.json',
        img_prefix=data_root + 'Tr01/img/',
        classes=classes,
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'Ts10/train_coco_sdk4.json',
        img_prefix=data_root + 'Tr10/img/',
        classes=classes,
        pipeline=test_pipeline))

Inference怎么用?

我想用你这个来试一下把公式的坐标从图片里面提取出来,但是不知道怎么用,我看到了Inference的说明,但是不明白这个checkpoint path需要放什么。我试过放mfd_gfl_s50.pth,但好像没有用。而且我还有个疑问,按理说我需要把待解析的图片传进去跑,但是要怎么传进去呢?
image

__missing__ raise Keyerror (name)

您好,您的repo和mmd官方代码我都试过了,都存在这个问题。数据集有什么特殊要求吗,正常的cocodataset style有问题
Traceback (most recent call last):
File "tools/train.py", line 188, in
main()
File "tools/train.py", line 164, in main
datasets = [build_dataset(cfg.data.train)]
File "/home/a/.local/lib/python3.7/site-packages/mmdet/datasets/builder.py", line 58, in build_dataset
elif cfg['type'] == 'ConcatDataset':
File "/home/a/.local/lib/python3.7/site-packages/mmcv/utils/config.py", line 35, in missing
raise KeyError(name)
KeyError: 'type'

Output Quality Focal Loss

To use the quality focal loss did you passed to it the quality score like [0.1 0.6 0.2 0.4] or you passed the onehot from the target like [0 1 0 0] ?

After 24 epoches trained, its loss still can't reach convergence

`2022-11-20 01:35:49,834 - mmdet - INFO - Epoch [24][2000/2174] lr: 1.000e-05, eta: 0:05:54, time: 2.101, data_time: 0.014, memory: 15795, loss_cls: 0.2582, loss_bbox: 1.2449, loss_dfl: 0.4970, loss: 2.0000
2022-11-20 01:37:34,752 - mmdet - INFO - Epoch [24][2050/2174] lr: 1.000e-05, eta: 0:04:12, time: 2.098, data_time: 0.014, memory: 15795, loss_cls: 0.2564, loss_bbox: 1.2549, loss_dfl: 0.4957, loss: 2.0070
2022-11-20 01:39:19,524 - mmdet - INFO - Epoch [24][2100/2174] lr: 1.000e-05, eta: 0:02:30, time: 2.095, data_time: 0.014, memory: 15795, loss_cls: 0.2651, loss_bbox: 1.2299, loss_dfl: 0.4924, loss: 1.9874
2022-11-20 01:41:04,317 - mmdet - INFO - Epoch [24][2150/2174] lr: 1.000e-05, eta: 0:00:48, time: 2.096, data_time: 0.013, memory: 15795, loss_cls: 0.2600, loss_bbox: 1.2279, loss_dfl: 0.4954, loss: 1.9832
2022-11-20 01:41:54,811 - mmdet - INFO - Saving checkpoint at 24 epochs
2022-11-20 01:44:58,555 - mmdet - INFO - Evaluating bbox...
2022-11-20 01:45:01,473 - mmdet - INFO -
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1000 ] = 0.000
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=1000 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.001
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.014
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 ] = 0.014
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1000 ] = 0.014
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.000
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.016

2022-11-20 01:45:01,502 - mmdet - INFO - Exp name: gfl_s50_fpn_2x_coco.py
2022-11-20 01:45:01,502 - mmdet - INFO - Epoch(val) [24][380] bbox_mAP: 0.0000, bbox_mAP_50: 0.0000, bbox_mAP_75: 0.0000, bbox_mAP_s: 0.0000, bbox_mAP_m: 0.0000, bbox_mAP_l: 0.0010, bbox_mAP_copypaste: 0.000 0.000 0.000 0.000 0.000 0.001
`

请问用resnest50训练后效果很差怎么办?

我是单卡titan xp,batchsize改成了2,然后训练时曾经报错显示不能从float转化为long类型,将一句关于分布式的代码改成直接返回tensor后能够训练了,但是loss一直停留在2左右,出来的结果也不好,可惜您无法提供训练好的模型,我再找找其他的吧。

Failed building wheel for mmpycocotools during requirements installation

Hi Team, As per github manual trying to install all the packages step by step. But following command troughing error. I am using DGX A100, python 3.8.12, pytorch==1.7.0+cu110 and mmcv-full==1.2.7

I am getting following error.
Running setup.py install for mmpycocotools ... error
error: subprocess-exited-with-error

Failed to build mmpycocotools
ERROR: Could not build wheels for mmpycocotools, which is required to install pyproject.toml-based projects

Complete error details mentioned below. Please guide.

(fcos4) root@pt-brhac-55cf55d5c8-rptrd:/workspace/nemo/ICDAR2021_MFD# pip install -r requirements.txt
Collecting cython
Using cached Cython-3.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB)
Requirement already satisfied: numpy in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from -r requirements/build.txt (line 3)) (1.21.5)
Collecting matplotlib
Using cached matplotlib-3.5.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)
Collecting mmpycocotools
Using cached mmpycocotools-12.0.3.tar.gz (23 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: six in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from -r requirements/runtime.txt (line 4)) (1.16.0)
Collecting terminaltables
Using cached terminaltables-3.1.10-py2.py3-none-any.whl (15 kB)
Collecting asynctest
Using cached asynctest-0.13.0-py3-none-any.whl (26 kB)
Collecting codecov
Using cached codecov-2.1.13-py2.py3-none-any.whl (16 kB)
Collecting flake8
Using cached flake8-5.0.4-py2.py3-none-any.whl (61 kB)
Collecting interrogate
Using cached interrogate-1.5.0-py3-none-any.whl (45 kB)
Collecting isort==4.3.21
Using cached isort-4.3.21-py2.py3-none-any.whl (42 kB)
Collecting kwarray
Using cached kwarray-0.6.14-py3-none-any.whl (106 kB)
Collecting pytest
Using cached pytest-7.4.2-py3-none-any.whl (324 kB)
Collecting ubelt
Using cached ubelt-1.3.3-py3-none-any.whl (217 kB)
Collecting xdoctest>=0.10.0
Using cached xdoctest-1.1.1-py3-none-any.whl (137 kB)
Requirement already satisfied: yapf in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from -r requirements/tests.txt (line 11)) (0.40.2)
Collecting kiwisolver>=1.0.1
Using cached kiwisolver-1.4.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB)
Collecting packaging>=20.0
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting cycler>=0.10
Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting fonttools>=4.22.0
Using cached fonttools-4.38.0-py3-none-any.whl (965 kB)
Collecting python-dateutil>=2.7
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pyparsing>=2.2.1
Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)
Requirement already satisfied: pillow>=6.2.0 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from matplotlib->-r requirements/runtime.txt (line 1)) (9.4.0)
Requirement already satisfied: setuptools>=18.0 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from mmpycocotools->-r requirements/runtime.txt (line 2)) (65.6.3)
Collecting coverage
Using cached coverage-7.2.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225 kB)
Requirement already satisfied: requests>=2.7.9 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from codecov->-r requirements/tests.txt (line 2)) (2.28.1)
Collecting mccabe<0.8.0,>=0.7.0
Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Collecting pycodestyle<2.10.0,>=2.9.0
Using cached pycodestyle-2.9.1-py2.py3-none-any.whl (41 kB)
Collecting importlib-metadata<4.3,>=1.1.0
Using cached importlib_metadata-4.2.0-py3-none-any.whl (16 kB)
Collecting pyflakes<2.6.0,>=2.5.0
Using cached pyflakes-2.5.0-py2.py3-none-any.whl (66 kB)
Collecting click>=7.1
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Collecting py
Using cached py-1.11.0-py2.py3-none-any.whl (98 kB)
Collecting tabulate
Using cached tabulate-0.9.0-py3-none-any.whl (35 kB)
Collecting colorama
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting toml
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting attrs
Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting pluggy<2.0,>=0.12
Using cached pluggy-1.2.0-py3-none-any.whl (17 kB)
Collecting iniconfig
Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting exceptiongroup>=1.0.0rc8
Using cached exceptiongroup-1.1.3-py3-none-any.whl (14 kB)
Requirement already satisfied: tomli>=1.0.0 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from pytest->-r requirements/tests.txt (line 8)) (2.0.1)
Collecting yapf
Using cached yapf-0.40.1-py3-none-any.whl (250 kB)
Using cached yapf-0.32.0-py2.py3-none-any.whl (190 kB)
Requirement already satisfied: typing-extensions>=3.6.4 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from importlib-metadata<4.3,>=1.1.0->flake8->-r requirements/tests.txt (line 3)) (4.7.1)
Requirement already satisfied: zipp>=0.5 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from importlib-metadata<4.3,>=1.1.0->flake8->-r requirements/tests.txt (line 3)) (3.15.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (1.26.14)
Requirement already satisfied: charset-normalizer<3,>=2 in /opt/conda/envs/fcos4/lib/python3.7/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (2.0.4)
Building wheels for collected packages: mmpycocotools
Building wheel for mmpycocotools (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [63 lines of output]

running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-37
creating build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/mask.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/coco.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/init.py -> build/lib.linux-x86_64-cpython-37/pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build/temp.linux-x86_64-cpython-37
creating build/temp.linux-x86_64-cpython-37/common
creating build/temp.linux-x86_64-cpython-37/pycocotools
gcc -pthread -B /opt/conda/envs/fcos4/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/envs/fcos4/lib/python3.7/site-packages/numpy/core/include -Icommon -I/opt/conda/envs/fcos4/include/python3.7m -c common/maskApi.c -o build/temp.linux-x86_64-cpython-37/common/maskApi.o
common/maskApi.c: In function ‘rleDecode’:
common/maskApi.c:46:7: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
for( k=0; k<R[i].cnts[j]; k++ ) (M++)=v; v=!v; }}
^~~
common/maskApi.c:46:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
for( k=0; k<R[i].cnts[j]; k++ ) (M++)=v; v=!v; }}
^
common/maskApi.c: In function ‘rleFrPoly’:
common/maskApi.c:166:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
for(j=0; j<k; j++) x[j]=(int)(scale
xy[j
2+0]+.5); x[k]=x[0];
^~~
common/maskApi.c:166:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
for(j=0; j<k; j++) x[j]=(int)(scalexy[j2+0]+.5); x[k]=x[0];
^
common/maskApi.c:167:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
for(j=0; j<k; j++) y[j]=(int)(scalexy[j2+1]+.5); y[k]=y[0];
^~~
common/maskApi.c:167:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
for(j=0; j<k; j++) y[j]=(int)(scalexy[j2+1]+.5); y[k]=y[0];
^
common/maskApi.c: In function ‘rleToString’:
common/maskApi.c:212:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
if(more) c |= 0x20; c+=48; s[p++]=c;
^~
common/maskApi.c:212:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
if(more) c |= 0x20; c+=48; s[p++]=c;
^
common/maskApi.c: In function ‘rleFrString’:
common/maskApi.c:220:3: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
while( s[m] ) m++; cnts=malloc(sizeof(uint)*m); m=0;
^~~~~
common/maskApi.c:220:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
while( s[m] ) m++; cnts=malloc(sizeof(uint)*m); m=0;
^~~~
common/maskApi.c:228:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
if(m>2) x+=(long) cnts[m-2]; cnts[m++]=(uint) x;
^~
common/maskApi.c:228:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
if(m>2) x+=(long) cnts[m-2]; cnts[m++]=(uint) x;
^~~~
common/maskApi.c: In function ‘rleToBbox’:
common/maskApi.c:141:31: warning: ‘xp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if(j%2==0) xp=x; else if(xp<x) { ys=0; ye=h-1; }
^
gcc -pthread -B /opt/conda/envs/fcos4/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/envs/fcos4/lib/python3.7/site-packages/numpy/core/include -Icommon -I/opt/conda/envs/fcos4/include/python3.7m -c pycocotools/_mask.c -o build/temp.linux-x86_64-cpython-37/pycocotools/_mask.o
gcc: error: pycocotools/_mask.c: No such file or directory
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mmpycocotools
Running setup.py clean for mmpycocotools
Failed to build mmpycocotools
Installing collected packages: yapf, xdoctest, ubelt, toml, terminaltables, tabulate, python-dateutil, pyparsing, pyflakes, pycodestyle, py, packaging, mccabe, kiwisolver, isort, iniconfig, importlib-metadata, fonttools, exceptiongroup, cython, cycler, coverage, colorama, asynctest, pluggy, matplotlib, kwarray, flake8, codecov, click, attrs, pytest, mmpycocotools, interrogate
Attempting uninstall: yapf
Found existing installation: yapf 0.40.2
Uninstalling yapf-0.40.2:
Successfully uninstalled yapf-0.40.2
Attempting uninstall: importlib-metadata
Found existing installation: importlib-metadata 6.7.0
Uninstalling importlib-metadata-6.7.0:
Successfully uninstalled importlib-metadata-6.7.0
Running setup.py install for mmpycocotools ... error
error: subprocess-exited-with-error

× Running setup.py install for mmpycocotools did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
running install
/opt/conda/envs/fcos4/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-37
creating build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/mask.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/coco.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-cpython-37/pycocotools
copying pycocotools/init.py -> build/lib.linux-x86_64-cpython-37/pycocotools
running build_ext
Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
/opt/conda/envs/fcos4/lib/python3.7/site-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/pip-install-venjjh8v/mmpycocotools_1824eea94d794c2dbefee8f95888ad43/pycocotools/_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pycocotools._mask' extension
creating build/common
creating build/temp.linux-x86_64-cpython-37
creating build/temp.linux-x86_64-cpython-37/common
creating build/temp.linux-x86_64-cpython-37/pycocotools
gcc -pthread -B /opt/conda/envs/fcos4/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/envs/fcos4/lib/python3.7/site-packages/numpy/core/include -Icommon -I/opt/conda/envs/fcos4/include/python3.7m -c ../common/maskApi.c -o build/temp.linux-x86_64-cpython-37/../common/maskApi.o
**gcc: error: ../common/maskApi.c: No such file or directory
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure**

× Encountered error while trying to install package.
╰─> mmpycocotools

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
(fcos4) root@pt-brhac-55cf55d5c8-rptrd:/workspace/ICDAR2021_MFD#

(fcos4) root@pt-brhac-55cf55d5c8-rptrd:/workspace/ICDAR2021_MFD# pip install -v -e .

Following Error:

cwd: /tmp/pip-install-mmzs0ypo/mmpycocotools_8b2791f3b92b4dbbb356955cca03a755/
Building wheel for mmpycocotools (setup.py) ... error
ERROR: Failed building wheel for mmpycocotools
Running setup.py clean for mmpycocotools
Running command python setup.py clean
running clean
removing 'build/temp.linux-x86_64-cpython-38' (and everything under it)
removing 'build/lib.linux-x86_64-cpython-38' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.8' does not exist -- can't clean it
Failed to build mmpycocotools
ERROR: Could not build wheels for mmpycocotools, which is required to install pyproject.toml-based projects
(fcos4) root@pt-brhac-55cf55d5c8-rptrd:/workspace/ICDAR2021_MFD#

Please guide

RuntimeError: CUDA OOM / Bad Training Performance after reducing crop_size

Hello @Yuxiang1995 ,

I am attempting to train your Network on a single gpu.
But then I get this Error:

RuntimeError: CUDA out of memory. Tried to allocate 1.86 GiB   
(GPU 0; 4.00 GiB total capacity; 1.48 GiB already allocated; 319.91 MiB free; 1.88   
 GiB reserved in total by PyTorch) 

I also tried it with a 10 GiB GPU but still the same error.
... well I am able to train it when I reduce the crop_size in conigs/_base_/datasets/formula_detection.py
But it seem the model doesnt learn anything, since the loss doesnt get smaller.
... and I saw in your presentation that the large crop_size is a feature of your model.

Can you give me hint how to sucessfully train the model on a single gpu, i.e get rid of the CUDA OOM Error ?

when inference:RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
A clear and concise description of what the bug is.

Reproduction

  1. What command or script did you run?
A placeholder for the command.
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
  2. What dataset did you use?

Environment

  1. Please run python mmdet/utils/collect_env.py to collect necessary environment information and paste it here.
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.

A placeholder for trackback.

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

Inference怎么用?

@Yuxiang1995 谢谢你做的这个项目,我想用你这个来试一下把公式的坐标从图片里面提取出来,但是不知道怎么用,我看到了Inference的说明,但是不明白这个checkpoint path需要放什么。我试过放mfd_gfl_s50.pth,但好像没有用。而且我还有个疑问,按理说我需要把待解析的图片传进去跑,但是要怎么传进去呢?
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.