Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,33 +64,34 @@ def translate_recipe(recipe):
|
|
64 |
translated_recipe = translator(recipe)[0]['translation_text']
|
65 |
return translated_recipe
|
66 |
|
67 |
-
# Paso 4: Crear la interfaz de Gradio
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
)
|
|
|
|
|
76 |
|
77 |
-
#
|
78 |
-
def
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
title="Recipe Generator from Dish Image",
|
91 |
-
description="Upload an image of a dish to get a detailed description, ingredient list, and step-by-step recipe. Optionally, translate the recipe to Spanish.",
|
92 |
-
flagging_mode="never"
|
93 |
-
)
|
94 |
|
95 |
# Lanzar la aplicaci贸n de Gradio
|
|
|
96 |
iface_with_translation.launch()
|
|
|
64 |
translated_recipe = translator(recipe)[0]['translation_text']
|
65 |
return translated_recipe
|
66 |
|
67 |
+
# Paso 4: Crear la interfaz de Gradio con bloques
|
68 |
+
def create_interface():
|
69 |
+
with gr.Blocks() as iface:
|
70 |
+
with gr.Row():
|
71 |
+
image_input = gr.Image(type="pil", label="Upload Dish Image")
|
72 |
+
with gr.Row():
|
73 |
+
description_output = gr.Textbox(label="Dish Description")
|
74 |
+
recipe_output = gr.Textbox(label="Recipe")
|
75 |
+
with gr.Row():
|
76 |
+
translate_button = gr.Button("Translate Recipe to Spanish")
|
77 |
+
translated_output = gr.Textbox(label="Translated Recipe")
|
78 |
|
79 |
+
# Procesar imagen y generar receta
|
80 |
+
def process_and_translate(image):
|
81 |
+
description, recipe = process_image(image)
|
82 |
+
return description, recipe, ""
|
83 |
+
|
84 |
+
image_input.change(fn=process_and_translate, inputs=image_input, outputs=[description_output, recipe_output, translated_output])
|
85 |
|
86 |
+
# Traducir receta
|
87 |
+
def translate_interface(recipe):
|
88 |
+
translated_recipe = translate_recipe(recipe)
|
89 |
+
return translated_recipe
|
90 |
+
|
91 |
+
translate_button.click(fn=translate_interface, inputs=recipe_output, outputs=translated_output)
|
92 |
+
|
93 |
+
return iface
|
|
|
|
|
|
|
|
|
94 |
|
95 |
# Lanzar la aplicaci贸n de Gradio
|
96 |
+
iface_with_translation = create_interface()
|
97 |
iface_with_translation.launch()
|