File size: 1,262 Bytes
947b71d
 
 
 
 
 
68d4af2
947b71d
 
 
 
 
 
 
 
 
 
 
026a257
947b71d
 
026a257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947b71d
 
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
50
51
import gradio as gr
import PIL.Image as Image


# Gradio interface

with gr.Blocks() as app:

    Title=gr.Label("Nutri Assistant App")

    with gr.Row():
        Title

    with gr.Row():
        gr.Markdown(
            "This app generates text for a given image related to nutrition in three low-resource languages")

    with gr.Row():
        image_input = gr.Image(type="pil", label="Upload an Image")

    with gr.Row():
        english_output = gr.Text(label="English: ")
        yoruba_output = gr.Text(label="Yoruba: ")
        swahili_output = gr.Text(label="Swahili: ")
        twi_output = gr.Text(label="Twi: ")
        
    with gr.Row():
        submit_btn = gr.Button("Submit")
        clear_btn = gr.Button("Clear")
    
    def process_image(image):
       
        return "English text", "Yoruba text", "Swahili text", "Twi text"
    
    def clear_outputs():
        return None, "", "", "", ""
    
    submit_btn.click(
        fn=process_image,
        inputs=[image_input],
        outputs=[english_output, yoruba_output, swahili_output, twi_output]
    )
    
    clear_btn.click(
        fn=clear_outputs,
        inputs=[],
        outputs=[image_input, english_output, yoruba_output, swahili_output, twi_output]
    )

app.launch()