def predicting(imgurl: str): modFile = 'mymod.mod' mod = pickle.load(open(modFile, 'rb')) a = cv.image(imgurl) feat = a.getresnet50() res = mod.predict([feat]) return {"class": res}
def classifier(): img_url = request.values['p_image_url'] a = cv.image(img_url) feat = a.getmobilenet() model = joblib.load('model_mobilenet.pkl') #Predict classes with LinearSVC prediction = model.predict([feat]) result = {'img_url': img_url, 'prediction': prediction[0]} return jsonify(result)
def predictimg(imgurl): a = cv.image(imgurl) feat = a.getresnet50() probList = mymod.predict_proba([feat])[0] maxprobind = np.argmax(probList) prob = probList[maxprobind] outclass = mymod.classes_[maxprobind] result = {} result['class'] = outclass result['probability'] = prob return result
def classifier(): img_url = request.values['p_image_url'] a = cv.image(img_url) feat = a.getmobilenet() modFile = 'CDmodel.mod' model = pickle.load(open(modFile, 'rb')) #Predict classes with LinearSVC prediction = model.predict([feat]) print(feat.shape) result = {'img_url': img_url, 'prediction': prediction[0]} return jsonify(result)
def predictImage(pic_name): #Load model modFile = 'gymmachine.mod' mod = pickle.load(open(modFile, 'rb')) # input image test_image = cv.image(pic_name) feat = test_image.getmobilenet() res = mod.predict([feat]) #print(res) return res[0] #print('The result is: {}.'.format(predictImage('testimage.jpg')))
def predict_image(img_url): a = cv.image(img_url) feat = a.getmobilenet() probList = mymod.predict_proba([feat])[0] maxprobind = np.argmax(probList) prob = probList[maxprobind] outclass = mymod.classes_[maxprobind] result = {} result['class'] = outclass result['probability'] = prob food = cal_df.loc[cal_df['food_name'] == outclass] if len(food.index) > 0: result['cal'] = float(food['cal'].values[0]) result['fat'] = float(food['fat'].values[0]) result['protein'] = float(food['protein'].values[0]) result['carbohydrate'] = float(food['carbohydrate'].values[0]) return result
def predicting(imgurl): a = cv.image(imgurl) feat = a.getresnet50() # feat = a.getmobilenet() res = mod.predict([feat])[0] return res
def predictimg(imgurl): a = cv.image(imgurl) feat = a.getresnet50() res = model.predict([feat])[0] return res
def predictimg(imgurl): print('predict image running') a = cv.image(imgurl) feat = a.getmobilenet() res = mod.predict([feat]) return res