Spaces:
Sleeping
Sleeping
Edit how pipelines are found
#5
by
hw01558
- opened
app.py
CHANGED
|
@@ -6,10 +6,12 @@ from customFunctions2 import *
|
|
| 6 |
import json
|
| 7 |
import datetime
|
| 8 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
pd.set_option('display.max_colwidth', 1000)
|
| 11 |
|
| 12 |
-
import torch
|
| 13 |
|
| 14 |
# Patch torch.load to always load on CPU
|
| 15 |
original_torch_load = torch.load
|
|
@@ -18,47 +20,51 @@ def cpu_load(*args, **kwargs):
|
|
| 18 |
|
| 19 |
torch.load = cpu_load
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
PIPELINES = [
|
| 23 |
{
|
| 24 |
'id': 1,
|
| 25 |
'name': 'Baseline',
|
| 26 |
-
'pipeline':
|
| 27 |
},
|
| 28 |
{
|
| 29 |
'id': 2,
|
| 30 |
'name': 'Trained on a FeedForward NN',
|
| 31 |
-
'pipeline':
|
| 32 |
},
|
| 33 |
{
|
| 34 |
'id': 3,
|
| 35 |
'name': 'Trained on a CRF',
|
| 36 |
-
'pipeline':
|
| 37 |
},
|
| 38 |
{
|
| 39 |
'id': 4,
|
| 40 |
'name': 'Trained on a small dataset',
|
| 41 |
-
'pipeline':
|
| 42 |
},
|
| 43 |
{
|
| 44 |
'id': 5,
|
| 45 |
'name': 'Trained on a large dataset',
|
| 46 |
-
'pipeline':
|
| 47 |
},
|
| 48 |
{
|
| 49 |
'id': 6,
|
| 50 |
'name': 'Embedded using TFIDF',
|
| 51 |
-
'pipeline':
|
| 52 |
},
|
| 53 |
{
|
| 54 |
'id': 7,
|
| 55 |
'name': 'Embedded using GloVe',
|
| 56 |
-
'pipeline':
|
| 57 |
},
|
| 58 |
{
|
| 59 |
'id': 8,
|
| 60 |
'name': 'Embedded using Bio2Vec',
|
| 61 |
-
|
| 62 |
},
|
| 63 |
|
| 64 |
]
|
|
@@ -131,3 +137,5 @@ def get_data():
|
|
| 131 |
if __name__ == '__main__':
|
| 132 |
app.run(host="0.0.0.0", port=7860)
|
| 133 |
|
|
|
|
|
|
|
|
|
| 6 |
import json
|
| 7 |
import datetime
|
| 8 |
import numpy as np
|
| 9 |
+
from huggingface_hub import hf_hub_download
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
|
| 13 |
pd.set_option('display.max_colwidth', 1000)
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
# Patch torch.load to always load on CPU
|
| 17 |
original_torch_load = torch.load
|
|
|
|
| 20 |
|
| 21 |
torch.load = cpu_load
|
| 22 |
|
| 23 |
+
def load_pipeline_from_hub(filename):
|
| 24 |
+
repo_id = 'hw01558/nlp-coursework-pipelines'
|
| 25 |
+
local_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 26 |
+
return load(local_path)
|
| 27 |
|
| 28 |
PIPELINES = [
|
| 29 |
{
|
| 30 |
'id': 1,
|
| 31 |
'name': 'Baseline',
|
| 32 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex1_s1.joblib")
|
| 33 |
},
|
| 34 |
{
|
| 35 |
'id': 2,
|
| 36 |
'name': 'Trained on a FeedForward NN',
|
| 37 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex1_s2.joblib")
|
| 38 |
},
|
| 39 |
{
|
| 40 |
'id': 3,
|
| 41 |
'name': 'Trained on a CRF',
|
| 42 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex1_s2.joblib")
|
| 43 |
},
|
| 44 |
{
|
| 45 |
'id': 4,
|
| 46 |
'name': 'Trained on a small dataset',
|
| 47 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex2_s3.joblib")
|
| 48 |
},
|
| 49 |
{
|
| 50 |
'id': 5,
|
| 51 |
'name': 'Trained on a large dataset',
|
| 52 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex2_s2.joblib")
|
| 53 |
},
|
| 54 |
{
|
| 55 |
'id': 6,
|
| 56 |
'name': 'Embedded using TFIDF',
|
| 57 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex3_s2.joblib")
|
| 58 |
},
|
| 59 |
{
|
| 60 |
'id': 7,
|
| 61 |
'name': 'Embedded using GloVe',
|
| 62 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex3_s3.joblib")
|
| 63 |
},
|
| 64 |
{
|
| 65 |
'id': 8,
|
| 66 |
'name': 'Embedded using Bio2Vec',
|
| 67 |
+
'pipeline': load_pipeline_from_hub("pipeline_ex3_s4.joblib")
|
| 68 |
},
|
| 69 |
|
| 70 |
]
|
|
|
|
| 137 |
if __name__ == '__main__':
|
| 138 |
app.run(host="0.0.0.0", port=7860)
|
| 139 |
|
| 140 |
+
#if __name__ == '__main__':
|
| 141 |
+
#app.run(host="0.0.0.0", port=7860)
|