Spaces:
Build error
Build error
Commit
·
420f35b
1
Parent(s):
9b91aa6
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)]
|
@@ -42,8 +42,8 @@ def temp(text):
|
|
42 |
print('IN FUNCTION')
|
43 |
return text
|
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']
|
@@ -54,8 +54,10 @@ if __name__ == '__main__':
|
|
54 |
token=space_key)
|
55 |
|
56 |
from src.network import SpanNet
|
|
|
|
|
57 |
# iface = gr.Interface(fn=temp, inputs="text", outputs="text", batch=False)
|
58 |
-
iface = gr.Interface(fn=predict_label, inputs="text", outputs="text"
|
59 |
iface.launch(share=True, blocked_paths=['models'])
|
60 |
iface.launch(show_api=False)
|
61 |
|
|
|
27 |
r = [[TAGS[ps] for ps in sent_ps] for sent_ps in pooled_scores]
|
28 |
return r
|
29 |
|
30 |
+
def predict_label(text, model=model):
|
31 |
model_path = 'models/span.model'
|
32 |
ip = text.split()
|
33 |
ip_len = [len(ip)]
|
|
|
42 |
print('IN FUNCTION')
|
43 |
return text
|
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']
|
|
|
54 |
token=space_key)
|
55 |
|
56 |
from src.network import SpanNet
|
57 |
+
model_path = 'models/span.model'
|
58 |
+
model = SpanNet.load_model(model_path)
|
59 |
# iface = gr.Interface(fn=temp, inputs="text", outputs="text", batch=False)
|
60 |
+
iface = gr.Interface(fn=predict_label, inputs="text", outputs="text")
|
61 |
iface.launch(share=True, blocked_paths=['models'])
|
62 |
iface.launch(show_api=False)
|
63 |
|