sitammeur commited on
Commit
5d1d027
·
verified ·
1 Parent(s): 47042ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -5
app.py CHANGED
@@ -6,18 +6,45 @@ import gradio as gr
6
  from src.app.response import describe_image
7
 
8
 
9
- # Image and text inputs for the interface
10
  image = gr.Image(type="pil", label="Image")
11
  question = gr.Textbox(label="Question", placeholder="Enter your question here")
 
 
 
 
 
 
12
 
13
  # Output for the interface
14
  answer = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)
15
 
16
  # Examples for the interface
17
  examples = [
18
- ["images/cat.jpg", "How many cats are there?"],
19
- ["images/dog.jpg", "¿De qué color es el perro?"],
20
- ["images/bird.jpg", "Que fait l'oiseau ?"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ]
22
 
23
  # Title, description, and article for the interface
@@ -29,7 +56,7 @@ article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/Min
29
  # Launch the interface
30
  interface = gr.Interface(
31
  fn=describe_image,
32
- inputs=[image, question],
33
  outputs=answer,
34
  examples=examples,
35
  cache_examples=True,
 
6
  from src.app.response import describe_image
7
 
8
 
9
+ # Image, text query, and input parameters
10
  image = gr.Image(type="pil", label="Image")
11
  question = gr.Textbox(label="Question", placeholder="Enter your question here")
12
+ temperature = gr.Slider(
13
+ minimum=0.01, maximum=1.99, step=0.01, value=0.7, label="Temperature"
14
+ )
15
+ top_p = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.8, label="Top P")
16
+ top_k = gr.Slider(minimum=0, maximum=1000, step=1, value=100, label="Top K")
17
+ max_new_tokens = gr.Slider(minimum=1, maximum=4096, step=1, value=512, label="Max Tokens")
18
 
19
  # Output for the interface
20
  answer = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)
21
 
22
  # Examples for the interface
23
  examples = [
24
+ [
25
+ "images/cat.jpg",
26
+ "How many cats are there?",
27
+ 0.7,
28
+ 0.8,
29
+ 100,
30
+ 512,
31
+ ],
32
+ [
33
+ "images/dog.jpg",
34
+ "¿De qué color es el perro?",
35
+ 0.7,
36
+ 0.8,
37
+ 100,
38
+ 512,
39
+ ],
40
+ [
41
+ "images/bird.jpg",
42
+ "Que fait l'oiseau ?",
43
+ 0.7,
44
+ 0.8,
45
+ 100,
46
+ 512,
47
+ ],
48
  ]
49
 
50
  # Title, description, and article for the interface
 
56
  # Launch the interface
57
  interface = gr.Interface(
58
  fn=describe_image,
59
+ inputs=[image, question, temperature, top_p, top_k, max_new_tokens],
60
  outputs=answer,
61
  examples=examples,
62
  cache_examples=True,