End-to-end pipeline that takes a visiting card image and outputs structured contact fields:
PaddleOCR → GLiNER (spaCy pipeline) → Regex post-processing → Structured entities
Extracted labels: PERSON, ORGANISATION, DESIGNATION, PHONE NUMBER, ADDRESS, EMAIL, URL
Emails and URLs are handled via regex override (GLiNER misclassifies these on noisy OCR text). Consecutive ADDRESS spans are merged into a single entity.
| File | Purpose |
|---|---|
PaddleOCR.py | OCR stage — extracts text from card images |
sample.py | Inference with pretrained medium model (baseline) |
visiting_card.py | Inference with fine-tuned small model |
final.py | Production script — lower threshold, address consolidation |
finetune.py | Fine-tuning entry point using GlinerTrainer |
train.py | Config-driven training loop with scheduler + checkpointing |
trainer.py | GlinerTrainer class (Accelerate, DDP, WandB support) |
Sample_Data.json | 67 annotated visiting card samples |
gliner_sample_data.json | 260 samples — visiting cards + invoices |
{
"tokenized_text": ["Jose", "Sebastian", "CTO", "Muthoottu", ...],
"ner": [
[0, 1, "PERSON"],
[2, 2, "DESIGNATION"],
[3, 3, "ORGANISATION"]
]
}
# Install dependencies
pip install -r requirements.pred.txt # inference only
pip install -r requirements.train.txt # training + annotation tools
# Step 1: OCR (edit img_path in PaddleOCR.py first)
python PaddleOCR.py
# Step 2: Run NER
python final.py # fine-tuned model (recommended)
python sample.py # pretrained medium model (baseline)
# Step 3: Fine-tune on your own data
python finetune.py
# or config-driven:
python train.py --config config.yaml --log_dir ./logs
Jose Sebastian E => PERSON
CTO => DESIGNATION
Muthoottu Infotech => ORGANISATION
65/623 K, Kaloor, Kochi, Kerala - 682 017 => ADDRESS
98468 70514 => PHONE NUMBER
[email protected] => EMAIL
www.mmsofttech.com => URL
GLiNER · spaCy · PaddleOCR · PyTorch · HuggingFace Transformers · Accelerate
Author: Swani Madhoop — CUSAT, AI & DS
End-to-end pipeline that takes a visiting card image and outputs structured contact fields:
PaddleOCR → GLiNER (spaCy pipeline) → Regex post-processing → Structured entities
Extracted labels: PERSON, ORGANISATION, DESIGNATION, PHONE NUMBER, ADDRESS, EMAIL, URL
Emails and URLs are handled via regex override (GLiNER misclassifies these on noisy OCR text). Consecutive ADDRESS spans are merged into a single entity.
| File | Purpose |
|---|---|
PaddleOCR.py | OCR stage — extracts text from card images |
sample.py | Inference with pretrained medium model (baseline) |
visiting_card.py | Inference with fine-tuned small model |
final.py | Production script — lower threshold, address consolidation |
finetune.py | Fine-tuning entry point using GlinerTrainer |
train.py | Config-driven training loop with scheduler + checkpointing |
trainer.py | GlinerTrainer class (Accelerate, DDP, WandB support) |
Sample_Data.json | 67 annotated visiting card samples |
gliner_sample_data.json | 260 samples — visiting cards + invoices |
{
"tokenized_text": ["Jose", "Sebastian", "CTO", "Muthoottu", ...],
"ner": [
[0, 1, "PERSON"],
[2, 2, "DESIGNATION"],
[3, 3, "ORGANISATION"]
]
}
# Install dependencies
pip install -r requirements.pred.txt # inference only
pip install -r requirements.train.txt # training + annotation tools
# Step 1: OCR (edit img_path in PaddleOCR.py first)
python PaddleOCR.py
# Step 2: Run NER
python final.py # fine-tuned model (recommended)
python sample.py # pretrained medium model (baseline)
# Step 3: Fine-tune on your own data
python finetune.py
# or config-driven:
python train.py --config config.yaml --log_dir ./logs
Jose Sebastian E => PERSON
CTO => DESIGNATION
Muthoottu Infotech => ORGANISATION
65/623 K, Kaloor, Kochi, Kerala - 682 017 => ADDRESS
98468 70514 => PHONE NUMBER
[email protected] => EMAIL
www.mmsofttech.com => URL
GLiNER · spaCy · PaddleOCR · PyTorch · HuggingFace Transformers · Accelerate
Author: Swani Madhoop — CUSAT, AI & DS