How to use the kfserving.kfserver.parser function in kfserving

To help you get started, we’ve selected a few kfserving examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SeldonIO / alibi-detect / integrations / samples / kfserving / ad-signs / signs.py View on Github external
self.ready = True

    def predict(self, request: Dict) -> Dict:
        inputs = np.array(request["instances"])

        try:
            preds = self.model.predict(inputs)
            print(preds)
            return { "predictions":  preds.argmax(axis=1).tolist() }
        except Exception as e:
            raise Exception("Failed to predict %s" % e)

DEFAULT_MODEL_NAME = "model"
DEFAULT_LOCAL_MODEL_DIR = "/tmp/model"

parser = argparse.ArgumentParser(parents=[kfserving.kfserver.parser])
parser.add_argument('--model_dir', required=True,
                    help='A URI pointer to the model binary')
args, _ = parser.parse_known_args()

if __name__ == "__main__":
    model = SignsModel("signs",args.model_dir)
    # Set number of workers to 1 as model is quite large
    kfserving.KFServer(workers=1).start([model])
github SeldonIO / alibi-detect / integrations / samples / kfserving / ad-mnist / mnist.py View on Github external
self.ready = True

    def predict(self, request: Dict) -> Dict:
        inputs = np.array(request["instances"])

        try:
            preds = self.model.predict(inputs)
            print(preds)
            return { "predictions":  preds.argmax(axis=1).tolist() }
        except Exception as e:
            raise Exception("Failed to predict %s" % e)

DEFAULT_MODEL_NAME = "model"
DEFAULT_LOCAL_MODEL_DIR = "/tmp/model"

parser = argparse.ArgumentParser(parents=[kfserving.kfserver.parser])
parser.add_argument('--model_dir', required=True,
                    help='A URI pointer to the model binary')
args, _ = parser.parse_known_args()

if __name__ == "__main__":
    model = MnistModel("mnist",args.model_dir)
    # Set number of workers to 1 as model is quite large
    kfserving.KFServer(workers=1).start([model])