File size: 1,673 Bytes
ef3d2c0 d336c8b ef3d2c0 4007c63 8589cca 7eb62d4 63c44d1 ef3d2c0 d336c8b 17871e5 d00ba07 17871e5 0cdc59c |
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 |
import gradio as gr
import image_feature as func
def work11(image1, image2):
return func.similarity_cpu(image1, image2)
# return func.infer1(image1, image2)
# return func.infer4(image1, image2)
# 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()
# 定义你的界面
# with gr.Interface(fn=work11,
# inputs=[gr.Textbox(label='图片1', lines=1), gr.Textbox(label='图片2', lines=1)], # 两个文本输入框
# outputs=[gr.Textbox(lines=3, label="推理结果")], # 输出为文本
# title="图片相似度推理", # 界面标题
# description="输入两张图片链接进行相似度推理", # 界面描述
# examples=[["https://example.com", "https://google.com"], # 示例输入
# ["https://github.com", "https://twitter.com"]]) as demo: # 更多示例输入
# demo.launch() # 启动界面
demo = gr.Interface(title="图片相似度推理",
css="",
fn=work11,
inputs=[gr.Image(type="pil", label="图片1"), gr.Image(type="pil", label="图片2")],
outputs=[gr.Textbox(lines=3, label="推理结果")])
#
# # demo = gr.Interface(fn=work, inputs="image,text", outputs="text")
#
demo.launch() |