Back to projects
TFM2026

Document Structure AI Master's Thesis

End-to-end platform that transforms scanned documents and PDFs into clean, editable HTML — faithfully preserving the original layout structure. The system uses a hybrid AI pipeline combining local computer vision (DocLayout-YOLOv10) for layout segmentation and cloud-based LLMs (Gemini) for semantic OCR, ensuring no critical component like signatures, stamps, or tables is lost during reconstruction.

Key features

01

Drag & drop upload

Upload scanned notes or PDFs instantly. Supports images and multi-page documents with a single drag-and-drop action.

02

AI-powered layout detection

DocLayout-YOLOv10 analyses the visual structure in real time, detecting headings, paragraphs, lists, tables, logos, signatures, and stamps.

03

Semantic HTML reconstruction

Gemini API transcribes and structures the document into clean, accessible HTML5 — faithfully preserving the original hierarchy and reading order.

04

Hybrid reconstruction

Non-text elements like signatures and stamps are extracted via OpenCV and re-embedded as Data URLs, ensuring nothing is lost.

Development process

01

Ideation & research

Defined the core problem — turning handwritten/scanned notes into structured, editable digital documents. Explored state-of-the-art models for layout detection (DocLayout-YOLO) and OCR (TrOCR, Gemini).

02

Model prototyping

Tested multiple model combinations in a Colab notebook. Compared YOLO variants, evaluated TrOCR vs Gemini for text extraction accuracy, and refined the detection pipeline.

03

API integration

Once the pipeline was stable, integrated it into a FastAPI microservice. Added PDF rasterisation (pdf2image), image normalisation (Pillow/OpenCV), and Gemini structural prompting.

04

Frontend development

Built a React/Next.js interface with drag-and-drop upload, real-time layout preview, and an editable HTML output panel. Deployed the app on Google Cloud Run.

05

Thesis defence

Presented the full project before the Master's jury — covering the architecture, pipeline decisions, and live demo of the working application.

Reflections & learnings

Building a generic CV pipeline is harder than it looks — edge cases multiply fast: varying image quality, handwriting vs print, complex multi-column layouts, millions of potential document formats. The model works well within its scope but would need significantly more training data to generalise. After presenting the project, I spoke with fellow students who confirmed how useful a tool like this would be — something close to NotebookLM but with layout-aware digitisation as the core feature. An obvious next step (that I ran out of time to test) is improving handwritten text recognition in the pipeline.

Gallery

Presentation of the Master's Thesis (TFM) project before the academic tribunal. MIOTI, 2026.

Presentation of the Master's Thesis (TFM) project before the academic tribunal. MIOTI, 2026.

App prototype

App prototype

App prototype

App prototype

Tech stack

Python
FastAPI
YOLOv10
TrOCR
Gemini API
React
Next.js
Tailwind CSS
OpenCV
Docker
Google Cloud Run