Skip to content

boostcampaitech7/level2-cv-datacentric-cv-23

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

81 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“œ Multilingual Receipt OCR

이미지 좜처 : https://www.ncloud.com/product/aiService/ocr


✏️ Introduction

OCR Β­(Optical Character Recognition)은 λ¬Έμ„œ λ“±μ˜ μ΄λ―Έμ§€μ—μ„œ κΈ€μžλ₯Ό μΈμ‹ν•˜λŠ” Task μž…λ‹ˆλ‹€. OCR의 λͺ¨λ“ˆλ‘œλŠ” κΈ€μž μ˜μ—­μ„ νŒλ‹¨ν•˜λŠ” Text Detector, μ˜μ—­μ— ν¬ν•¨λœ κΈ€μžλ₯Ό μΈμ‹ν•˜λŠ” Text Recognizer, μžμ—°μ–΄λ₯Ό μœ μ˜λ―Έν•œ μˆœμ„œλ‘œ μ •λ ¬ν•˜λŠ” Serializer, κΈ°μ •μ˜λœ key듀에 λŒ€ν•œ value μΆ”μΆœν•˜λŠ” Text Parserκ°€ μžˆμŠ΅λ‹ˆλ‹€. ν•΄λ‹Ή λŒ€νšŒλŠ” 영수증 이미지 λ°μ΄ν„°μ—μ„œ κΈ€μžλ₯Ό κ²€μΆœν•˜λŠ” OCR λŒ€νšŒλ‘œ λ‹€μŒ 두 κ°€μ§€ κ·œμΉ™μ΄ μžˆμŠ΅λ‹ˆλ‹€.

  1. 영수증 μ΄λ―Έμ§€μ—μ„œ μ˜μ—­μ„ νƒμ§€ν•˜λŠ” Text Detectionλ§Œμ„ μˆ˜ν–‰ν•©λ‹ˆλ‹€.
  2. λͺ¨λΈμ€ EAST둜 κ³ μ •ν•˜κ³ , Dataλ§Œμ„ μˆ˜μ •ν•˜μ—¬ μ„±λŠ₯을 λ†’μ—¬μ•Ό ν•©λ‹ˆλ‹€.

λŒ€νšŒλŠ” μ˜μ—­ 탐지 μ„±λŠ₯을 ν‰κ°€ν•˜λŠ” DetEval을 톡해 ν‰κ°€λ©λ‹ˆλ‹€.


πŸ“… Schedule

ν”„λ‘œμ νŠΈ 전체 일정

  • 2024.10.30 ~ 2024.11.07

ν”„λ‘œμ νŠΈ 세뢀일정

  • 2024.10.30 ~ 2024.10.31 : 데이터 EDA 및 μ‹œκ°ν™”, 평가 μ§€ν‘œ μ„€μ •
  • 2024.10.30 ~ 2024.11.03 : Wandb 연동 및 둜그 μΆ”κ°€
  • 2024.11.01 ~ 2024.11.03 : μ™ΈλΆ€ 데이터 쑰사 및 Annotation κ°€μ΄λ“œλΌμΈ μ„€μ •
  • 2024.11.02 ~ 2024.11.05 : μ™ΈλΆ€ 데이터 Annotation
  • 2024.11.02 ~ 2024.11.07 : λͺ¨λΈ μ‹€ν—˜ 및 평가
  • 2024.11.07 ~ 2024.11.08 : λͺ¨λΈ 앙상블 μ‹€ν—˜
  • 2024.11.08 ~ 2024.11.08 : μ΅œμ’… λͺ¨λΈ 평가

πŸ•΅οΈ ν”„λ‘œμ νŠΈ νŒŒμ΄ν”„λΌμΈ

각 νŒŒμ΄ν”„λΌμΈμ— λŒ€ν•œ μƒμ„Έν•œ λ‚΄μš©μ€ μ•„λž˜ 링크λ₯Ό 톡해 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.


πŸ₯ˆ Result

Private λ¦¬λ”λ³΄λ“œμ—μ„œ μ΅œμ’…μ μœΌλ‘œ μ•„λž˜μ™€ 같은 κ²°κ³Όλ₯Ό μ–»μ—ˆμŠ΅λ‹ˆλ‹€.


πŸ—ƒοΈ Dataset Structure

