innocent-charles
commited on
Commit
•
bdd5c64
1
Parent(s):
c92b6f6
Update app.py
Browse files
app.py
CHANGED
@@ -39,20 +39,27 @@ sentence_to_compare_inputs = [
|
|
39 |
gr.Textbox(lines=2, placeholder="Enter the sentence you want to compare...", label="Sentence to Compare 3")
|
40 |
]
|
41 |
|
|
|
42 |
def update_interface(num_sentences):
|
43 |
-
return [gr.Textbox(lines=2, placeholder="Enter the sentence you want to compare...", label=f"Sentence to Compare {i}") for i in range(1, num_sentences+1)]
|
44 |
|
45 |
-
num_sentences_input = gr.Slider(minimum=1, maximum=10, step=1,
|
46 |
|
47 |
inputs = [model_name_display, original_sentence_input, num_sentences_input] + sentence_to_compare_inputs
|
48 |
outputs = gr.JSON(label="Detailed Similarity Scores")
|
49 |
|
50 |
# Create Gradio interface
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
gr.Textbox(lines=2, placeholder="Enter the sentence you want to compare...", label="Sentence to Compare 3")
|
40 |
]
|
41 |
|
42 |
+
# Function to dynamically update the interface
|
43 |
def update_interface(num_sentences):
|
44 |
+
return [gr.Textbox(lines=2, placeholder="Enter the sentence you want to compare...", label=f"Sentence to Compare {i}") for i in range(1, num_sentences + 1)]
|
45 |
|
46 |
+
num_sentences_input = gr.Slider(minimum=1, maximum=10, step=1, value=3, label="Number of Sentences to Compare")
|
47 |
|
48 |
inputs = [model_name_display, original_sentence_input, num_sentences_input] + sentence_to_compare_inputs
|
49 |
outputs = gr.JSON(label="Detailed Similarity Scores")
|
50 |
|
51 |
# Create Gradio interface
|
52 |
+
def dynamic_interface(num_sentences):
|
53 |
+
inputs_dynamic = [model_name_display, original_sentence_input, num_sentences_input] + update_interface(num_sentences)
|
54 |
+
return gr.Interface(
|
55 |
+
fn=predict,
|
56 |
+
title="African Cross-Lingua Embeddings Model's Demo",
|
57 |
+
description="Compute the semantic similarity across various sentences among any African Languages using African-Cross-Lingua-Embeddings-Model.",
|
58 |
+
inputs=inputs_dynamic,
|
59 |
+
outputs=outputs,
|
60 |
+
live=True
|
61 |
+
)
|
62 |
+
|
63 |
+
# Launch the interface with dynamic updates
|
64 |
+
interface = dynamic_interface(3)
|
65 |
+
interface.launch(debug=True, share=True)
|