Unverified 提交 5f069779 作者: ysyx2008 提交者: GitHub

解决 image_loader.py 运行时报错“ModuleNotFoundError: No module named 'configs'”的问题。 (#795)

上级 a8a3ea9c
...@@ -5,9 +5,6 @@ from langchain.document_loaders.unstructured import UnstructuredFileLoader ...@@ -5,9 +5,6 @@ from langchain.document_loaders.unstructured import UnstructuredFileLoader
from paddleocr import PaddleOCR from paddleocr import PaddleOCR
import os import os
import nltk import nltk
from configs.model_config import NLTK_DATA_PATH
nltk.data.path = [NLTK_DATA_PATH] + nltk.data.path
class UnstructuredPaddleImageLoader(UnstructuredFileLoader): class UnstructuredPaddleImageLoader(UnstructuredFileLoader):
"""Loader that uses unstructured to load image files, such as PNGs and JPGs.""" """Loader that uses unstructured to load image files, such as PNGs and JPGs."""
...@@ -35,6 +32,10 @@ class UnstructuredPaddleImageLoader(UnstructuredFileLoader): ...@@ -35,6 +32,10 @@ class UnstructuredPaddleImageLoader(UnstructuredFileLoader):
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__))) sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from configs.model_config import NLTK_DATA_PATH
nltk.data.path = [NLTK_DATA_PATH] + nltk.data.path
filepath = os.path.join(os.path.dirname(os.path.dirname(__file__)), "knowledge_base", "samples", "content", "test.jpg") filepath = os.path.join(os.path.dirname(os.path.dirname(__file__)), "knowledge_base", "samples", "content", "test.jpg")
loader = UnstructuredPaddleImageLoader(filepath, mode="elements") loader = UnstructuredPaddleImageLoader(filepath, mode="elements")
docs = loader.load() docs = loader.load()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论