Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -34,6 +34,7 @@ for lang, model_name in translation_models.items():
|
|
34 |
try:
|
35 |
loaded_translation_models[lang] = MarianMTModel.from_pretrained(model_name)
|
36 |
loaded_translation_tokenizers[lang] = MarianTokenizer.from_pretrained(model_name)
|
|
|
37 |
except Exception as e:
|
38 |
print(f"Error loading model for {lang}: {e}")
|
39 |
|
@@ -64,7 +65,9 @@ def translate_text(text, target_lang="Spanish"):
|
|
64 |
# Combined Captioning and Translation function
|
65 |
def caption_and_translate(image, target_lang="Spanish"):
|
66 |
caption_text = caption(image)
|
|
|
67 |
translated_caption = translate_text(caption_text, target_lang)
|
|
|
68 |
return caption_text, translated_caption
|
69 |
|
70 |
# Create Gradio interfaces
|
@@ -91,3 +94,4 @@ final_interface = gr.TabbedInterface([interface1, interface2, interface3],
|
|
91 |
title=title, theme=gr.themes.Soft())
|
92 |
|
93 |
final_interface.launch(inbrowser=True)
|
|
|
|
34 |
try:
|
35 |
loaded_translation_models[lang] = MarianMTModel.from_pretrained(model_name)
|
36 |
loaded_translation_tokenizers[lang] = MarianTokenizer.from_pretrained(model_name)
|
37 |
+
print(f"Successfully loaded translation model for {lang}")
|
38 |
except Exception as e:
|
39 |
print(f"Error loading model for {lang}: {e}")
|
40 |
|
|
|
65 |
# Combined Captioning and Translation function
|
66 |
def caption_and_translate(image, target_lang="Spanish"):
|
67 |
caption_text = caption(image)
|
68 |
+
print(f"Generated caption: {caption_text}")
|
69 |
translated_caption = translate_text(caption_text, target_lang)
|
70 |
+
print(f"Translated caption: {translated_caption}")
|
71 |
return caption_text, translated_caption
|
72 |
|
73 |
# Create Gradio interfaces
|
|
|
94 |
title=title, theme=gr.themes.Soft())
|
95 |
|
96 |
final_interface.launch(inbrowser=True)
|
97 |
+
|