EasyDetect / app.py
sunnychenxiwang's picture
app update
50e84c0
raw
history blame
1.67 kB
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"
def get_response(text, filepath):
pipeline = Pipeline()
res = pipeline.run(text=text, image_path=image_path)
return res
demo = gr.Interface(
fn=get_response,
inputs=["text", gr.Image(type="filepath")],
outputs=["text"],
)
demo.launch()
# def generate_mutimodal(title, context, img):
# return f"Title:{title}\nContext:{context}\n...{img}"
# server = gr.Interface(
# fn=generate_mutimodal,
# inputs=[
# gr.Textbox(lines=1, placeholder="请输入标题"),
# gr.Textbox(lines=2, placeholder="请输入正文"),
# gr.Image(shape=(200, 200), label="请上传图片(可选)")
# ],
# outputs="text"
# )
# server.launch()
# import numpy as np
# import gradio as gr
# def sepia(input_img):
# #处理图像
# sepia_filter = np.array([
# [0.393, 0.769, 0.189],
# [0.349, 0.686, 0.168],
# [0.272, 0.534, 0.131]
# ])
# sepia_img = input_img.dot(sepia_filter.T)
# sepia_img /= sepia_img.max()
# return sepia_img
# #shape设置输入图像大小
# demo = gr.Interface(sepia, gr.Image(), "image")
# demo.launch()
# Download human-readable labels for ImageNet.
# gr.Interface(fn=sepia,inputs=gr.Image(type="pil"),outputs="image").launch()