langchain_community.document_loaders.image
.UnstructuredImageLoader¶
- class langchain_community.document_loaders.image.UnstructuredImageLoader(file_path: Optional[Union[str, List[str], Path, List[Path]]], mode: str = 'single', **unstructured_kwargs: Any)[source]¶
使用`Unstructured`加载`PNG`和`JPG`文件。
您可以在两种模式中的一种中运行加载程序:”single”和”elements”。 如果使用”single”模式,文档将作为单个langchain Document对象返回。 如果使用”elements”模式,unstructured库将文档拆分为诸如Title和NarrativeText之类的元素。 您可以在模式之后传递额外的unstructured kwargs以应用不同的unstructured设置。
from langchain_community.document_loaders import UnstructuredImageLoader
- loader = UnstructuredImageLoader(
“example.png”, mode=”elements”, strategy=”fast”,
) docs = loader.load()
https://unstructured-io.github.io/unstructured/bricks.html#partition-image
使用文件路径进行初始化。
Methods
__init__
(file_path[, mode])使用文件路径进行初始化。
一个用于文档的惰性加载器。
aload
()将数据加载到文档对象中。
加载文件。
load
()将数据加载到文档对象中。
load_and_split
([text_splitter])加载文档并分割成块。块作为文档返回。
- Parameters
file_path (Optional[Union[str, List[str], Path, List[Path]]]) –
mode (str) –
unstructured_kwargs (Any) –
- __init__(file_path: Optional[Union[str, List[str], Path, List[Path]]], mode: str = 'single', **unstructured_kwargs: Any)¶
使用文件路径进行初始化。
- Parameters
file_path (Optional[Union[str, List[str], Path, List[Path]]]) –
mode (str) –
unstructured_kwargs (Any) –
- load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document] ¶
加载文档并分割成块。块作为文档返回。
不要覆盖此方法。应该被视为已弃用!
- 参数:
- text_splitter: 用于分割文档的TextSplitter实例。
默认为RecursiveCharacterTextSplitter。
- 返回:
文档列表。
- Parameters
text_splitter (Optional[TextSplitter]) –
- Return type
List[Document]