File size: 1,250 Bytes
3153924
b6faa5c
3153924
b6faa5c
 
 
 
 
6292093
81700f6
62769de
2938dd3
d071360
 
 
 
 
 
 
 
2938dd3
62769de
6292093
 
 
3153924
 
6292093
 
62769de
fe542b3
 
6292093
b6faa5c
 
 
 
 
3153924
 
 
 
 
b6faa5c
 
3153924
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
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
    )