li commited on
Commit
644062f
·
1 Parent(s): 52c562e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -1,5 +1,15 @@
1
  import gradio as gr
2
 
 
 
 
 
 
 
 
 
 
 
3
  examples = [["Two women are observing something together.", "Two women are standing with their eyes closed."],
4
  ["A smiling costumed woman is holding an umbrella", "A happy woman in a fairy costume holds an umbrella"],
5
  ["A soccer game with multiple males playing", "Some men are playing a sport"],
 
1
  import gradio as gr
2
 
3
+ def predict(sentence1, sentence2):
4
+ sentence_pairs = np.array([[str(sentence1), str(sentence2)]])
5
+ test_data = BertSemanticDataGenerator(
6
+ sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
7
+ )
8
+ probs = model.predict(test_data[0])[0]
9
+
10
+ labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
11
+ return labels_probs
12
+
13
  examples = [["Two women are observing something together.", "Two women are standing with their eyes closed."],
14
  ["A smiling costumed woman is holding an umbrella", "A happy woman in a fairy costume holds an umbrella"],
15
  ["A soccer game with multiple males playing", "Some men are playing a sport"],