File size: 1,307 Bytes
d336c8b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
import testMch as func
def work(imgurl):
# output = testMch.describeImage2(img)
# # output = testMch.agent(img)
# # output = testMch.agent(img)
# return output
# imgurl = "r" + imgurl
# imgurl = imgurl.replace("\\\\\\", "\\")
# input = "Describe the following image:\n" + imgurl
out = func.agent(f"Please describe the following image:\n{imgurl}")
anws = func.toChinese(out['output'])
return anws
# with gr.Blocks() as demo:
# image_url = gr.Image(type="filepath", label="请选择一张图片")
# input = gr.Textbox(label='请描述您的问题', placeholder="", lines=1)
# output = gr.Textbox(label='答案', placeholder="", lines=2, interactive=False)
# submit = gr.Button('提问', variant="primary")
# submit.click(work, inputs=[image_url, input], outputs=output)
# demo.launch()
demo = gr.Interface(title="识别图片",
css="",
fn=work,
inputs=[gr.Image(type="filepath", label="请上传图片")],
outputs=[gr.Textbox(lines=3, label="识别结果")])
#
# # demo = gr.Interface(fn=work, inputs="image,text", outputs="text")
#
demo.launch()
# # interface = gr.Interface(fn=agent, inputs="image", outputs="text")
# # interface.launch()
|