forked from Archives/langchain
feat: document loader for image files (#1330)
### Summary Adds a document loader for image files such as `.jpg` and `.png` files. ### Testing Run the following using the example document from the [`unstructured` repo](https://github.com/Unstructured-IO/unstructured/tree/main/example-docs). ```python from langchain.document_loaders.image import UnstructuredImageLoader loader = UnstructuredImageLoader("layout-parser-paper-fast.jpg") loader.load() ```searx-doc
parent
c14cff60d0
commit
1aa41b5741
@ -0,0 +1,13 @@
|
|||||||
|
"""Loader that loads image files."""
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from langchain.document_loaders.unstructured import UnstructuredFileLoader
|
||||||
|
|
||||||
|
|
||||||
|
class UnstructuredImageLoader(UnstructuredFileLoader):
|
||||||
|
"""Loader that uses unstructured to load image files, such as PNGs and JPGs."""
|
||||||
|
|
||||||
|
def _get_elements(self) -> List:
|
||||||
|
from unstructured.partition.image import partition_image
|
||||||
|
|
||||||
|
return partition_image(filename=self.file_path)
|
Loading…
Reference in New Issue