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() |