prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Sample of image_transformer does not work
  /kind bug
  Sample under docs/samples/transformer/image_transformer is broken, there's python error in it.
  
  **What steps did you take and what happened:**
  [A clear and concise description of what the bug is.]
  It's due to PR #492, kfmodel and kfserver is refactored now but the sample still inherit from transformer which does not exist now. Also some other symbols need be renamed.
  
  **What did you expect to happen:**
  Sample still works
  
  
  </issue>
  <code>
  [start of docs/samples/transformer/image_transformer/image_transformer/__main__.py]
  1 # Copyright 2019 kubeflow.org.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #    http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import kfserving
  16 import argparse
  17 from .image_transformer import ImageTransformer
  18 
  19 DEFAULT_MODEL_NAME = "model"
  20 
  21 parser = argparse.ArgumentParser(parents=[kfserving.server.parser])
  22 parser.add_argument('--model_name', default=DEFAULT_MODEL_NAME,
  23                     help='The name that the model is served under.')
  24 parser.add_argument('--predictor_host', help='The URL for the model predict function', required=True)
  25 
  26 args, _ = parser.parse_known_args()
  27 
  28 if __name__ == "__main__":
  29     transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host,
  30                                    protocol=args.protocol)
  31     kfserver = kfserving.KFServer()
  32     kfserver.start(models=[transformer])
  33
  [end of docs/samples/transformer/image_transformer/image_transformer/__main__.py]
  [start of docs/samples/transformer/image_transformer/image_transformer/image_transformer.py]
  1 # Copyright 2019 kubeflow.org.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #    http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import kfserving
  16 from typing import List, Dict
  17 from kfserving.transformer import Transformer
  18 from PIL import Image
  19 import torchvision.transforms as transforms
  20 import logging
  21 import io
  22 import numpy as np
  23 import base64
  24 
  25 logging.basicConfig(level=kfserving.constants.KFSERVING_LOGLEVEL)
  26 
  27 transform = transforms.Compose(
  28         [transforms.ToTensor(),
  29          transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
  30 
  31 
  32 def image_transform(instance):
  33     byte_array = base64.b64decode(instance['image_bytes']['b64'])
  34     image = Image.open(io.BytesIO(byte_array))
  35     a = np.asarray(image)
  36     im = Image.fromarray(a)
  37     res = transform(im)
  38     logging.info(res)
  39     return res.tolist()
  40 
  41 
  42 class ImageTransformer(Transformer):
  43 
  44     def preprocess(self, inputs: Dict) -> Dict:
  45         return {'instances': [image_transform(instance) for instance in inputs['instances']]}
  46 
  47     def postprocess(self, inputs: List) -> List:
  48         return inputs
  49
  [end of docs/samples/transformer/image_transformer/image_transformer/image_transformer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/docs/samples/transformer/image_transformer/image_transformer/__main__.py b/docs/samples/transformer/image_transformer/image_transformer/__main__.py
  --- a/docs/samples/transformer/image_transformer/image_transformer/__main__.py
  +++ b/docs/samples/transformer/image_transformer/image_transformer/__main__.py
  @@ -18,7 +18,7 @@
   
   DEFAULT_MODEL_NAME = "model"
   
  -parser = argparse.ArgumentParser(parents=[kfserving.server.parser])
  +parser = argparse.ArgumentParser(parents=[kfserving.kfserver.parser])
   parser.add_argument('--model_name', default=DEFAULT_MODEL_NAME,
                       help='The name that the model is served under.')
   parser.add_argument('--predictor_host', help='The URL for the model predict function', required=True)
  @@ -26,7 +26,6 @@
   args, _ = parser.parse_known_args()
   
   if __name__ == "__main__":
  -    transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host,
  -                                   protocol=args.protocol)
  +    transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host)
       kfserver = kfserving.KFServer()
       kfserver.start(models=[transformer])
  diff --git a/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py b/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py
  --- a/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py
  +++ b/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py
  @@ -14,7 +14,6 @@
   
   import kfserving
   from typing import List, Dict
  -from kfserving.transformer import Transformer
   from PIL import Image
   import torchvision.transforms as transforms
   import logging
  @@ -39,7 +38,10 @@
       return res.tolist()
   
   
  -class ImageTransformer(Transformer):
  +class ImageTransformer(kfserving.KFModel):
  +    def __init__(self, name: str, predictor_host: str):
  +        super().__init__(name)
  +        self.predictor_host = predictor_host
   
       def preprocess(self, inputs: Dict) -> Dict:
           return {'instances': [image_transform(instance) for instance in inputs['instances']]}
  
verification_info: {"golden_diff": "diff --git a/docs/samples/transformer/image_transformer/image_transformer/__main__.py b/docs/samples/transformer/image_transformer/image_transformer/__main__.py\n--- a/docs/samples/transformer/image_transformer/image_transformer/__main__.py\n+++ b/docs/samples/transformer/image_transformer/image_transformer/__main__.py\n@@ -18,7 +18,7 @@\n \n DEFAULT_MODEL_NAME = \"model\"\n \n-parser = argparse.ArgumentParser(parents=[kfserving.server.parser])\n+parser = argparse.ArgumentParser(parents=[kfserving.kfserver.parser])\n parser.add_argument('--model_name', default=DEFAULT_MODEL_NAME,\n                     help='The name that the model is served under.')\n parser.add_argument('--predictor_host', help='The URL for the model predict function', required=True)\n@@ -26,7 +26,6 @@\n args, _ = parser.parse_known_args()\n \n if __name__ == \"__main__\":\n-    transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host,\n-                                   protocol=args.protocol)\n+    transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host)\n     kfserver = kfserving.KFServer()\n     kfserver.start(models=[transformer])\ndiff --git a/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py b/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py\n--- a/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py\n+++ b/docs/samples/transformer/image_transformer/image_transformer/image_transformer.py\n@@ -14,7 +14,6 @@\n \n import kfserving\n from typing import List, Dict\n-from kfserving.transformer import Transformer\n from PIL import Image\n import torchvision.transforms as transforms\n import logging\n@@ -39,7 +38,10 @@\n     return res.tolist()\n \n \n-class ImageTransformer(Transformer):\n+class ImageTransformer(kfserving.KFModel):\n+    def __init__(self, name: str, predictor_host: str):\n+        super().__init__(name)\n+        self.predictor_host = predictor_host\n \n     def preprocess(self, inputs: Dict) -> Dict:\n         return {'instances': [image_transform(instance) for instance in inputs['instances']]}\n", "issue": "Sample of image_transformer does not work\n/kind bug\r\nSample under docs/samples/transformer/image_transformer is broken, there's python error in it.\r\n\r\n**What steps did you take and what happened:**\r\n[A clear and concise description of what the bug is.]\r\nIt's due to PR #492, kfmodel and kfserver is refactored now but the sample still inherit from transformer which does not exist now. Also some other symbols need be renamed.\r\n\r\n**What did you expect to happen:**\r\nSample still works\r\n\n", "before_files": [{"content": "# Copyright 2019 kubeflow.org.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport kfserving\nimport argparse\nfrom .image_transformer import ImageTransformer\n\nDEFAULT_MODEL_NAME = \"model\"\n\nparser = argparse.ArgumentParser(parents=[kfserving.server.parser])\nparser.add_argument('--model_name', default=DEFAULT_MODEL_NAME,\n                    help='The name that the model is served under.')\nparser.add_argument('--predictor_host', help='The URL for the model predict function', required=True)\n\nargs, _ = parser.parse_known_args()\n\nif __name__ == \"__main__\":\n    transformer = ImageTransformer(args.model_name, predictor_host=args.predictor_host,\n                                   protocol=args.protocol)\n    kfserver = kfserving.KFServer()\n    kfserver.start(models=[transformer])\n", "path": "docs/samples/transformer/image_transformer/image_transformer/__main__.py"}, {"content": "# Copyright 2019 kubeflow.org.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport kfserving\nfrom typing import List, Dict\nfrom kfserving.transformer import Transformer\nfrom PIL import Image\nimport torchvision.transforms as transforms\nimport logging\nimport io\nimport numpy as np\nimport base64\n\nlogging.basicConfig(level=kfserving.constants.KFSERVING_LOGLEVEL)\n\ntransform = transforms.Compose(\n        [transforms.ToTensor(),\n         transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])\n\n\ndef image_transform(instance):\n    byte_array = base64.b64decode(instance['image_bytes']['b64'])\n    image = Image.open(io.BytesIO(byte_array))\n    a = np.asarray(image)\n    im = Image.fromarray(a)\n    res = transform(im)\n    logging.info(res)\n    return res.tolist()\n\n\nclass ImageTransformer(Transformer):\n\n    def preprocess(self, inputs: Dict) -> Dict:\n        return {'instances': [image_transform(instance) for instance in inputs['instances']]}\n\n    def postprocess(self, inputs: List) -> List:\n        return inputs\n", "path": "docs/samples/transformer/image_transformer/image_transformer/image_transformer.py"}]}