Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -68,11 +68,15 @@ def predict(sentence1, sentence2):
|
|
68 |
test_data = BertSemanticDataGenerator(
|
69 |
sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
|
70 |
)
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
|
77 |
inputs = [
|
78 |
gr.Audio(source = "upload", label='Upload audio file', type="filepath"),
|
@@ -89,7 +93,8 @@ gr.Interface(
|
|
89 |
description = "Natural Language Inference by fine-tuning BERT model on SNLI Corpus ๐ฐ",
|
90 |
inputs=["text", "text"],
|
91 |
examples=examples,
|
92 |
-
outputs=gr.Textbox(label='Prediction'),
|
|
|
93 |
cache_examples=False,
|
94 |
article = "Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>. Based on the keras example from <a href=\"https://keras.io/examples/nlp/semantic_similarity_with_bert/\">Mohamad Merchant</a>",
|
95 |
).launch(debug=True, enable_queue=True)
|
|
|
68 |
test_data = BertSemanticDataGenerator(
|
69 |
sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
|
70 |
)
|
71 |
+
probsใ= model.predict(test_data[0])[0]
|
72 |
+
|
73 |
+
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
74 |
+
return labels_probs
|
75 |
+
|
76 |
+
#idx = np.argmax(proba)
|
77 |
+
#proba = f"{proba[idx]*100:.2f}%"
|
78 |
+
#pred = labels[idx]
|
79 |
+
#return f'The semantic similarity of two input sentences is {pred} with {proba} of probability'
|
80 |
|
81 |
inputs = [
|
82 |
gr.Audio(source = "upload", label='Upload audio file', type="filepath"),
|
|
|
93 |
description = "Natural Language Inference by fine-tuning BERT model on SNLI Corpus ๐ฐ",
|
94 |
inputs=["text", "text"],
|
95 |
examples=examples,
|
96 |
+
#outputs=gr.Textbox(label='Prediction'),
|
97 |
+
outputs=gr.outputs.Label(num_top_classes=3, label='Semantic similarity score'),
|
98 |
cache_examples=False,
|
99 |
article = "Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>. Based on the keras example from <a href=\"https://keras.io/examples/nlp/semantic_similarity_with_bert/\">Mohamad Merchant</a>",
|
100 |
).launch(debug=True, enable_queue=True)
|