Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from transformers import pipeline
|
|
| 5 |
from joblib import load
|
| 6 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 7 |
import torch.nn.functional as F
|
| 8 |
-
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
|
| 11 |
# global variables to load models
|
|
@@ -44,7 +44,7 @@ def plot():
|
|
| 44 |
cm = confusion_matrix(actual, pred)
|
| 45 |
disp = ConfusionMatrixDisplay(confusion_matrix=cm)
|
| 46 |
disp.plot()
|
| 47 |
-
return plt.gcf()
|
| 48 |
|
| 49 |
|
| 50 |
demo = gr.Blocks()
|
|
@@ -87,7 +87,7 @@ with demo:
|
|
| 87 |
interface = gr.Interface(
|
| 88 |
plot,
|
| 89 |
[],
|
| 90 |
-
"plot"
|
| 91 |
)
|
| 92 |
|
| 93 |
demo.launch()
|
|
|
|
| 5 |
from joblib import load
|
| 6 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 7 |
import torch.nn.functional as F
|
| 8 |
+
from sklearn.metrics import accuracy_score, confusion_matrix, ConfusionMatrixDisplay
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
|
| 11 |
# global variables to load models
|
|
|
|
| 44 |
cm = confusion_matrix(actual, pred)
|
| 45 |
disp = ConfusionMatrixDisplay(confusion_matrix=cm)
|
| 46 |
disp.plot()
|
| 47 |
+
return (plt.gcf(), f"Accuracy: {accuracy_score(actual, pred)}")
|
| 48 |
|
| 49 |
|
| 50 |
demo = gr.Blocks()
|
|
|
|
| 87 |
interface = gr.Interface(
|
| 88 |
plot,
|
| 89 |
[],
|
| 90 |
+
["plot", "text"]
|
| 91 |
)
|
| 92 |
|
| 93 |
demo.launch()
|