├── README.md ├── Web-Based Image Classification project report (1).docx ├── API-Using-Flask.py ├── python └── w.html /README.md: -------------------------------------------------------------------------------- 1 | # WEB-BASED-IMAGE-CLASSIFICATION -------------------------------------------------------------------------------- /Web-Based Image Classification project report (1).docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEERTHIRAJENDRAN-27/WEB-BASED-IMAGE-CLASSIFICATION/HEAD/Web-Based Image Classification project report (1).docx -------------------------------------------------------------------------------- /API-Using-Flask.py: -------------------------------------------------------------------------------- 1 | import flask 2 | from flask import request, jsonify 3 | 4 | 5 | #creating ka Flask App 6 | app =flask.Flask(__name__) 7 | 8 | phone = [ 9 | {'id':0, 10 | 'name':'Samsung'}, 11 | {'id':1,'name':'iphone'} 12 | ] 13 | 14 | 15 | #Home route 16 | @app.route('/', methods=['GET']) 17 | def home(): 18 | return "

First App

" 19 | 20 | 21 | @app.route('/phone/',methods=['GET']) 22 | def api(): 23 | return jsonify(phone) 24 | 25 | 26 | @app.route('/phone/',methods=['GET']) 27 | def api_id(id): 28 | return jsonify(phone[int(id)]) 29 | 30 | if __name__=='__main__': 31 | app.run(debug=True) 32 | -------------------------------------------------------------------------------- /python: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | from keras.models import load_model 3 | from keras.preprocessing import image 4 | app = Flask(__name__) 5 | 6 | dic = {0 : 'Cat', 1 : 'Dog'} 7 | 8 | model = load_model('model.h5') 9 | 10 | model.make_predict_function() 11 | 12 | def predict_label(img_path): 13 | i = image.load_img(img_path, target_size=(100,100)) 14 | i = image.img_to_array(i)/255.0 15 | i = i.reshape(1, 100,100,3) 16 | p = model.predict_classes(i) 17 | return dic[p[0]] 18 | 19 | 20 | # routes 21 | @app.route("/", methods=['GET', 'POST']) 22 | def main(): 23 | return render_template("index.html") 24 | 25 | @app.route("/about") 26 | def about_page(): 27 | return "Please subscribe Artificial Intelligence Hub..!!!" 28 | 29 | @app.route("/submit", methods = ['GET', 'POST']) 30 | def get_output(): 31 | if request.method == 'POST': 32 | img = request.files['my_image'] 33 | 34 | img_path = "static/" + img.filename 35 | img.save(img_path) 36 | 37 | p = predict_label(img_path) 38 | 39 | return render_template("index.html", prediction = p, img_path = img_path) 40 | 41 | 42 | if __name__ =='__main__': 43 | #app.debug = True 44 | app.run(debug = True) 45 | -------------------------------------------------------------------------------- /w.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IMAGE CLASSFICATION 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 26 | 27 | 28 | 29 | 30 |
31 |

IMAGE CLASSFICATION

32 |

33 |
34 | 35 |
36 | 37 | 38 |
39 | 40 |
41 |
42 | 43 |
44 |
45 | 46 |
47 |
48 |
49 | {% if prediction %} 50 | 51 |

The Prediction of image is :

52 | 53 | {% endif %} 54 |
55 | 56 | 57 | --------------------------------------------------------------------------------