Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -78,10 +78,10 @@ def summarize_description(full_description, language):
|
|
78 |
return summarization_pipeline(full_description, max_length=150, min_length=50, do_sample=False)[0]['summary_text'] # Summarize in English
|
79 |
|
80 |
# Function to translate the caption and classification result
|
81 |
-
def translate_results(caption, top_label, top_prob, language):
|
82 |
if language == 'ar':
|
83 |
caption_translated = translation_pipeline(caption, src_lang='eng_Latn', tgt_lang='arb_Arab')[0]['translation_text'] # Translate caption to Arabic
|
84 |
-
classification_result = translation_pipeline(f"أفضل مطابقة: {top_label} باحتمالية {top_prob:.4f}", src_lang='eng_Latn', tgt_lang='arb_Arab')[0]['translation_text'] # Translate classification result
|
85 |
else:
|
86 |
caption_translated = caption # Keep caption in English
|
87 |
classification_result = f"Best match: {top_label} with probability {top_prob:.4f}" # Create English classification result
|
@@ -105,7 +105,7 @@ def process_image(image, language='en'):
|
|
105 |
summarized_description = summarize_description(full_description, language) # Call the summarization function
|
106 |
|
107 |
# Translate caption and classification result
|
108 |
-
caption_translated, classification_result = translate_results(caption, top_label, top_prob, language) # Call the translation function
|
109 |
|
110 |
# Convert the summarized description to speech
|
111 |
audio_file = text_to_speech(summarized_description, language) # Convert summary to audio
|
@@ -160,7 +160,7 @@ arabic_interface = gr.Interface(
|
|
160 |
# Merge all interfaces into a tabbed interface
|
161 |
demo = gr.TabbedInterface(
|
162 |
[english_interface, arabic_interface], # List of interfaces to include
|
163 |
-
["English
|
164 |
)
|
165 |
|
166 |
# Launch the interface
|
|
|
78 |
return summarization_pipeline(full_description, max_length=150, min_length=50, do_sample=False)[0]['summary_text'] # Summarize in English
|
79 |
|
80 |
# Function to translate the caption and classification result
|
81 |
+
def translate_results(caption, top_label, top_prob, landmarks_dict, language):
|
82 |
if language == 'ar':
|
83 |
caption_translated = translation_pipeline(caption, src_lang='eng_Latn', tgt_lang='arb_Arab')[0]['translation_text'] # Translate caption to Arabic
|
84 |
+
classification_result = translation_pipeline(f"أفضل مطابقة: {landmarks_dict[top_label]} باحتمالية {top_prob:.4f}", src_lang='eng_Latn', tgt_lang='arb_Arab')[0]['translation_text'] # Translate classification result
|
85 |
else:
|
86 |
caption_translated = caption # Keep caption in English
|
87 |
classification_result = f"Best match: {top_label} with probability {top_prob:.4f}" # Create English classification result
|
|
|
105 |
summarized_description = summarize_description(full_description, language) # Call the summarization function
|
106 |
|
107 |
# Translate caption and classification result
|
108 |
+
caption_translated, classification_result = translate_results(caption, top_label, top_prob, landmarks_dict, language) # Call the translation function
|
109 |
|
110 |
# Convert the summarized description to speech
|
111 |
audio_file = text_to_speech(summarized_description, language) # Convert summary to audio
|
|
|
160 |
# Merge all interfaces into a tabbed interface
|
161 |
demo = gr.TabbedInterface(
|
162 |
[english_interface, arabic_interface], # List of interfaces to include
|
163 |
+
["English", "العربية"] # Names of the tabs
|
164 |
)
|
165 |
|
166 |
# Launch the interface
|