li
commited on
Commit
·
c8080dc
1
Parent(s):
58dc09d
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
gr.Interface.load("models/
|
5 |
-
|
6 |
-
def predict(sentence1, sentence2):
|
7 |
-
sentence_pairs = np.array([[str(sentence1), str(sentence2)]])
|
8 |
-
test_data = BertSemanticDataGenerator(
|
9 |
-
sentence_pairs, labels=None, batch_size=1, shuffle=False, include_targets=False,
|
10 |
-
)
|
11 |
-
probs = model.predict(test_data[0])[0]
|
12 |
-
|
13 |
-
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
14 |
-
return labels_probs
|
15 |
-
|
16 |
-
examples = [["Two women are observing something together.", "Two women are standing with their eyes closed."],
|
17 |
-
["A smiling costumed woman is holding an umbrella", "A happy woman in a fairy costume holds an umbrella"],
|
18 |
-
["A soccer game with multiple males playing", "Some men are playing a sport"],
|
19 |
-
]
|
20 |
-
|
21 |
-
gr.Interface(
|
22 |
-
fn=predict,
|
23 |
-
title="basic with GPT",
|
24 |
-
description = "Natural Language Inference by fine-tuning GPT model",
|
25 |
-
inputs=["text", "text"],
|
26 |
-
examples=examples,
|
27 |
-
#outputs=gr.Textbox(label='Prediction'),
|
28 |
-
outputs=gr.outputs.Label(num_top_classes=3, label='Semantic similarity'),
|
29 |
-
cache_examples=True
|
30 |
-
).launch(debug=True, enable_queue=True)
|
31 |
-
|
32 |
-
# gr.Interface.load("models/openai-gpt").launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
description = "GPT 牛逼"
|
3 |
+
examples = [["I am king."]]
|
4 |
+
demo = gr.Interface.load("models/bert-base-uncased", description=description, examples=examples)
|
5 |
+
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|