Diard is a document image analysis pipeline to extract semi-structured Analysis Ready Data from your Document's Images. To achieve this, the state-of-the-art layout detection model is used (DiT) to extract document objects (e.g., title, text, list, figure,...) along with table-transformer for table extraction. These objects are then used to segment the sections (e.g., Table Of Contents, Introduction,...) and to find the information needed to obtain a semi-structured version of your document. The pipeline output can be exported as HTML for evaluation and as JSON for text analysis.
First, clone the repository and use the setup guide to run things locally.
git clone https://github.com/thibaultvt/Diard.git
cd Diard
If you just want to test the pipeline, go ahead and use the following command to run the example script.
python main.py
After runnnig the above command, you should see output similar to the one below in your terminal.
Processing 'example': 0%| | 0/8 [00:00<?, ?it/s]
2022-05-16 09:46:34,138 | INFO: Language detection successful! Language is now set to German (deu).
Processing 'example': 12%|█████████████████▎ | 1/8 [00:03<00:25, 3.61s/it]
For more detailed explanations on how the pipeline can be used, you can refer to the examples. Please note that the main Python script should always be ran from the root of the repository.
Diard
│ │
│ main.py # The document image analysis pipeline
│ requirements.txt # List of required Python libraries
│ README.md # This file
│
+---ditod # Microsoft's DiT modules
|
+---modules
│ │
│ │ utils.py # Non-class specific functions
│ │ document.py # Document class definition
│ │ exceptions.py # Custom exceptions
│ │ sections.py # Section segmentation related functions
│ │ export.py # Export/ evaluation related methods (HTML, JSON)
│
+---docs
│ │
│ │ setup_guide.md # Environment setup guide
│
+---resources
│ │
│ │ stylesheet.css # Stylesheet for HTML visualization
│ │ stylescript.js # Style script for HTML visualization
│ │
│ +---images # Images used in README.md
│ │
│ +---model_configs # Configuration files for DiT
│ │
│ +---pdfs # To be processed pdfs
│ │ │ example.pdf
│ │ │ ...
│ │
│ +---weights # Storage for pre-trained model weights
│ │ publaynet_dit-l_cascade.pth # Weights used in initial release
│
+---output # Default output dir (created by pipeline)
│
+---example # Directory for each PDF you process
│
+---html # Storage for HTML visualizations
│
+---jsons # Storage for doc layout JSON files
│
+---visualizations # Storage for detection visualizations