-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (36 loc) · 1.19 KB
/
app.py
File metadata and controls
45 lines (36 loc) · 1.19 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
from flask import Flask, render_template, request
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np
import tensorflow as tf
from keras.preprocessing import image
from keras.models import load_model
app = Flask(__name__)
page=["hibiscus","neem","tulsi"]
model=load_model("model/leafClassifier_v3.h5")
graph = tf.get_default_graph()
@app.route('/')
def entry_point():
return render_template('home.html')
@app.route('/uploader', methods = ['POST'])
def upload_file():
if request.method == 'POST':
print("debug 0")
im = image.load_img(request.files['file'], target_size=(215, 215))
img = image.img_to_array(im)
img = np.expand_dims(img, axis = 0)
#print(test)
with graph.as_default():
result = model.predict(img)
return page[result.argmax()] #render_template("plants/"+page[result.argmax()])
@app.route('/neem')
def neem_page():
return render_template('plants/neem.html')
@app.route('/hibiscus')
def hibiscus_page():
return render_template('plants/hibiscus.html')
@app.route('/tulsi')
def tulsi_page():
return render_template('plants/tulsi.html')
if __name__ == '__main__':
app.run(debug = True)#debug = True)