Commit b469586b authored by Jan Rudolf's avatar Jan Rudolf

ADD models to app

parent 4cb8e2e0
......@@ -7,6 +7,8 @@ from werkzeug.utils import redirect, secure_filename
from audio_classification.dnn_simple_classifier.dnn_simple_classifier import DNNSimpleClassifierFactory
from audio_classification.dtwclassifier.dtwclassifier import DTWClassifierFactory
from audio_classification.resnet_classifier.resnet_classifier import ResNetClassifierFactory
from audio_classification.resnet_similarity_knn.nn_similarity import ResNetSimilarityKnnFactory
from audio_classification.run.utils import generate_soundwave
UPLOAD_FOLDER = 'upload'
......@@ -17,6 +19,12 @@ if not os.path.exists(UPLOAD_FOLDER):
os.mkdir(UPLOAD_FOLDER)
simple_dnn_classifier = DNNSimpleClassifierFactory.create()
resnet_classifier = ResNetClassifierFactory.create()
dtw_classifier = DTWClassifierFactory.create()
resnet_similarity_knn = ResNetSimilarityKnnFactory.create()
@app.route('/')
def index():
return send_from_directory('static', 'index.html')
......@@ -49,8 +57,6 @@ def classify():
file.save(filepath)
audio_file, sr = librosa.load(filepath)
mfcc = librosa.feature.mfcc(y=audio_file, sr=sr, n_mfcc=13)
simple_dnn_classifier = DNNSimpleClassifierFactory.create()
dtw_classifier = DTWClassifierFactory.create()
return jsonify({
"classification": [
......@@ -58,6 +64,14 @@ def classify():
'name': 'Simple DNN Classifier',
'genre': simple_dnn_classifier.classify_mfcc(mfcc)
},
{
'name': 'ResNet-18 Classifier',
'genre': resnet_classifier.classify_mfcc(mfcc)
},
{
'name': 'ResNet-18 Embedding + KNN Classifier',
'genre': resnet_similarity_knn.classify_mfcc(mfcc)
},
{
'name': 'DTW classifier',
'genre': dtw_classifier.classify_mfcc(mfcc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment