Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,54 @@
|
|
1 |
import transformers
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
pipe = pipeline(model="mskov/whisper_esc50")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
fn=transcribe,
|
13 |
-
inputs=gr.Audio(source="microphone", type="filepath"),
|
14 |
-
outputs="text",
|
15 |
-
title="Model Testing",
|
16 |
-
description="Testing model import.",
|
17 |
-
)
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import transformers
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
+
import pandas
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
from sklearn import model_selection
|
7 |
+
from sklearn.linear_model import LogisticRegression
|
8 |
+
from sklearn.tree import DecisionTreeClassifier
|
9 |
+
from sklearn.neighbors import KNeighborsClassifier
|
10 |
+
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
|
11 |
+
from sklearn.naive_bayes import GaussianNB
|
12 |
+
from sklearn.svm import SVC
|
13 |
|
|
|
14 |
|
15 |
+
whisper_esc50 = pipeline(model="mskov/whisper_esc50")
|
16 |
+
whisper_miso= pipeline(model="mskov/whisper_miso")
|
17 |
+
whisper_tiny = whisper.load_model("tiny")
|
18 |
+
whisper_base = whisper.load_model("base")
|
19 |
|
20 |
+
dataset = load_dataset("mskov/miso_test")
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
names = ['path', 'file_name', 'category']
|
23 |
+
dataframe = pandas.read_csv(url, names=names)
|
24 |
+
array = dataframe.values
|
25 |
+
X = array[:,0:2]
|
26 |
+
Y = array[:,2]
|
27 |
+
# prepare configuration for cross validation test harness
|
28 |
+
seed = 7
|
29 |
+
# prepare models
|
30 |
+
models = [whisper_esc50, whisper_miso, whisper_tiny, whisper_base]
|
31 |
+
models.append(('LR', LogisticRegression()))
|
32 |
+
models.append(('LDA', LinearDiscriminantAnalysis()))
|
33 |
+
models.append(('KNN', KNeighborsClassifier()))
|
34 |
+
models.append(('CART', DecisionTreeClassifier()))
|
35 |
+
models.append(('NB', GaussianNB()))
|
36 |
+
models.append(('SVM', SVC()))
|
37 |
+
# evaluate each model in turn
|
38 |
+
results = []
|
39 |
+
names = []
|
40 |
+
scoring = 'accuracy'
|
41 |
+
for name, model in models:
|
42 |
+
kfold = model_selection.KFold(n_splits=10, random_state=seed)
|
43 |
+
cv_results = model_selection.cross_val_score(model, X, Y, cv=kfold, scoring=scoring)
|
44 |
+
results.append(cv_results)
|
45 |
+
names.append(name)
|
46 |
+
msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std())
|
47 |
+
print(msg)
|
48 |
+
# boxplot algorithm comparison
|
49 |
+
fig = plt.figure()
|
50 |
+
fig.suptitle('Algorithm Comparison')
|
51 |
+
ax = fig.add_subplot(111)
|
52 |
+
plt.boxplot(results)
|
53 |
+
ax.set_xticklabels(names)
|
54 |
+
plt.show()
|