示例#1
0
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}
示例#2
0
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)
示例#3
0
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
示例#4
0
文件: app.py 项目: boonsim/bn-deploy
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)
示例#5
0
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')))
示例#6
0
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
示例#7
0
def predicting(imgurl):
    a = cv.image(imgurl)
    feat = a.getresnet50()
    # feat = a.getmobilenet()
    res = mod.predict([feat])[0]
    return res
示例#8
0
def predictimg(imgurl):
  a = cv.image(imgurl)
  feat = a.getresnet50()
  res = model.predict([feat])[0]
  return res
示例#9
0
def predictimg(imgurl):
    print('predict image running')
    a = cv.image(imgurl)
    feat = a.getmobilenet()
    res = mod.predict([feat])
    return res