Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,30 +44,24 @@ st.markdown("### What two metrics do you want to compare?")
|
|
| 44 |
|
| 45 |
metrics = st.multiselect(
|
| 46 |
'Choose the metrics for the comparison',
|
| 47 |
-
options=['f1', 'accuracy', 'precision', 'recall']
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
st.markdown("### Please wait for the dataset and models to load (this can take some time if they are big!")
|
| 51 |
|
| 52 |
### Loading data
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
st.text("Sorry, I can't load this dataset... try another one!")
|
| 61 |
-
|
| 62 |
### Loading models
|
| 63 |
|
| 64 |
for i in range (len(models)):
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
globals()[f"model_{i}"] = AutoModelForSequenceClassification.from_pretrained(models[i])
|
| 68 |
-
st.text("Loaded model "+ str(models[i]))
|
| 69 |
-
except:
|
| 70 |
-
st.text("Sorry, I can't load model "+ str(models[i]))
|
| 71 |
|
| 72 |
### Defining metrics
|
| 73 |
for i in range (len(metrics)):
|
|
@@ -77,8 +71,9 @@ for i in range (len(metrics)):
|
|
| 77 |
st.text("Sorry, I can't load metric "+ str(metrics[i]) +"... Try another one!")
|
| 78 |
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
### Defining pipelines
|
| 84 |
|
|
@@ -100,7 +95,7 @@ for i in range (len(models)):
|
|
| 100 |
except:
|
| 101 |
st.text("Sorry, I can't load model "+ str(models[i]))
|
| 102 |
|
| 103 |
-
|
| 104 |
res_accuracy1 = eval.compute(model_or_pipeline=pipe1, data=data, metric=accuracy,
|
| 105 |
label_mapping={"NEGATIVE": 0, "POSITIVE": 1},)
|
| 106 |
res_f11 = eval.compute(model_or_pipeline=pipe1, data=data, metric=f1,
|
|
|
|
| 44 |
|
| 45 |
metrics = st.multiselect(
|
| 46 |
'Choose the metrics for the comparison',
|
| 47 |
+
options=['f1', 'accuracy', 'precision', 'recall'],
|
| 48 |
+
default=["f1", "accuracy"])
|
| 49 |
|
| 50 |
|
| 51 |
st.markdown("### Please wait for the dataset and models to load (this can take some time if they are big!")
|
| 52 |
|
| 53 |
### Loading data
|
| 54 |
+
data = datasets.load_dataset(dset, split=dset_split)
|
| 55 |
+
st.text("Loaded the "+ str(dset_split)+ " split of dataset "+ str(dset))
|
| 56 |
+
|
| 57 |
+
### Defining Evaluator
|
| 58 |
+
eval = evaluator("text-classification")
|
| 59 |
+
|
|
|
|
|
|
|
|
|
|
| 60 |
### Loading models
|
| 61 |
|
| 62 |
for i in range (len(models)):
|
| 63 |
+
globals()[f"pipe_{i}"] = pipeline("text-classification", model = models[i], tokenizer = models[i], device=0)
|
| 64 |
+
st.text("Loaded model "+ str(models[i]))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
### Defining metrics
|
| 67 |
for i in range (len(metrics)):
|
|
|
|
| 71 |
st.text("Sorry, I can't load metric "+ str(metrics[i]) +"... Try another one!")
|
| 72 |
|
| 73 |
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
|
| 78 |
### Defining pipelines
|
| 79 |
|
|
|
|
| 95 |
except:
|
| 96 |
st.text("Sorry, I can't load model "+ str(models[i]))
|
| 97 |
|
| 98 |
+
|
| 99 |
res_accuracy1 = eval.compute(model_or_pipeline=pipe1, data=data, metric=accuracy,
|
| 100 |
label_mapping={"NEGATIVE": 0, "POSITIVE": 1},)
|
| 101 |
res_f11 = eval.compute(model_or_pipeline=pipe1, data=data, metric=f1,
|