sasha HF staff commited on
Commit
0b7786c
1 Parent(s): 3c0d40a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
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
- try:
54
- data = datasets.load_dataset(dset, split=dset_split)
55
- st.text("Loaded the validation split of dataset "+ str(dset))
56
- except:
57
- data = datasets.load_dataset(dset, split="test")
58
- st.text("Loaded the test split of dataset "+ str(dset))
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
- try:
66
- globals()[f"tokenizer_{i}"] = AutoTokenizer.from_pretrained(models[i])
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
- ### Defining Evaluator
81
- eval = evaluator("text-classification")
 
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
- pipe1 = pipeline("text-classification", model=model1, tokenizer= tokenizer1, device=0)
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,