data/
β”œβ”€β”€ chinese_receipt
β”‚Β Β  β”œβ”€β”€ img
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.zh.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.zh.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  └── train
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.zh.in_house...jpg
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.zh.in_house...jpg
β”‚Β Β  β”‚Β Β      └── ...
β”‚Β Β  └── ufo
β”‚Β Β      β”œβ”€β”€ test.json
β”‚Β Β      └── train.json
β”œβ”€β”€ japanese_receipt
β”‚Β Β  β”œβ”€β”€ img
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.ja.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.ja.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  └── train
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.ja.in_house...jpg
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.ja.in_house...jpg
β”‚Β Β  β”‚Β Β      └── ...
β”‚Β Β  └── ufo
β”‚Β Β      β”œβ”€β”€ test.json
β”‚Β Β      └── train.json
β”œβ”€β”€ thai_receipt
β”‚Β Β  β”œβ”€β”€ img
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.th.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.th.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.th.in_house...jpg
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  └── train
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.th.in_house...jpg
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ extractor.th.in_house...jpg
β”‚Β Β  β”‚Β Β      └── ...
β”‚Β Β  └── ufo
β”‚Β Β      β”œβ”€β”€ test.json
β”‚Β Β      └── train.json
└── vietnamese_receipt
    β”œβ”€β”€ img
    β”‚Β Β  β”œβ”€β”€ test
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.vi.in_house...jpg
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ extractor.vi.in_house...jpg
    β”‚Β Β  β”‚Β Β  └── ...
    β”‚Β Β  └── train
    β”‚Β Β      β”œβ”€β”€ extractor.vi.in_house...jpg
    β”‚Β Β      β”œβ”€β”€ extractor.vi.in_house...jpg
    β”‚Β Β      └── ...
    └── ufo
        β”œβ”€β”€ test.json
        └── train.json

  • 데이터셋은 λ‹€κ΅­μ–΄(쀑ꡭ어, 일본어, νƒœκ΅­μ–΄, λ² νŠΈλ‚¨μ–΄) 영수증 μ΄λ―Έμ§€λ‘œ ν•Έλ“œν° 카메라 λ“±μœΌλ‘œ 찍은 영수증 사진과 μŠ€μΊ”λœ 영수증 μ‚¬μ§„μœΌλ‘œ 이뀄지며, train 400개(언어별 100개), test 120개(언어별 30개)둜 κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

Train & Test json

Train json νŒŒμΌμ€ UFO format을 λ”°λ₯΄λ©° paragraphs, words, characters, image width & height, image tag, annotation log, license tag λ“±μœΌλ‘œ κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

