Spaces:
Sleeping
Sleeping
File size: 1,206 Bytes
ca86d9d 50e84c0 55d9644 ad4956a 55d9644 225738c 55d9644 ad4956a 50e84c0 55d9644 50e84c0 ad4956a 55d9644 |
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 |
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)
|