-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
586 changed files
with
181,426 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
import json | ||
import cv2 | ||
import shapely | ||
import os | ||
import argparse | ||
import csv | ||
|
||
with open("CrossTest.csv", 'w', newline='') as csvfileOut: | ||
detects = ['yolo-Result-best-rulebase', 'unet-Result-best-rulebase', 'marge'] | ||
regres = ['RARETYPE1', 'RARERGB','RAREBINARY', 'dataColor.RARERGB', | ||
'CRNNTYPE1','CRNNRGB','CRNNBINARY', 'dataColor.CRNNRGB', | ||
'RosettaTYPE1','RosettaRGB','RosettaBINARY', 'dataColor.RosettaRGB', | ||
'STARNetTYPE1', 'STARNetRGB','STARNetBINARY', 'dataColor.STARNetRGB', | ||
'dataColor.NoneResNetBiLSTMCTCRGB', | ||
"voteRGB", "vote2RGB"] | ||
table = np.zeros((18, len(detects), len(regres))) | ||
for filename in os.listdir("./CrossTest/"): | ||
name, ext = os.path.splitext(filename) | ||
|
||
detect, regre, color = name.split("_") | ||
regre = regre+color | ||
print(filename, detect, regre) | ||
with open(os.path.join('./CrossTest/', filename), newline='') as csvfile: | ||
rows = csv.reader(csvfile, delimiter=':') | ||
for i, row in enumerate(rows): | ||
row = row[0].split(",") | ||
if detect not in detects: | ||
# print(detect, "not in ") | ||
continue | ||
if regre not in regres: | ||
# print(regre, "not in ") | ||
continue | ||
table[i, detects.index(detect), regres.index(regre)] = float(row[-1]) | ||
print("table", table.shape) | ||
tableMean = np.mean(table, axis=0) | ||
# print(detects) | ||
# print(regres) | ||
# print(table) | ||
|
||
writer = csv.writer(csvfileOut) | ||
writer.writerow([""]+detects) | ||
for i in range(len(tableMean[0])): | ||
print(row) | ||
row = tableMean[:,i] | ||
writer.writerow([regres[i]]+row.tolist()) | ||
|
||
with open("CrossTestbest.csv", 'w', newline='') as csvfileOut2: | ||
writer2 = csv.writer(csvfileOut2) | ||
tableMaxIdx = np.argmax(table.reshape((18, len(detects)*len(regres))), axis=1) | ||
tableMaxIdx = np.unravel_index(tableMaxIdx, (len(detects), len(regres))) | ||
print(tableMaxIdx) | ||
for i in range(len(tableMaxIdx[0])): | ||
print(i, detects[tableMaxIdx[0][i]].split("-")[0], regres[tableMaxIdx[1][i]], table[i,tableMaxIdx[0][i],tableMaxIdx[1][i]]) | ||
writer2.writerow(["FPK_"+str(i+1).zfill(2)+".jpg", detects[tableMaxIdx[0][i]].split("-")[0], regres[tableMaxIdx[1][i]], table[i,tableMaxIdx[0][i],tableMaxIdx[1][i]]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 SakuraRiven | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## Description | ||
This is a PyTorch Re-Implementation of [EAST: An Efficient and Accurate Scene Text Detector](http://openaccess.thecvf.com/content_cvpr_2017/papers/Zhou_EAST_An_Efficient_CVPR_2017_paper.pdf). | ||
|
||
* Only RBOX part is implemented. | ||
* Using dice loss instead of class-balanced cross-entropy loss. Some codes refer to [argman/EAST](https://github.com/argman/EAST) and [songdejia/EAST](https://github.com/songdejia/EAST) | ||
* The pre-trained model provided achieves __82.79__ F-score on ICDAR 2015 Challenge 4 using only the 1000 images. see [here](http://rrc.cvc.uab.es/?ch=4&com=evaluation&view=method_info&task=1&m=52405) for the detailed results. | ||
|
||
| Model | Loss | Recall | Precision | F-score | | ||
| - | - | - | - | - | | ||
| Original | CE | 72.75 | 80.46 | 76.41 | | ||
| Re-Implement | Dice | 81.27 | 84.36 | 82.79 | | ||
|
||
## Prerequisites | ||
Only tested on | ||
* Anaconda3 | ||
* Python 3.7.1 | ||
* PyTorch 1.0.1 | ||
* Shapely 1.6.4 | ||
* opencv-python 4.0.0.21 | ||
* lanms 1.0.2 | ||
|
||
When running the script, if some module is not installed you will see a notification and installation instructions. __if you failed to install lanms, please update gcc and binutils__. The update under conda environment is: | ||
|
||
conda install -c omgarcia gcc-6 | ||
conda install -c conda-forge binutils | ||
|
||
The original lanms code has a bug in ```normalize_poly``` that the ref vertices are not fixed when looping the p's ordering to calculate the minimum distance. We fixed this bug in [LANMS](https://github.com/SakuraRiven/LANMS) so that anyone could compile the correct lanms. However, this repo still uses the original lanms. | ||
|
||
## Installation | ||
### 1. Clone the repo | ||
|
||
``` | ||
git clone https://github.com/SakuraRiven/EAST.git | ||
cd EAST | ||
``` | ||
|
||
### 2. Data & Pre-Trained Model | ||
* Download Train and Test Data: [ICDAR 2015 Challenge 4](http://rrc.cvc.uab.es/?ch=4&com=downloads). Cut the data into four parts: train_img, train_gt, test_img, test_gt. | ||
|
||
* Download pre-trained VGG16 from PyTorch: [VGG16](https://drive.google.com/open?id=1HgDuFGd2q77Z6DcUlDEfBZgxeJv4tald) and our trained EAST model: [EAST](https://drive.google.com/open?id=1AFABkJgr5VtxWnmBU3XcfLJvpZkC2TAg). Make a new folder ```pths``` and put the download pths into ```pths``` | ||
|
||
``` | ||
mkdir pths | ||
mv east_vgg16.pth vgg16_bn-6c64b313.pth pths/ | ||
``` | ||
|
||
Here is an example: | ||
``` | ||
. | ||
├── EAST | ||
│ ├── evaluate | ||
│ └── pths | ||
└── ICDAR_2015 | ||
├── test_gt | ||
├── test_img | ||
├── train_gt | ||
└── train_img | ||
``` | ||
## Train | ||
Modify the parameters in ```train.py``` and run: | ||
``` | ||
CUDA_VISIBLE_DEVICES=0,1 python train.py | ||
``` | ||
## Detect | ||
Modify the parameters in ```detect.py``` and run: | ||
``` | ||
CUDA_VISIBLE_DEVICES=0 python detect.py | ||
``` | ||
## Evaluate | ||
* The evaluation scripts are from [ICDAR Offline evaluation](http://rrc.cvc.uab.es/?ch=4&com=mymethods&task=1) and have been modified to run successfully with Python 3.7.1. | ||
* Change the ```evaluate/gt.zip``` if you test on other datasets. | ||
* Modify the parameters in ```eval.py``` and run: | ||
``` | ||
CUDA_VISIBLE_DEVICES=0 python eval.py | ||
``` |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.