acvss24 commited on
Commit
c159d6d
·
verified ·
1 Parent(s): 026a257

interface update

Browse files
Files changed (1) hide show
  1. app.py +19 -44
app.py CHANGED
@@ -2,49 +2,24 @@ import gradio as gr
2
  import PIL.Image as Image
3
 
4
 
5
- # Gradio interface
6
-
7
- with gr.Blocks() as app:
8
-
9
- Title=gr.Label("Nutri Assistant App")
10
-
11
- with gr.Row():
12
- Title
13
-
14
- with gr.Row():
15
- gr.Markdown(
16
- "This app generates text for a given image related to nutrition in three low-resource languages")
17
-
18
- with gr.Row():
19
- image_input = gr.Image(type="pil", label="Upload an Image")
20
-
21
- with gr.Row():
22
- english_output = gr.Text(label="English: ")
23
- yoruba_output = gr.Text(label="Yoruba: ")
24
- swahili_output = gr.Text(label="Swahili: ")
25
- twi_output = gr.Text(label="Twi: ")
26
 
27
- with gr.Row():
28
- submit_btn = gr.Button("Submit")
29
- clear_btn = gr.Button("Clear")
30
-
31
- def process_image(image):
32
-
33
- return "English text", "Yoruba text", "Swahili text", "Twi text"
34
-
35
- def clear_outputs():
36
- return None, "", "", "", ""
37
-
38
- submit_btn.click(
39
- fn=process_image,
40
- inputs=[image_input],
41
- outputs=[english_output, yoruba_output, swahili_output, twi_output]
42
- )
43
-
44
- clear_btn.click(
45
- fn=clear_outputs,
46
- inputs=[],
47
- outputs=[image_input, english_output, yoruba_output, swahili_output, twi_output]
48
- )
49
 
50
- app.launch()
 
2
  import PIL.Image as Image
3
 
4
 
5
+ def process_image(image):
6
+ return "English text","Yoruba text", "Swahili text", "Twi text"
7
+ app = gr.Interface(
8
+ fn=process_image,
9
+ inputs = gr.Image(type="pil", label="Upload an Image"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ outputs = [
12
+ gr.Text(label="English: "),
13
+ gr.Text(label="Yoruba: "),
14
+ gr.Text(label="Swahili: "),
15
+ gr.Text(label="Twi: "),
16
+ ],
17
+ title="Nutri Assistant App",
18
+ description="This app generates text for a given image related to nutrition in three low-resource languages",
19
+ examples =[["spaghetti.png"],
20
+ ["cake.png"]],
21
+
22
+ )
23
+ if __name__ == "__main__":
24
+ app.launch()
 
 
 
 
 
 
 
 
25