EasyDetect / app.py
sunnychenxiwang's picture
Update app.py
47bb245 verified
raw
history blame
1.25 kB
import os
os.system('python install.py')
import gradio as gr
from pipeline.run_pipeline import *
'''
时间优化
并发优化
'''
# from run import *
# '''
# 把一些文件移动到此文件路径下
# '''
# text = "A person is cutting a birthday cake with two red candles that spell out \"21\". The surface of the cake is round, and there is a balloon in the room. The person is using a silver knife to cut the cake."
# image_path = "/newdisk3/wcx/val2014/COCO_val2014_000000297425.jpg"
pipeline = Pipeline(type="image-to-text", api_key="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")
# res,claim_list = pipeline.run(text=text, image_path=image_path,type="image-to-text")
# print(res)
def get_response(text, filepath, type):
res, claim_list = pipeline.run(text=text, image_path=filepath, type=type)
return claim_list, res
demo = gr.Interface(
fn=get_response,
inputs=[gr.Textbox(placeholder="Input I2T model's response or T2I model's prompt", label="text input"), gr.Image(type="filepath", label="image input"), gr.Radio(['image-to-text','text-to-image'], label='task type', value='image-to-text')],
outputs=[gr.Textbox(label="claim list"), gr.Textbox(label="detect results")],
)
demo.queue().launch(share=True)