innocent-charles commited on
Commit
68721f5
1 Parent(s): bdd5c64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -39,27 +39,25 @@ 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
  # 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)
 
39
  gr.Textbox(lines=2, placeholder="Enter the sentence you want to compare...", label="Sentence to Compare 3")
40
  ]
41
 
42
+ num_sentences_input = gr.Slider(minimum=1, maximum=10, step=1, value=3, label="Number of Sentences to Compare")
43
+
44
  # Function to dynamically update the interface
45
  def update_interface(num_sentences):
46
  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)]
47
 
48
+ def create_interface():
49
+ inputs_dynamic = [model_name_display, original_sentence_input, num_sentences_input]
50
+ inputs_dynamic += update_interface(3)
 
 
 
 
 
51
  return gr.Interface(
52
  fn=predict,
53
  title="African Cross-Lingua Embeddings Model's Demo",
54
  description="Compute the semantic similarity across various sentences among any African Languages using African-Cross-Lingua-Embeddings-Model.",
55
  inputs=inputs_dynamic,
56
  outputs=outputs,
57
+ live=False,
58
+ allow_flagging="never"
59
  )
60
 
61
+ # Create and launch the initial interface
62
+ interface = create_interface()
63
  interface.launch(debug=True, share=True)