File size: 1,386 Bytes
7c10316
 
 
 
85a6a9e
83ee2cb
 
7c10316
 
83ee2cb
7c10316
83ee2cb
 
7c10316
83ee2cb
 
 
 
 
 
 
 
7c10316
83ee2cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c10316
 
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
import gradio as gr
import PIL.Image as Image

# Gradio interface
with gr.Blocks(theme=gr.themes.Soft()) as interface:
    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):
        # Add your image processing logic here
        # For now, we'll just return placeholder text
        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]
    )

interface.launch()