Skip to content

prography/6th-lemorning-deep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

폴더 구조

/deeplearning: 딥러닝 모델
/flask: flask 연습
/flask-server: flask, deeplearning 구현 (rending page)

레모닝 딥러닝 API

block diagram

code

flask/app.py


from flask import Flask, redirect, render_template, request, url_for, flash
import os

app = Flask(__name__)

UPLOAD_FOLDER = './uploads/audio'
ALLOWED_EXTENSIONS = set(['m4a', 'm4p', 'wav', 'mp3', 'mp4'])
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER


@app.route("/")
def index():
    return '''
    <h1>Deep Learning rending page</h1>
        <p>음악파일을 업로드 하면 딥러닝모델(musicnn)을 이용하여 어떤 종류의 음악인지 분류해 줍니다.</p>
        <a href='/tag'>Click Here!!!</a>
    '''


def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS


@app.route('/tag', methods=['GET', 'POST'])
def tag():
    if request.method == 'POST':
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = file.filename
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            #딥러닝 로직
            from deep.model import DeepModel
            model = DeepModel()
            path = UPLOAD_FOLDER +'/' +filename
            feats, tags = model.extract_info(path, mode='both', topN=5)
            return render_template('deeplearning.html', filename=filename, tags=tags)
        else:
            return '<h1>Error</h1>'

    return render_template('tag.html')

Result

  1. 음악 파일을 upload한다.

  1. 관련 Tag를 반환한다.

About

6기 레모닝 딥러닝

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published