|
|
import gradio as gr |
|
|
import PIL.Image as Image |
|
|
|
|
|
|
|
|
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): |
|
|
|
|
|
|
|
|
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() |