Downloads · 30 days
0
donghyun95/EpiText-Hanja-OCR
EpiText-Hanja-OCR is a image-to-text model from donghyun95. Use it when you need a caption or text from an image. It is set up for pytorch. The card lists the license as mit.
<p align="center" 🔧 <a href="google-vision-api-setup-required"Setup</a | ▶️ <a href="running-the-ocr"Run</a | 🖼️ <a href="preprocessing-and-intermediate-outputs"Examples</a | 📦 <…
Downloads · 30 days
0
Access
Public
Updated Feb 8, 2026
Repo size
221 MB
Likes
0
Public
Click a slice to open those files.
.pth115 MB · 52%
From the Hugging Face model README
Pipeline: Input → Preprocess (gray for Swin, binary for OCR) → OCR (auto) → JSON + BBox
This repository provides a damage-aware OCR pipeline specialized for Hanja rubbing (탁본) images.
The system integrates Google Vision OCR with custom deep learning models to robustly recognize characters under severe degradation commonly found in stone inscriptions and epigraphic materials.
Hanja rubbing images differ significantly from modern scanned documents.
They often exhibit erosion, ink bleeding, uneven backgrounds, and partially or fully missing characters.
To address these challenges, this project combines:
⚠️ Google Vision OCR is not redistributed.
Users must provide their own Google Cloud API credentials.
[MASK1], [MASK2]EpiText-Hanja-OCR/
├─ assets/ # README example images
├─ dong_ocr.py # Main execution script
├─ ai_modules/ # OCR engine, preprocessing, model definitions
├─ weights/ # Model weights (and user-provided API key)
├─ requirements.txt
└─ README.md
Install dependencies:
pip install -r requirements.txt
This project requires a Google Vision API service account JSON file.
weights/ directoryweights/
├─ best.pth
├─ best_5000.pt
└─ google_key.json
⚠️ Do NOT upload this JSON file to GitHub or Hugging Face.
It must remain local to your machine.
export OCR_WEIGHTS_BASE_PATH=./weights
export GOOGLE_CREDENTIALS_JSON=google_key.json
$env:OCR_WEIGHTS_BASE_PATH=".\weights"
$env:GOOGLE_CREDENTIALS_JSON="google_key.json"
python dong_ocr.py path/to/image.jpg
Example:
python dong_ocr.py assets/input.jpg
Before OCR inference, the input image is automatically preprocessed to generate task-specific intermediate representations.
The OCR system outputs a structured JSON file that preserves character-level recognition results, spatial information, and damage-aware annotations for historical rubbings.
{
"image": "input_image.jpg",
"results": [
{
"order": 0,
"text": "府",
"type": "TEXT",
"box": [x1, y1, x2, y2],
"confidence": 0.77,
"source": "Google"
},
{
"order": 4,
"text": "[MASK1]",
"type": "MASK1",
"box": [x1, y1, x2, y2],
"confidence": 0.0,
"source": "Inferred"
},
{
"order": 5,
"text": "[MASK2]",
"type": "MASK2",
"box": [x1, y1, x2, y2],
"confidence": 0.0,
"source": "Inferred"
}
]
}
order
Reading order index (top-to-bottom, column-wise)
text
Recognized character or special damage token
(TEXT, [MASK1], [MASK2])
type
Damage-aware classification:
TEXT : confidently recognized characterMASK1: fully missing character (no visible strokes)MASK2: partially damaged character (residual strokes remain)box
Bounding box coordinates [x1, y1, x2, y2] in image space
confidence
OCR confidence score
(0.0 for inferred MASK regions)
source
OCR origin:
Google : Google Vision OCRInferred : damage-aware inference (non-OCR)This JSON format is designed to preserve structural and damage information, enabling downstream tasks such as contextual restoration, multimodal reasoning, and expert-assisted interpretation.
The binarized (black-and-white) image is automatically forwarded to the OCR engine.
Input image → preprocessing → binary image → OCR (automatic)
*_gray.jpg
Grayscale image used for Swin Transformer–based processing
*_binary.jpg
Binarized image automatically used for OCR inference
*_ocr_result.json
Structured OCR results including:
TEXT, MASK1, MASK2)*_bbox.jpg
Visualization image with colored bounding boxes
[MASK1] (fully missing characters)[MASK2] (partially damaged characters)[MASK1]: fully missing[MASK2]: partially damagedMIT License
@misc{epitext_hanja_ocr_2025,
title = {EpiText Hanja OCR: Damage-Aware OCR for Rubbing Images},
author = {donghyun95},
year = {2025},
howpublished = {Hugging Face Model Repository}
}