How to use the kfserving.KFModel 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
import kfserving
from typing import List, Dict
import numpy as np
from alibi_detect.utils.saving import load_tf_model
import argparse

class SignsModel(kfserving.KFModel):
    def __init__(self, name: str, model_dir: str):
        super().__init__(name)
        self.model_dir = model_dir
        self.name = name
        self.ready = False

    def load(self):
        self.model = load_tf_model(self.model_dir)
        self.ready = True

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

        try:
            preds = self.model.predict(inputs)
            print(preds)
github SeldonIO / alibi-detect / integrations / samples / kfserving / ad-mnist / mnist.py View on Github external
import kfserving
from typing import List, Dict
import numpy as np
from alibi_detect.utils.saving import load_tf_model
import argparse

class MnistModel(kfserving.KFModel):
    def __init__(self, name: str, model_dir: str):
        super().__init__(name)
        self.model_dir = model_dir
        self.name = name
        self.ready = False

    def load(self):
        self.model = load_tf_model(self.model_dir)
        self.ready = True

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

        try:
            preds = self.model.predict(inputs)
            print(preds)