이 문서는 이미지를 다른 LangChain 모듈과 함께 사용할 수 있는 문서 형식으로 로드하는 방법을 다룹니다. .jpg.png와 같은 다양한 이미지 형식을 처리하기 위해 Unstructured를 사용합니다. Unstructured를 로컬에서 설정하는 방법(필수 시스템 종속성 설정 포함)에 대한 자세한 내용은 이 가이드를 참조하세요.

Unstructured 사용하기

pip install -qU "unstructured[all-docs]"
from langchain_community.document_loaders.image import UnstructuredImageLoader

loader = UnstructuredImageLoader("./example_data/layout-parser-paper-screenshot.png")

data = loader.load()

data[0]
Document(page_content='2021\n\n2103.15348v2 [cs.CV] 21 Jun\n\narXiv\n\nLayoutParser: A Unified Toolkit for Deep Learning Based Document Image Analysis\n\nZejiang Shen! (&4), Ruochen Zhang?, Melissa Dell?, Benjamin Charles Germain Lee*, Jacob Carlson?, and Weining Li?\n\n1\n\nAllen Institute for AI [email protected] ? Brown University ruochen_zhang@brown. edu 3 Harvard University {melissadell, jacob_carlson}@fas.harvard.edu 4 University of Washington [email protected] 5 University of Waterloo [email protected]\n\nAbstract. Recent advances in document image analysis (DIA) have been primarily driven by the application of neural networks. Ideally, research outcomes could be easily deployed in production and extended for further investigation. However, various factors like loosely organized codebases and sophisticated model configurations complicate the easy reuse of im- portant innovations by a wide audience. Though there have been on-going efforts to improve reusability and simplify deep learning (DL) model development in disciplines like natural language processing and computer vision, none of them are optimized for challenges in the domain of DIA. This represents a major gap in the existing toolkit, as DIA is central to academic research across a wide range of disciplines in the social sciences and humanities. This paper introduces LayoutParser, an open-source library for streamlining the usage of DL in DIA research and applica- tions. The core LayoutParser library comes with a set of simple and intuitive interfaces for applying and customizing DL models for layout de- tection, character recognition, and many other document processing tasks. To promote extensibility, LayoutParser also incorporates a community platform for sharing both pre-trained models and full document digiti- zation pipelines. We demonstrate that LayoutParser is helpful for both lightweight and large-scale digitization pipelines in real-word use cases. The library is publicly available at https: //layout-parser.github. io.\n\nKeywords: Document Image Analysis - Deep Learning - Layout Analysis - Character Recognition - Open Source library - Toolkit.\n\n1 Introduction\n\nDeep Learning(DL)-based approaches are the state-of-the-art for a wide range of document image analysis (DIA) tasks including document image classification [11,', metadata={'source': './example_data/layout-parser-paper-screenshot.png'})

Element 유지하기

내부적으로 Unstructured는 텍스트의 여러 청크에 대해 서로 다른 “element”를 생성합니다. 기본적으로 이들을 결합하지만, mode="elements"를 지정하여 분리된 상태로 유지할 수 있습니다.
loader = UnstructuredImageLoader(
    "./example_data/layout-parser-paper-screenshot.png", mode="elements"
)

data = loader.load()

data[0]
Document(page_content='2021', metadata={'source': './example_data/layout-parser-paper-screenshot.png', 'coordinates': {'points': ((47.0, 492.0), (47.0, 591.0), (83.0, 591.0), (83.0, 492.0)), 'system': 'PixelSpace', 'layout_width': 1624, 'layout_height': 1920}, 'last_modified': '2024-07-01T10:38:29', 'filetype': 'PNG', 'languages': ['eng'], 'page_number': 1, 'file_directory': './example_data', 'filename': 'layout-parser-paper-screenshot.png', 'category': 'UncategorizedText'})

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I