Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,47 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import PIL.Image as Image
|
| 3 |
|
| 4 |
-
|
| 5 |
# Gradio interface
|
| 6 |
-
|
| 7 |
with gr.Blocks(theme=gr.themes.Soft()) as interface:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
with gr.Row():
|
| 12 |
Title
|
| 13 |
-
|
| 14 |
with gr.Row():
|
| 15 |
-
gr.Markdown(
|
| 16 |
-
|
| 17 |
-
|
| 18 |
with gr.Row():
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Row():
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import PIL.Image as Image
|
| 3 |
|
|
|
|
| 4 |
# Gradio interface
|
|
|
|
| 5 |
with gr.Blocks(theme=gr.themes.Soft()) as interface:
|
| 6 |
+
Title = gr.Label("Nutri Assistant App")
|
| 7 |
+
|
|
|
|
| 8 |
with gr.Row():
|
| 9 |
Title
|
| 10 |
+
|
| 11 |
with gr.Row():
|
| 12 |
+
gr.Markdown("This app generates text for a given image related to nutrition in three low-resource languages")
|
| 13 |
+
|
|
|
|
| 14 |
with gr.Row():
|
| 15 |
+
image_input = gr.Image(type="pil", label="Upload an Image")
|
| 16 |
+
|
| 17 |
+
with gr.Row():
|
| 18 |
+
english_output = gr.Text(label="English: ")
|
| 19 |
+
yoruba_output = gr.Text(label="Yoruba: ")
|
| 20 |
+
swahili_output = gr.Text(label="Swahili: ")
|
| 21 |
+
twi_output = gr.Text(label="Twi: ")
|
| 22 |
+
|
| 23 |
with gr.Row():
|
| 24 |
+
submit_btn = gr.Button("Submit")
|
| 25 |
+
clear_btn = gr.Button("Clear")
|
| 26 |
+
|
| 27 |
+
def process_image(image):
|
| 28 |
+
# Add your image processing logic here
|
| 29 |
+
# For now, we'll just return placeholder text
|
| 30 |
+
return "English text", "Yoruba text", "Swahili text", "Twi text"
|
| 31 |
+
|
| 32 |
+
def clear_outputs():
|
| 33 |
+
return None, "", "", "", ""
|
| 34 |
+
|
| 35 |
+
submit_btn.click(
|
| 36 |
+
fn=process_image,
|
| 37 |
+
inputs=[image_input],
|
| 38 |
+
outputs=[english_output, yoruba_output, swahili_output, twi_output]
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
clear_btn.click(
|
| 42 |
+
fn=clear_outputs,
|
| 43 |
+
inputs=[],
|
| 44 |
+
outputs=[image_input, english_output, yoruba_output, swahili_output, twi_output]
|
| 45 |
+
)
|
| 46 |
|
| 47 |
interface.launch()
|