I used these GitHub repositories. Thank you for your contributions!
TextRecognitionDataGenerator(https://github.com/Belval/TextRecognitionDataGenerator)
TRDG2DTRB(https://github.com/DaveLogs/TRDG2DTRB)
deep-text-recognition-benchmark(https://github.com/clovaai/deep-text-recognition-benchmark)
python 3.6.13 ๋ฒ์ ์ฌ์ฉํ์(anaconda ๊ฐ์ํ๊ฒฝ์ผ๋ก ์์ฑํ์)
-
pip list๋ requirements.txt ์ฐธ๊ณ
pip install -r requirements.txt
-
PyTorch 1.8.1 + CUDA 11.1 ์ค์น
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 --extra-index-url https://download.pytorch.org/whl/cu111
1. ocr_dtrb -> generate_run.py
os.system(f"python {runpy} -c 4500 -w 1 -f 64 -l ko --output_dir ./out")
-c ์์ฑ ์ด๋ฏธ์ง ๊ฐฏ์ -w ๊ธธ์ด -f ๋์ด -l ์ธ์ด --output_dir "{์์ฑํ ์ด๋ฏธ์ง ๊ฒฝ๋ก}" ๋ก ์์ ํ ์ฌ์ฉ
์ด์ธ ๊ธฐํ ๋ฐ ์์ธํ ์ฌํญ์ ocr_dtrb\data\generator\TextRecognitionDataGenerator\run.py์ def parse_arguments() ์ฐธ๊ณ
2. TRDG2DTRB -> convertrun.py
input_path์ output_path๋ฅผ ํ์ธํ ํ ์คํ.
์คํ ์ ๊ฒฐ๊ณผ๋ก images์ ์ด๋ฏธ์ง๋ค(image_00000.jpg, image_00001.jpg, image_00002.jpg ...)์ gt.txt๊ฐ ์์ฑ์ด ๋จ
3. deep-text-recognition-benchmark -> run.py
gt_path์ gt.txt ํ์ผ ๊ฒฝ๋ก๋ฅผ ๋ฃ๊ณ
commands ์์ --inputPath์ --outputPath์ ๊ฒฝ๋ก๋ฅผ ํ์ธํ ๋ค ์คํ ํ๋ฉด LMDB ๋ฐ์ดํฐ ์ ์ด ์์ฑ์ด ๋จ.
๋ง์ฝ lmdb ์ฌ์ด์ฆ๋ฅผ ์กฐ์ ํ๊ณ ์ถ์ผ๋ฉด deep-text-recognition-benchmark\create_lmdb_dataset.py์์ def createDataset์ env = lmdb.open(outputPath, map_size=104857600) map_size๋ฅผ ์์ ํด์ฃผ๋ฉด ๋จ.(ํ์ฌ 100mb๋ก ์ค์ ๋จ)
4. deep-text-recognition-benchmark -> trainrun.py
--train_data ์ --valid_data์ ๊ฒฝ๋ก๋ฅผ ํ์ธํ๊ณ --num_iter (๋ฐ๋ณต ํ์)๋ฅผ ์กฐ์ ํด์ ์คํํ๋ฉด
saved_models/None-VGG-BiLSTM-CTC-Seed1111 ํด๋ ์์ pthํ์ผ๋ค๊ณผ txtํ์ผ๋ค์ด ์์ฑ๋ ๊ฒ์ ๋ณผ ์ ์์
์ฌ๊ธฐ์ EasyOCR์ ์ฌ์ฉํ pthํ์ผ์ best_accuracy.pth๋ฅผ customํ ์ด๋ฏธ์ง ์ด๋ฆ์ ๋ง์ถฐ์ ์์ ํด์ฃผ๋ฉด ๋จ(ex. custom.py, custom.yaml, custom.pth)
!!! ๋ง์ฝ ํ์ต์ด ๋๋ฌด ๋๋ฆฌ๋ค๋ฉด cuda๊ฐ ์ค์น๋๋์ง GPU๊ฐ ์๋์ค์ธ์ง ํ์ธํ๊ธธ ๋ฐ๋ !!!
import torch
print(torch.cuda.is_available()) # True์ฌ์ผ ํจ
print(torch.cuda.get_device_name(0)) # GPU ์ด๋ฆ ์ถ๋ ฅ
parser.add_argument('--select_data', default='/'
parser.add_argument('--batch_ratio', default='1'
parser.add_argument('--character' # ์ฌ๊ธฐ default์ ํ๊ธ์ ์ถ๊ฐํจ. default ๊ฐ์ ๋นผ๊ณ trainrun.py์ command๋ก ์ฎ๊ฒจ์ค๋ ๋จ)
parser.add_argument('--data_filtering_off', default=True