huaapp / app.py
chanhua's picture
8
d336c8b verified
raw
history blame
1.19 kB
import gradio as gr
import image_feature as func
def work(image1, image2):
return func.infer1(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=work,
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() # 启动界面