-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
52 lines (35 loc) · 1.28 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
51
52
from tkinter import Image
from flask import Flask, render_template, request
from keras.models import load_model
from keras.preprocessing import image
import tensorflow as tf
import numpy as np
app = Flask(__name__)
model = load_model('model.h5')
@app.route("/")
def uploadpic():
return render_template('index.html',query2="")
@app.route("/", methods=['POST'])
def predict():
query2 = request.form['shoes']
shoename=request.form['Randomname']
findshoe_url = query2
findss_path = tf.keras.utils.get_file(shoename, origin=findshoe_url)
img = tf.keras.utils.load_img(findss_path, target_size=(224,224))
img_array = tf.keras.utils.img_to_array(img)
img_array = tf.expand_dims(img_array, 0) # Create a batch
predictions = model.predict(img_array)
score = tf.nn.softmax(predictions[0])
final_score=round(100 * np.max(score))
classname=[np.argmax(score)]
if classname==[0]:
Brand="Adidas"
elif classname==[1]:
Brand="Balenciaga"
elif classname==[2]:
Brand="Nike"
elif classname==[3]:
Brand="Puma"
return render_template('index.html', output1=Brand, output2=final_score)
if __name__ == "__main__":
app.run(debug=True)