REST API - Tensorflow/server.py
def predict():
    '''
    Read the input images from input and return the predicted class.
    '''
    
    result = {'success':False}
    #Fetch the file
    # ensure an image was properly uploaded to our endpoint
    if flask.request.method == "POST":
        if flask.request.files.get("image"):
             # read the image in PIL format
            image = flask.request.files["image"].read()
            image = Image.open(io.BytesIO(image))
            image = np.reshape(image,(1,IMG_ROWS,IMG_COLS,1))

            y_pred = cls.predict(image)
            
            result['success'] = True
            
            result['prediction'] = (np.argmax(y_pred[0])).tolist()

    return flask.jsonify(result)

    Read the input images from input and return the predicted class.
    
Read the input images from input and return the predicted class.
Read the input images from input and return the predicted class .
def predict():
    result = {'success':False}
    if flask.request.method == "POST":
        if flask.request.files.get("image"):
            image = flask.request.files["image"].read()
            image = Image.open(io.BytesIO(image))
            image = np.reshape(image,(1,IMG_ROWS,IMG_COLS,1))
            y_pred = cls.predict(image)
            result['success'] = True
            result['prediction'] = (np.argmax(y_pred[0])).tolist()
    return flask.jsonify(result)
def predict ( ) : result = { 'success' : False } if flask . request . method == "POST" : if flask . request . files . get ( "image" ) : image = flask . request . files [ "image" ] . read ( ) image = Image . open ( io . BytesIO ( image ) ) image = np . reshape ( image , ( 1 , IMG_ROWS , IMG_COLS , 1 ) ) y_pred = cls . predict ( image ) result [ 'success' ] = True result [ 'prediction' ] = ( np . argmax ( y_pred [ 0 ] ) ) . tolist ( ) return flask . jsonify ( result )
Read the input images from input and return the predicted class.
Read the input images from input and return the predicted class .
'''
    Read the input images from input and return the predicted class.
    ''' #Fetch the file # ensure an image was properly uploaded to our endpoint # read the image in PIL format