You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuntimeError: (NotFound) Operator (one_hot) is not registered. [Hint: op_info_ptr should not be null.] (at ..\paddle/fluid/framework/op_info.h:152)
#513
Open
Idaydayup opened this issue
Dec 28, 2023
· 5 comments
#报错D:\anaconda\envs\p5\python.exe D:\pycharm\实训2\任务5\内容识别.py
D:\anaconda\envs\p5\lib\site-packages_distutils_hack_init_.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
E1228 17:47:01.441207 15760 analysis_config.cc:653] Please compile with MKLDNN first to use MKLDNN
Traceback (most recent call last):
File "D:\pycharm\实训2\任务5\内容识别.py", line 18, in
docprompt = Taskflow("document_intelligence")
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 804, in init
self.task_instance = task_class(
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\document_intelligence.py", line 68, in init
self._get_inference_model()
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\task.py", line 372, in _get_inference_model
self._prepare_static_mode()
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\task.py", line 227, in _prepare_static_mode
self.predictor = paddle.inference.create_predictor(self._config)
RuntimeError: (NotFound) Operator (one_hot) is not registered.
[Hint: op_info_ptr should not be null.] (at ..\paddle/fluid/framework/op_info.h:152)
进程已结束,退出代码1
The text was updated successfully, but these errors were encountered:
代码
import gradio as gr
from paddlenlp import Taskflow
import numpy as np
from PIL import Image
import uuid
初始化文档智能任务模型
docprompt = Taskflow("document_intelligence")
定义模型推理函数
def model_inference(image, prompt):
prompt = prompt.split("?")[:-1]
img = Image.fromarray(np.uint8(image))
filename = "image/" + str(uuid.uuid4()) + ".png"
img.save(filename)
res = docprompt([{"doc": filename, "prompt": prompt}])
json_out = {"result": res}
print(json_out)
return image, json_out
定义清除函数
def clear_all():
return None, None, None
使用Gradio构建用户界面
with gr.Blocks() as demo:
gr.Markdown("ERNIE-Layout")
with gr.Column(scale=1, min_width=100):
# 输入图片和文本框
img_in = gr.Image(value="图片.jpg", label="Input")
text = gr.Textbox(value="发票号码是多少?校验码是多少?", label="输入问题:", lines=2)
with gr.Row():
# 清除和提交按钮
btn1 = gr.Button("Clear")
btn2 = gr.Button("Submit")
json_out = gr.JSON(label="Information Extraction Output")
img_out = gr.Image(label="Output") # 输出图片
# 绑定按钮点击事件到函数
btn1.click(fn=clear_all, inputs=None, outputs=[img_in, img_out, json_out])
btn2.click(fn=model_inference, inputs=[img_in, text], outputs=[img_out, json_out])
demo.launch(server_port=7008) # 启动Gradio界面,监听7008端口)
#报错D:\anaconda\envs\p5\python.exe D:\pycharm\实训2\任务5\内容识别.py
D:\anaconda\envs\p5\lib\site-packages_distutils_hack_init_.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
E1228 17:47:01.441207 15760 analysis_config.cc:653] Please compile with MKLDNN first to use MKLDNN
Traceback (most recent call last):
File "D:\pycharm\实训2\任务5\内容识别.py", line 18, in
docprompt = Taskflow("document_intelligence")
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 804, in init
self.task_instance = task_class(
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\document_intelligence.py", line 68, in init
self._get_inference_model()
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\task.py", line 372, in _get_inference_model
self._prepare_static_mode()
File "D:\anaconda\envs\p5\lib\site-packages\paddlenlp\taskflow\task.py", line 227, in _prepare_static_mode
self.predictor = paddle.inference.create_predictor(self._config)
RuntimeError: (NotFound) Operator (one_hot) is not registered.
[Hint: op_info_ptr should not be null.] (at ..\paddle/fluid/framework/op_info.h:152)
进程已结束,退出代码1
The text was updated successfully, but these errors were encountered: