forked from rohitvy/Fooodify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFood_app.py
36 lines (29 loc) · 806 Bytes
/
Food_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
from flask import *
import os
from werkzeug.utils import secure_filename
import label_image
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
def load_image(image):
text = label_image.main(image)
return text
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def upload():
if request.method == 'POST':
# Get the file from post request
f = request.files['file']
file_path = secure_filename(f.filename)
f.save(file_path)
# Make prediction
result = load_image(file_path)
result = result.title()
print(result)
os.remove(file_path)
return result
return None
if __name__ == '__main__':
app.run()