-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·57 lines (38 loc) · 1.31 KB
/
app.py
File metadata and controls
executable file
·57 lines (38 loc) · 1.31 KB
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
51
52
53
54
55
import os
import shutil
from flask import Flask, render_template, request
from main import *
UPLOAD_FOLDER = "static/images"
for the_file in os.listdir(UPLOAD_FOLDER):
file_path = os.path.join(UPLOAD_FOLDER, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as e:
print(e)
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route('/', methods=['GET', 'POST'])
def hello():
if request.method == 'GET':
return render_template('index.html')
if request.method == 'POST':
file = request.files['file']
f = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
file.save(f)
name = file.filename
image = UPLOAD_FOLDER + '/' + name
found, flag = breed(path = image)
if flag == 0:
info = wiki(found)
top = 'More about ' + found
else:
info = ''
top = 'NO DOG FOUND | UPLOAD A DOG IMAGE.'
if device == 'cpu':
chip = 'CPU'
else:
chip = 'GPU | available'
return render_template('result.html',breed_name=found, info= info, device= chip, image_name = name, head = top)
if __name__ == '__main__':
app.run(debug =True)