Spaces:
Sleeping
Sleeping
import gradio as gr | |
import os | |
from service.controllers import inference_tag2text | |
# ํ ์คํธ ์ด๋ฏธ์ง ์ธํ | |
examples = ["./service/examples/" + i for i in os.listdir("./service/examples")] | |
def start_app(): | |
with gr.Blocks(title="์ ์ฌ์ฌ๋ก ์ฐพ๊ธฐ") as app: | |
with gr.Box(): | |
input_img = gr.Image(type="pil", label="์ฌ๊ณ ์ํฉ์ ์ฌ์ง์ผ๋ก ์ ๋ ฅ", shape=(200, 200)) | |
gr.Examples(examples, inputs=[input_img], label="์ฌ์ง ์์") | |
input_emphasis_word = gr.Text(label="๊ฐ์กฐํ๊ณ ์ถ์ ๋จ์ด ์ ๋ ฅ") | |
with gr.Row(): | |
find_btn = gr.Button("์ ์ฌํ ์ฌ๊ณ ์ฌ๋ก๋ฅผ ์ฐพ์ต๋๋ค") | |
with gr.Box(): | |
output_url = gr.Text(label="์ฌ๊ณ ์ํฉ๊ณผ ์ ์ฌํ ์์ URL") | |
output_tags = gr.Text(label="์ฌ๊ณ ์ํฉ ํ๊ทธ") | |
output_caption = gr.Text(label="์ฌ๊ณ ์ํฉ ์บก์ ") | |
find_btn.click( | |
fn=inference_tag2text, | |
inputs=[input_img, input_emphasis_word], | |
outputs=[output_url, output_tags, output_caption], | |
api_name="greet", | |
) | |
return app | |