-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
50 lines (43 loc) · 1.58 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import Flask, render_template, url_for, request, redirect
from flask_bootstrap import Bootstrap
import os
# import model_test
import model
import you_dl
import soundfile as sf
app = Flask(__name__, template_folder='Template')
Bootstrap(app)
"""
Routes
"""
@app.route('/', methods=['GET','POST'])
def index():
if request.method == 'POST':
uploaded_file = request.files['file']
url = request.form['url_text']
url = url.strip()
if uploaded_file.filename != '':
av_path = os.path.join('static', uploaded_file.filename)
image_name = uploaded_file.filename.split('.')[0]
image_path = os.path.join('static', image_name + '.png')
uploaded_file.save(av_path)
pred = model.get_prediction(av_path,image_path)
result = {
'class_name': pred,
'image_path': image_path,
}
return render_template('result.html', result = result)
elif url != '':
av_path, title = you_dl.dwl_vid(url)
# image_name = title.split('.')[0]
# image_path = os.path.join('static', image_name + '.png')
image_path = "static/out_graph.png"
pred = model.get_prediction(av_path,image_path)
result = {
'class_name': pred,
'image_path': image_path,
}
return render_template('result.html', result = result)
return render_template('index.html')
if __name__ == '__main__':
app.run(debug = True)