File size: 1,619 Bytes
341d44c
d473761
 
742fbf4
341d44c
49de293
341d44c
 
 
742fbf4
7ac068e
341d44c
 
782aea4
341d44c
 
 
d42bb0c
11141bc
 
341d44c
 
 
 
d06af2a
b7c19a9
341d44c
 
 
 
49de293
341d44c
 
 
d473761
 
341d44c
 
 
9e0886b
d473761
341d44c
 
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
# Importing the requirements
# import warnings
# warnings.filterwarnings("ignore")

import gradio as gr
from src.app.response import describe_image


# Image and text inputs for the interface
image = gr.Image(type="pil", label="Image")
question = gr.Textbox(label="Question", placeholder="Enter your question here")

# Output for the interface
answer = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)

# Examples for the interface
examples = [
    ["images/cat.jpg", "How many cats are there?"],
    ["images/dog.jpg", "¿De qué color es el perro?"],
    ["images/bird.jpg", "Que fait l'oiseau ?"],
]

# Title, description, and article for the interface
title = "Visual Question Answering"
description = "Gradio Demo for the MiniCPM-V 2.6 Vision Language Understanding and Generation model. This model can answer questions about images in natural language. To use it, simply upload your image, type a question, and click 'submit', or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"


# Launch the interface
interface = gr.Interface(
    fn=describe_image,
    inputs=[image, question],
    outputs=answer,
    examples=examples,
    cache_examples=True,
    cache_mode="lazy",
    title=title,
    description=description,
    article=article,
    theme="JohnSmith9982/small_and_pretty",
    flagging_mode="never",
)
interface.launch(debug=False)