Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -74,6 +74,7 @@ def load_models(mod_names):
|
|
74 |
continue
|
75 |
return(model_list)
|
76 |
|
|
|
77 |
@st.cache
|
78 |
def load_pipes(mod_list):
|
79 |
pipe_list=[]
|
@@ -87,31 +88,19 @@ load_pipes(load_models(models))
|
|
87 |
### Defining metrics
|
88 |
for i in range (len(metrics)):
|
89 |
globals()[f"metrics[i]"] = evaluate.load(metrics[i])
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
### Defining pipelines
|
95 |
|
96 |
st.markdown("### Help us pick the right labels for your models")
|
97 |
|
98 |
st.text("The labels for your dataset are: "+ str(data.features['label'].names))
|
99 |
|
100 |
-
_ = """
|
101 |
-
for i in range (len(model_list)):
|
102 |
-
st.text("The labels for your dataset are: "+ str(data.features['label'].names))
|
103 |
-
print(model_list[i])
|
104 |
-
print(AutoConfig.from_pretrained(models[0]).id2label)
|
105 |
|
106 |
-
for i in range (len(
|
107 |
-
|
108 |
-
globals()[f"pipe1_{i}"] = AutoTokenizer.from_pretrained(models[i])
|
109 |
-
globals()[f"model_{i}"] = AutoModelForSequenceClassification.from_pretrained(models[i])
|
110 |
-
st.text("Loaded model "+ str(models[i]))
|
111 |
-
except:
|
112 |
-
st.text("Sorry, I can't load model "+ str(models[i]))
|
113 |
|
114 |
|
|
|
115 |
res_accuracy1 = eval.compute(model_or_pipeline=pipe1, data=data, metric=accuracy,
|
116 |
label_mapping={"NEGATIVE": 0, "POSITIVE": 1},)
|
117 |
res_f11 = eval.compute(model_or_pipeline=pipe1, data=data, metric=f1,
|
|
|
74 |
continue
|
75 |
return(model_list)
|
76 |
|
77 |
+
### Defining pipelines
|
78 |
@st.cache
|
79 |
def load_pipes(mod_list):
|
80 |
pipe_list=[]
|
|
|
88 |
### Defining metrics
|
89 |
for i in range (len(metrics)):
|
90 |
globals()[f"metrics[i]"] = evaluate.load(metrics[i])
|
91 |
+
|
92 |
+
## Label mapping
|
|
|
|
|
|
|
93 |
|
94 |
st.markdown("### Help us pick the right labels for your models")
|
95 |
|
96 |
st.text("The labels for your dataset are: "+ str(data.features['label'].names))
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
+
for i in range (len(model_list)):
|
100 |
+
st.text("The labels for " + str(model_list[i]) + "are: "+ str(AutoConfig.from_pretrained(model_list[i]).id2label))
|
|
|
|
|
|
|
|
|
|
|
101 |
|
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,
|