Пример #1
0
    def create_prediction_microservice(self,pipeline_folder,model_name):
        """
        Create a prediction Flask microservice app

        Parameters
        ----------

        pipeline_folder : str
           location of pipeline
        model_name : str
           model name to use for this pipeline
        """
        app = Flask(__name__)
                   
        rint = random.randint(1,999999)
        pw = sutl.PipelineWrapper(work_folder='/tmp/pl_'+str(rint),aws_key=self.aws_key,aws_secret=self.aws_secret)
        pipeline = pw.load_pipeline(pipeline_folder)
        
        app.config["seldon_pipeline_wrapper"] = pw
        app.config["seldon_pipeline"] = pipeline
        app.config["seldon_model_name"] = model_name
 
        app.register_blueprint(predict_blueprint)

        # other setup tasks
        return app
Пример #2
0
 def create_prediction_rpc_microservice(self, pipeline_folder, model_name,
                                        custom_data_handler):
     rint = random.randint(1, 999999)
     pw = sutl.PipelineWrapper(work_folder='/tmp/pl_' + str(rint),
                               aws_key=self.aws_key,
                               aws_secret=self.aws_secret)
     pipeline = pw.load_pipeline(pipeline_folder)
     server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
     seldon_pb2.add_ClassifierServicer_to_server(
         RpcClassifier(pipeline, model_name, custom_data_handler), server)
     server.add_insecure_port('[::]:5000')
     server.start()
     try:
         while True:
             time.sleep(_ONE_DAY_IN_SECONDS)
     except KeyboardInterrupt:
         server.stop(0)
Пример #3
0
    # print(sess.run(accuracy, feed_dict = {x: mnist.test.images, y_:mnist.test.labels}))

    tfw = TensorFlowWrapper(sess,
                            tf_input=x,
                            tf_output=y_conv,
                            tf_constants=[(keep_prob, 1.0)],
                            target="y",
                            target_readable="class",
                            excluded=['class'])

    return Pipeline([('deep_classifier', tfw)])


if __name__ == '__main__':

    parser = argparse.ArgumentParser(prog='pipeline_example')
    parser.add_argument('-m',
                        '--model',
                        help='model output folder',
                        required=True)
    parser.add_argument('-l', '--load', help='Load pretrained model from file')

    args = parser.parse_args()

    p = create_pipeline(args.load)

    pw = sutl.PipelineWrapper()

    pw.save_pipeline(p, args.model)