Package: visarchpy
VisArchPyData pipelines for extraction, transformation and visualization of architectural visuals in Python. It extracts images embedded in PDF files, collects relevant metadata, and extracts visual features using the DinoV2 model.
We ambition to make of this package Ai-powered tool with features for recorgnizing different types architectural visuals (types of buildings, structures, etc.). The package is still in development and we are working on adding more features and improving the existing ones. If you have any suggestions or questions, please open an issue in ourGitHub repository.Main FeaturesExtraction pipelinesLayout:pipeline for extracting metadata and visuals (images) from PDF files using a layout analysis. Layout analysis recursively checks elements in the PDF file and sorts them into images, text, and other elements.OCR:pipeline for extracting metadata and visuals from PDF files using OCR analysis. OCR analysis extracts images from PDF files using Tesseract OCR.LayoutOCR:pipeline for extracting metadata and visuals from PDF files that combines layout and OCR analysis.Metadata ExtractionExtraction of medatdata of extracted images (document page, image size)Extraction of captions of images based on proximity to images andtext-analysisusing keywords.Transformation utilitiesDino:pipeline for transforming images into visual features using the self-supervised  learning inDinoV2.Visualization utilitiesViz:an utility to create abounding box plot. This plot provides an overview of the shapes and sizes of images in a data set.DependenciesPython 3.10 or 3.11Tesseract v4.0 or recentPyTorch v2.1 or recentInstallionAfter installing the dependencies, install VisArchPy usingpip.pipinstallvisarchpyInstalling from sourceClone the repository.gitclonehttps://github.com/AiDAPT-A/VisArchPy.gitGo to the root of the repository.cdVisArchPy/Install the package usingpip.pipinstall.Developers who intend to modify the sourcecode can install additional dependencies for test and documentation as follows.Go to the root directoryvisarchpy/Run:pipinstall-e.[dev]UsageVisArchPy provides a command line interface to access its functionality. If you want to VisArchPy as a Python package consult thedocumentation.To access the CLI:visarch-hTo access a particular pipeline:visarch[PIPELINE][SUBCOMMAND]For example, to run thelayoutpipeline using a single PDF file, do the following:visarchlayoutfrom-file<path-to-pdf-file><path-output-directory>Usevisarch [PIPELINE] [SUBCOMMAND] -hfor help.ResultsResults from the data extraction pipelines (Layout, OCR, LayoutOCR) are save to the output directory. Results are organized as following:00000/# results directory├──pdf-001# directory where images are saved to. One per PDF file├──00000-metadata.csv# extracted metadata as CSV├──00000-metadata.json# extracted metadata as JSON├──00000-settings.json# settings used by pipeline└──00000.log# log fileSettingsThe pipeline's settings determine how visual extraction from PDF files is performed. Settings must be passed as a JSON file on the CLI. Settings may must include all items listed below. The values showed belowed are the defaults.Available settings{"layout":{# setting for layout analysis"caption":{"offset":[# distance used to locate captions4,"mm"],"direction":"down",# direction used to locate captions"keywords":[# keywords used to find captions based on text analysis"figure","caption","figuur"]},"image":{# images smaller than these dimensions will be ignored"width":120,"height":120}},"ocr":{# settings for OCR analysis"caption":{"offset":[50,"px"],"direction":"down","keywords":["figure","caption","figuur"]},"image":{"width":120,"height":120},"resolution":250,# dpi to convert PDF pages to images before OCR"resize":30000# total pixels. Larger OCR inputs are downsize to this before OCR"tesseract":"--psm 1 --oem 3"# tesseract options}}When no seetings are passed to a pipeline, the defaults are used. To print the default seetting to the terminal use:visarch[PIPELINE]settingsCitationPlease cite this software using as follows:Garcia Alvarez, M. G., Khademi, S., & Pohl, D. (2023). VisArchPy [Computer software].https://github.com/AiDAPT-A/VisArchPyAcknowlegdementsVisArchPy was develped thanks to the support provided by theDigital Competence Centre, Delft University of Technology.Reseach Data Services, Delft University of Technology, The Netherlands.