-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (35 loc) · 1009 Bytes
/
app.py
File metadata and controls
46 lines (35 loc) · 1009 Bytes
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
import os
import FruitClassifier
import FruitClassifierTraining
from flask import Flask, render_template
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app)
app.config['TEST_FOLDER'] = os.path.join(os.path.join('static/', 'fruit/'), 'test')
@app.route('/train-model')
@cross_origin()
def train_model():
model, history = FruitClassifierTraining.train_model(4)
return {
"model": model,
"history": history
}
@app.route('/fruit-classifier')
@cross_origin()
def show_images():
classification, path, features = FruitClassifier.next_image()
full_filename = os.path.join('fruit/', path)
return {
"imageURL": full_filename,
"classification": classification,
"features": features
}
@app.route('/get-file-names')
@cross_origin()
def get_file_names():
file_names = FruitClassifier.get_file_names()
return {
"fileNames": file_names
}
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)