Spaces:
Sleeping
Sleeping
Dynamic loading (#8)
Browse files- Dynamic loading (91fb880bb0580b4b29a2bf626bbc304a6868e7b5)
Co-authored-by: H Wilks <[email protected]>
app.py
CHANGED
@@ -36,42 +36,42 @@ PIPELINES = [
|
|
36 |
{
|
37 |
'id': 1,
|
38 |
'name': 'Baseline',
|
39 |
-
'
|
40 |
},
|
41 |
{
|
42 |
'id': 2,
|
43 |
'name': 'Trained on a FeedForward NN',
|
44 |
-
'
|
45 |
},
|
46 |
{
|
47 |
'id': 3,
|
48 |
'name': 'Trained on a CRF',
|
49 |
-
'
|
50 |
},
|
51 |
{
|
52 |
'id': 4,
|
53 |
'name': 'Trained on a small dataset',
|
54 |
-
'
|
55 |
-
},
|
56 |
{
|
57 |
'id': 5,
|
58 |
'name': 'Trained on a large dataset',
|
59 |
-
'
|
60 |
},
|
61 |
{
|
62 |
'id': 6,
|
63 |
'name': 'Embedded using TFIDF',
|
64 |
-
'
|
65 |
},
|
66 |
{
|
67 |
'id': 7,
|
68 |
'name': 'Embedded using GloVe',
|
69 |
-
'
|
70 |
},
|
71 |
{
|
72 |
'id': 8,
|
73 |
'name': 'Embedded using Bio2Vec',
|
74 |
-
'
|
75 |
},
|
76 |
|
77 |
]
|
@@ -79,7 +79,7 @@ PIPELINES = [
|
|
79 |
pipeline_metadata = [{'id': p['id'], 'name': p['name']} for p in PIPELINES]
|
80 |
|
81 |
def get_pipeline_by_id(pipelines, pipeline_id):
|
82 |
-
return next((p['
|
83 |
|
84 |
def get_name_by_id(pipelines, pipeline_id):
|
85 |
return next((p['name'] for p in pipelines if p['id'] == pipeline_id), None)
|
@@ -130,7 +130,7 @@ def get_data():
|
|
130 |
tokens_fomatted = pd.Series([pd.Series(tokens)])
|
131 |
|
132 |
pipeline_id = int(request.form['pipeline_select'])
|
133 |
-
pipeline = get_pipeline_by_id(PIPELINES, pipeline_id)
|
134 |
name = get_name_by_id(PIPELINES, pipeline_id)
|
135 |
|
136 |
labels = requestResults(tokens_fomatted, pipeline)
|
|
|
36 |
{
|
37 |
'id': 1,
|
38 |
'name': 'Baseline',
|
39 |
+
'filename': "pipeline_ex1_s1.joblib"
|
40 |
},
|
41 |
{
|
42 |
'id': 2,
|
43 |
'name': 'Trained on a FeedForward NN',
|
44 |
+
'filename': "pipeline_ex1_s2.joblib"
|
45 |
},
|
46 |
{
|
47 |
'id': 3,
|
48 |
'name': 'Trained on a CRF',
|
49 |
+
'filename': "pipeline_ex1_s2.joblib"
|
50 |
},
|
51 |
{
|
52 |
'id': 4,
|
53 |
'name': 'Trained on a small dataset',
|
54 |
+
'filename': "pipeline_ex2_s3.joblib"
|
55 |
+
v },
|
56 |
{
|
57 |
'id': 5,
|
58 |
'name': 'Trained on a large dataset',
|
59 |
+
'filename': "pipeline_ex2_s2.joblib"
|
60 |
},
|
61 |
{
|
62 |
'id': 6,
|
63 |
'name': 'Embedded using TFIDF',
|
64 |
+
'filename': "pipeline_ex3_s2.joblib"
|
65 |
},
|
66 |
{
|
67 |
'id': 7,
|
68 |
'name': 'Embedded using GloVe',
|
69 |
+
'filename': "pipeline_ex3_s3.joblib"
|
70 |
},
|
71 |
{
|
72 |
'id': 8,
|
73 |
'name': 'Embedded using Bio2Vec',
|
74 |
+
'filename': "pipeline_ex3_s4.joblib"
|
75 |
},
|
76 |
|
77 |
]
|
|
|
79 |
pipeline_metadata = [{'id': p['id'], 'name': p['name']} for p in PIPELINES]
|
80 |
|
81 |
def get_pipeline_by_id(pipelines, pipeline_id):
|
82 |
+
return next((p['filename'] for p in pipelines if p['id'] == pipeline_id), None)
|
83 |
|
84 |
def get_name_by_id(pipelines, pipeline_id):
|
85 |
return next((p['name'] for p in pipelines if p['id'] == pipeline_id), None)
|
|
|
130 |
tokens_fomatted = pd.Series([pd.Series(tokens)])
|
131 |
|
132 |
pipeline_id = int(request.form['pipeline_select'])
|
133 |
+
pipeline = load_pipeline_from_hub(get_pipeline_by_id(PIPELINES, pipeline_id))
|
134 |
name = get_name_by_id(PIPELINES, pipeline_id)
|
135 |
|
136 |
labels = requestResults(tokens_fomatted, pipeline)
|