Spaces:
Build error
Build error
Commit
·
44e2bdb
1
Parent(s):
baa1966
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,10 @@ from huggingface_hub import Repository
|
|
5 |
def greet(name):
|
6 |
return "Hello " + name + "!!"
|
7 |
|
8 |
-
def extract_spannet_scores(path,input_sentence, pos_col, task_col):
|
9 |
|
10 |
-
sent = input_sentence.split()
|
11 |
-
length = [len(sent)]
|
12 |
|
13 |
all_scores = []
|
14 |
|
@@ -31,10 +31,13 @@ def pool_span_scores(score_dicts, sent_lens):
|
|
31 |
r = [[TAGS[ps] for ps in sent_ps]for sent_ps in pooled_scores]
|
32 |
return r
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
iface = gr.Interface(fn=greet, inputs=input_text, outputs="text")
|
37 |
-
iface.
|
38 |
-
model_path = 'models/span_model'
|
39 |
-
scores = extract_spannet_scores(model_path,input_text, pos_col=1, task_col=2)
|
40 |
-
iface.launch()
|
|
|
5 |
def greet(name):
|
6 |
return "Hello " + name + "!!"
|
7 |
|
8 |
+
def extract_spannet_scores(path,input_sentence,length, pos_col, task_col):
|
9 |
|
10 |
+
# sent = input_sentence.split()
|
11 |
+
# length = [len(sent)]
|
12 |
|
13 |
all_scores = []
|
14 |
|
|
|
31 |
r = [[TAGS[ps] for ps in sent_ps]for sent_ps in pooled_scores]
|
32 |
return r
|
33 |
|
34 |
+
def predict_label(text):
|
35 |
+
model_path = 'models/span_model'
|
36 |
+
ip = input_text.split()
|
37 |
+
ip_len = [length(ip)]
|
38 |
+
scores = extract_spannet_scores(model_path,ip,ip_len, pos_col=1, task_col=2)
|
39 |
+
pooled_scores = pool_span_scores(scores, ip_len)
|
40 |
+
return pooled_scores
|
41 |
+
|
42 |
+
iface = gr.Interface(fn=predict_label, inputs="text", outputs="text")
|
43 |
|
|
|
|
|
|
|
|
|
|