CRAFT-Reimplementation
CRAFT-Reimplementation copied to clipboard
Critical issues with training code
- training scripts (
trainSyndata.py) importstest.py.test.pyhas some code not nested inif __name__ == "__main__":. For example, this below code that parses argument:
parser = argparse.ArgumentParser(description='CRAFT Text Detection')
parser.add_argument('--trained_model', default='weights/craft_mlt_25k.pth', type=str, help='pretrained model')
parser.add_argument('--text_threshold', default=0.7, type=float, help='text confidence threshold')
parser.add_argument('--low_text', default=0.4, type=float, help='text low-bound score')
parser.add_argument('--link_threshold', default=0.4, type=float, help='link confidence threshold')
parser.add_argument('--cuda', default=True, type=str2bool, help='Use cuda to train model')
parser.add_argument('--canvas_size', default=2240, type=int, help='image size for inference')
parser.add_argument('--mag_ratio', default=2, type=float, help='image magnification ratio')
parser.add_argument('--poly', default=False, action='store_true', help='enable polygon type')
parser.add_argument('--show_time', default=False, action='store_true', help='show processing time')
parser.add_argument('--test_folder', default='/data/', type=str, help='folder path to input images')
is part of test.py and it is not within if __name__ == "__main__":. This means whenever test.py is imported, this code runs. You can see the error with:
python trainSyndata.py --help
which prints
usage: trainSyndata.py [-h] [--trained_model TRAINED_MODEL]
[--text_threshold TEXT_THRESHOLD] [--low_text LOW_TEXT]
[--link_threshold LINK_THRESHOLD] [--cuda CUDA]
[--canvas_size CANVAS_SIZE] [--mag_ratio MAG_RATIO]
[--poly] [--show_time] [--test_folder TEST_FOLDER]
CRAFT Text Detection
optional arguments:
-h, --help show this help message and exit
--trained_model TRAINED_MODEL
pretrained model
--text_threshold TEXT_THRESHOLD
text confidence threshold
--low_text LOW_TEXT text low-bound score
--link_threshold LINK_THRESHOLD
link confidence threshold
--cuda CUDA Use cuda to train model
--canvas_size CANVAS_SIZE
image size for inference
--mag_ratio MAG_RATIO
image magnification ratio
--poly enable polygon type
--show_time show processing time
--test_folder TEST_FOLDER
folder path to input images
The above print statement is for args written in test.py, not for trainSyndata.py. Nesting the arguments within the if statement in test.py fixed the error.
-
watershed.pyusesPolygonlibrary, but I can't seem to find how to install this library. Any hints?
- watershed.py uses Polygon library, but I can't seem to find how to install this library. Any hints?
pip install Polygon3
Made PR to address each issue, respectively: https://github.com/backtime92/CRAFT-Reimplementation/pull/29 https://github.com/backtime92/CRAFT-Reimplementation/pull/30
@ThisIsIsaac thanks for you advice I will merge it