TYH71
add: flower example
d071360
"""
main script for gradio application
"""
import argparse
import gradio as gr
# modules
from src.core.logger import logger
from src.interface.clip import clip_demo_fn
# Constants
EXAMPLES = [
[
"examples/9FGUrrp.jpg",
"anime character, human being, anime male, anime female"
],
[
"examples/Dandelion-Tea-Fertilzer-Feature.jpg",
"marigold, buttercup, oxeye daisy, common dandelion",
],
]
demo = gr.Interface(
fn=clip_demo_fn,
inputs=[
gr.Image(type="pil", label="Image"),
gr.Text(placeholder="comma separated text", label="Text"),
],
outputs=gr.Label(label="Class and its associated probability"),
title="OpenCLIP Gradio Demo",
allow_flagging="never",
examples=EXAMPLES,
)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--host", default="0.0.0.0", type=str)
parser.add_argument(
"--port",
help="will start gradio app on this port (if available)",
default=7860,
type=int,
)
args_all = parser.parse_args()
logger.info("Gradio Application live and running !")
demo.queue().launch(
share=False, server_name=args_all.host, server_port=args_all.port
)