This repository contains an offline, CPU-only solution for Adobe India Hackathon 2025 - Challenge 1A. It extracts the title and hierarchical headings (H1, H2, H3) from a PDF document and outputs a JSON in the specified format.
The model uses a Tiny LayoutLM-style architecture to classify each line of text using both layout and textual features. It is designed to run within strict constraints:
Challenge_1A/
├── app/
│ ├── process_pdfs.py # Entry point
│ ├── pdf_utils.py # PDF text + layout extraction
│ ├── classify_headings.py # Tiny LayoutLM inference wrapper
│ └── model/ # Pretrained model files (≤200MB)
│ ├── config.json
│ ├── pytorch_model.bin
│ └── tokenizer/
│ └── vocab.txt
├── requirements.txt
├── Dockerfile
└── README.md
Text + Layout Extraction:
Tokenization + Embeddings:
Classification:
Title, H1, H2, H3, or Other.Output:
/app/output, matching required schema.This solution runs entirely in a Docker container on linux/amd64 without any internet connection.
docker build --platform linux/amd64 -t pdf-headings .
docker run --rm \\
-v $(pwd)/input:/app/input:ro \\
-v $(pwd)/output:/app/output \\
--network none \\
pdf-headings
.pdf files in input/ folder..json files will be saved to output/.Requirements:
pip install -r requirements.txt
Run Script:
python app/process_pdfs.py
Input and output paths are hardcoded to /app/input and /app/output. You may change these for local use.
{
"title": "Introduction to Document AI",
"outline": [
{ "level": "H1", "text": "Overview", "page": 0 },
{ "level": "H2", "text": "Challenges", "page": 1 },
{ "level": "H3", "text": "Scanned PDFs", "page": 2 }
]
}
/app/model/ and ≤ 200 MB in size.pdf_utils.py to add OCR fallback (e.g., ocrmypdf + Tesseract).1., 1.2).Feel free to reach out for queries, suggestions, or collaboration ideas related to this project.
Python
98.7%
Dockerfile
1.3%
This repository contains an offline, CPU-only solution for Adobe India Hackathon 2025 - Challenge 1A. It extracts the title and hierarchical headings (H1, H2, H3) from a PDF document and outputs a JSON in the specified format.
The model uses a Tiny LayoutLM-style architecture to classify each line of text using both layout and textual features. It is designed to run within strict constraints:
Challenge_1A/
├── app/
│ ├── process_pdfs.py # Entry point
│ ├── pdf_utils.py # PDF text + layout extraction
│ ├── classify_headings.py # Tiny LayoutLM inference wrapper
│ └── model/ # Pretrained model files (≤200MB)
│ ├── config.json
│ ├── pytorch_model.bin
│ └── tokenizer/
│ └── vocab.txt
├── requirements.txt
├── Dockerfile
└── README.md
Text + Layout Extraction:
Tokenization + Embeddings:
Classification:
Title, H1, H2, H3, or Other.Output:
/app/output, matching required schema.This solution runs entirely in a Docker container on linux/amd64 without any internet connection.
docker build --platform linux/amd64 -t pdf-headings .
docker run --rm \\
-v $(pwd)/input:/app/input:ro \\
-v $(pwd)/output:/app/output \\
--network none \\
pdf-headings
.pdf files in input/ folder..json files will be saved to output/.Requirements:
pip install -r requirements.txt
Run Script:
python app/process_pdfs.py
Input and output paths are hardcoded to /app/input and /app/output. You may change these for local use.
{
"title": "Introduction to Document AI",
"outline": [
{ "level": "H1", "text": "Overview", "page": 0 },
{ "level": "H2", "text": "Challenges", "page": 1 },
{ "level": "H3", "text": "Scanned PDFs", "page": 2 }
]
}
/app/model/ and ≤ 200 MB in size.pdf_utils.py to add OCR fallback (e.g., ocrmypdf + Tesseract).1., 1.2).Feel free to reach out for queries, suggestions, or collaboration ideas related to this project.
Python
98.7%
Dockerfile
1.3%