Test code for text detection and recognition from images of medical laboratory reports. The results may have some deviation on different devices.
The text detection module is forked from endernewton. We improve the results through a patch-based strategy. The text recognition module is implemented according to meijieru. A concatenation structure is designed to utilize both the shallow and deep features, which results in a higher accuracy.
- Download the dataset from Google Drive.
- Extract the .zip file and put them under "./detection/data/VOCdevkit2007/". Then the folder should be:
├── detection ├── data ├── VOCdevkit2007 ├── VOC2007 ├── Annotations ├── ImageSets ├── JPEGImages ├── editAnnotation.py ├── labels_src.json
- Download the model from Google Drive.
- Extract the .zip file and put them under "./detection/output/". Then the folder should be:
├── detection ├── output ├── vgg16 ├── voc_2007_test ├── voc_2007_trainval
- This framwork has been tested under Tensorflow 1.0. Update your -arch in setup script to match your GPU.
cd detection/lib # Change the GPU architecture (-arch) if necessary vim setup.py # TitanX (Maxwell/Pascal) sm_52 # GTX 960M sm_50 # GTX 1080 (Ti) sm_61 # Tesla K80 (AWS p2.xlarge) sm_37
- Modify the GPU number before test.
Then, run "printResults_with_crop.py" under Tensorflow environment:
cd detection/tools vim printResults_with_crop.py 33 os.environ['CUDA_VISIBLE_DEVICES']='1'
A result file will be created as "detection/tools/results.txt"cd .. python ./tools/printResults_with_crop.py --net vgg16 --dataset pascal_voc
- Evaluaiton the results:
python ./tools/eval_results.py
- Download val set from Google Drive.
- The test set has been transformed as LMDB format. Extract the .zip file and put them under "./recognition/data/val". Then the folder should be:
├── recognition ├── data ├── val ├── data.mdb ├── lock.mdb
- Download the model from Google Drive.
- Put "netCRNN_L3.pth" under "./recognition/output/". Then the folder should be:
├── recognition ├── output ├── netCRNN_L3.pth
- Dependence: Pytorch 0.2 and warp_ctc_pytorch.
- Modify the GPU number before test.
Then, run "eval.py":
cd recognition vim eval.py 16 os.environ['CUDA_VISIBLE_DEVICES']='1'
python eval.py