Skip to content

bestKUFO/custom_pth_data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

I used these GitHub repositories. Thank you for your contributions!

ocr_kor(https://github.com/parksunwoo/ocr_kor)

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 ์ด๋ฆ„ ์ถœ๋ ฅ

deep-text-recognition-benchmark\train.py ํŒŒ์ผ ๋‚ด ์ˆ˜์ •๋œ ์‚ฌํ•ญ

 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

About

Used to customize the pth file in EasyOCR

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors