File size: 934 Bytes
377ebdf
cac69c8
3bd9346
cac69c8
3bd9346
988fe48
 
 
 
 
 
cac69c8
689bc80
988fe48
3bd9346
cac69c8
35e486f
cac69c8
 
988fe48
 
5aa785c
3bd9346
cac69c8
 
988fe48
cac69c8
3bd9346
5aa785c
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 spaces
import gradio as gr
from panna import CLIPInterrogator

model = CLIPInterrogator()
css = """
#col-container {
    margin: 0 auto;
    max-width: 580px;
}
"""


@spaces.GPU
def infer(image, best_max_flavors):
    image = image.convert('RGB')
    return model(image, best_max_flavors=best_max_flavors)


with gr.Blocks(css=css) as demo:
    with gr.Column(elem_id="col-container"):
        gr.Markdown("# CLIP Interrogator\nThe demo is part of [panna](https://github.com/asahi417/panna) project.")
        input_image = gr.Image(type='pil')
        with gr.Row():
            flavor_input = gr.Slider(minimum=2, maximum=48, step=2, value=32, label='best mode max flavors')
        run_button = gr.Button("Submit")
        output_text = gr.Textbox(label="Description Output")
    run_button.click(fn=infer, inputs=[input_image, flavor_input], outputs=[output_text], concurrency_limit=10)
demo.launch(server_name="0.0.0.0")