{
    "images": {
        "extractor.ja.in_house.appen_000911_page0001.jpg": {
            "paragraphs": {},
            "words": {
                "0001": {
                    "transcription": "LAWSON",
                    "points": [
                        [
                            728.553329490908,
                            235.436074339687
                        ],
                        [
                            735.9530472990916,
                            428.81846937705836
                        ],
                        [
                            216.57843990309,
                            340.653026763541
                        ],
                        [
                            220.926247854489,
                            246.740375013324
                        ]
                    ]
                },
                "chars": {},
                "img_w": 960,
                "img_h": 1280,
                "num_patches": null,
                "tags": [],
                "relations": {},
                "annotation_log": {
                    "worker": "worker",
                    "timestamp": "2024-06-07",
                    "tool_version": "",
                    "source": null
                },
                "license_tag": {
                    "usability": true,
                    "public": false,
                    "commercial": true,
                    "type": null,
                    "holder": "Upstage"
                }
            }
        },
        ...
    }
  • pointλŠ” 각 라벨의 μœ„μΉ˜ μ’Œν‘œμ΄λ©°, κΈ€μžλ₯Ό μ½λŠ” λ°©ν–₯의 μ™Όμͺ½ μœ„μ—μ„œλΆ€ν„° μ‹œκ³„ λ°©ν–₯으둜 x,y μ’Œν‘œλ‘œ 총 4개의 (x,y) μ’Œν‘œλ‘œ κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

Test JSON νŒŒμΌμ€ Train JSON 파일과 λ™μΌν•œ ꡬ쑰λ₯Ό κ°€μ§€λ©°, 단 point μ •λ³΄λ§Œ λΉ μ Έ μžˆμŠ΅λ‹ˆλ‹€.


πŸŽ‰ Project

Structure

project
β”œβ”€β”€ EDA&Viz
β”‚Β Β  β”œβ”€β”€ eda.ipynb
β”‚Β Β  β”œβ”€β”€ result_viz.py
β”‚Β Β  └── result_viz.sh
β”œβ”€β”€ inference.py
β”œβ”€β”€ inference.sh
β”œβ”€β”€ preprocessing
β”‚Β Β  β”œβ”€β”€ COCO2UFO.py
β”‚Β Β  β”œβ”€β”€ CORD2UFO.ipynb
β”‚Β Β  β”œβ”€β”€ SROIE2UFO.ipynb
β”‚Β Β  └── UFO2COCO.py
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ dataset_CV2.py
β”‚Β Β  β”œβ”€β”€ dataset.py
β”‚Β Β  β”œβ”€β”€ deteval.py
β”‚Β Β  β”œβ”€β”€ __init__.py
β”‚Β Β  └── TIoUeval.py
β”œβ”€β”€ train.py
└── utils
    β”œβ”€β”€ artifacts_download.py
    β”œβ”€β”€ bbox_check.py
    β”œβ”€β”€ create_train_val_tag.py
    └── create_val_data.py

λŒ€νšŒ κ·œμ •μ— 따라 EAST λͺ¨λΈμ΄ μ •μ˜λœ μ½”λ“œλŠ” μ œμ™Έν•˜μ˜€μŠ΅λ‹ˆλ‹€.

EDA&Viz

  • eda.ipynb : 이미지 크기 뢄포, 단어 개수 뢄포, Bounding box 크기 뢄포, Aspect Ratio 뢄포, μ˜ˆμ‹œ 이미지 등을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.
  • result_viz.py: μ΅œμ’… λͺ¨λΈ 평가 κ²°κ³Όλ₯Ό μ‹œκ°ν™”ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€. ν•΄λ‹Ή μ½”λ“œλ₯Ό μœ„ν•΄ λ‹€μŒμ„ μ‹€ν–‰ν•΄μ•Ό ν•©λ‹ˆλ‹€.
    bash result_viz.sh

preprocessing

  • COCO2UFO.py : COCO format의 데이터λ₯Ό UFO format의 λ°μ΄ν„°λ‘œ λ³€ν™˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • CORD2UFO.ipynb : CORD format의 데이터λ₯Ό UFO format의 λ°μ΄ν„°λ‘œ λ³€ν™˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • SROIE2UFO.ipynb : SROIE format의 데이터λ₯Ό UFO format의 λ°μ΄ν„°λ‘œ λ³€ν™˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • UFO2COCO.py : UFO format의 데이터λ₯Ό COCO format의 λ°μ΄ν„°λ‘œ λ³€ν™˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.

src

  • dataset.py : 데이터 λ‘œλ”λ₯Ό μ •μ˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€. (PIL)
  • dataset_CV2.py : 데이터 λ‘œλ”λ₯Ό μ •μ˜ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€. (CV2)
  • deteval.py : DetEval을 κ³„μ‚°ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • TIoUeval.py : TIoUλ₯Ό κ³„μ‚°ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.

utils

  • artifacts_download.py : Wandb에 μ €μž₯된 μ•„ν‹°νŒ©νŠΈλ₯Ό λ‹€μš΄λ‘œλ“œν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • bbox_check.py : Bounding box 체크λ₯Ό μœ„ν•œ μ½”λ“œμž…λ‹ˆλ‹€.
  • create_train_val_tag.py : Train & Validation json νŒŒμΌμ— νƒœκ·Έλ₯Ό μƒμ„±ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
  • create_val_data.py : Validation 데이터λ₯Ό μƒμ„±ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€. (8 : 2 λΉ„μœ¨)

βš™οΈ Requirements

env.

이 ν”„λ‘œμ νŠΈλŠ” Ubuntu 20.04.6 LTS, CUDA Version: 12.2, Tesla v100 32GB의 ν™˜κ²½μ—μ„œ ν›ˆλ ¨ 및 ν…ŒμŠ€νŠΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Installment

λ˜ν•œ, 이 ν”„λ‘œμ νŠΈμ—λŠ” λ‹€μ•™ν•œ λΌμ΄λΈŒλŸ¬λ¦¬κ°€ ν•„μš”ν•©λ‹ˆλ‹€. λ‹€μŒ 단계λ₯Ό 따라 ν•„μš”ν•œ λͺ¨λ“  라이브러리λ₯Ό μ„€μΉ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  git clone https://github.com/boostcampaitech7/level2-cv-datacentric-cv-23.git
  cd level2-datacentric-cv-23
  pip install -r requirements.txt

πŸ§‘β€πŸ€β€πŸ§‘ Contributors

⚑️ Detail

ν”„λ‘œμ νŠΈμ— λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ Wrap-Up Report μ—μ„œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

About

level2-cv-datacentric-cv-23 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages