Spaces:
Build error
Build error
Commit
·
1e7b155
1
Parent(s):
521bb9b
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def pool_span_scores(score_dicts, sent_lens):
|
|
27 |
r = [[TAGS[ps] for ps in sent_ps] for sent_ps in pooled_scores]
|
28 |
return r
|
29 |
|
30 |
-
def predict_label(text
|
31 |
# model_path = 'models/span.model'
|
32 |
ip = text.split()
|
33 |
ip_len = [len(ip)]
|
@@ -44,19 +44,19 @@ def temp(text):
|
|
44 |
print('STARTING ..')
|
45 |
|
46 |
|
47 |
-
|
48 |
-
space_key = os.environ.get('key')
|
49 |
-
filenames = ['network.py', 'layers.py', 'utils.py', 'representation.py']
|
50 |
-
for file in filenames:
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
from src.network import SpanNet
|
57 |
-
|
58 |
-
model_path = 'models/span.model'
|
59 |
-
model = SpanNet.load_model(model_path)
|
60 |
-
|
61 |
-
iface = gr.Interface(fn=predict_label, inputs="text", outputs="text")
|
62 |
-
iface.launch(show_api=False)
|
|
|
27 |
r = [[TAGS[ps] for ps in sent_ps] for sent_ps in pooled_scores]
|
28 |
return r
|
29 |
|
30 |
+
def predict_label(text):
|
31 |
# model_path = 'models/span.model'
|
32 |
ip = text.split()
|
33 |
ip_len = [len(ip)]
|
|
|
44 |
print('STARTING ..')
|
45 |
|
46 |
|
47 |
+
if __name__ == '__main__':
|
48 |
+
space_key = os.environ.get('key')
|
49 |
+
filenames = ['network.py', 'layers.py', 'utils.py', 'representation.py']
|
50 |
+
for file in filenames:
|
51 |
+
hf_hub_download('nehalelkaref/stagedNER',
|
52 |
+
filename=file,
|
53 |
+
local_dir='src',
|
54 |
+
token=space_key)
|
55 |
+
|
56 |
+
from src.network import SpanNet
|
57 |
+
|
58 |
+
model_path = 'models/span.model'
|
59 |
+
model = SpanNet.load_model(model_path)
|
60 |
+
|
61 |
+
iface = gr.Interface(fn=predict_label, inputs="text", outputs="text")
|
62 |
+
iface.launch(show_api=False)
|