コード例 #1
0
ファイル: inputs.py プロジェクト: ylvaldes/gradio
 def preprocess(self, inp):
     """
     Default preprocessing method for is to convert the picture to black and white and resize to be 48x48
     """
     im = preprocessing_utils.decode_base64_to_image(inp)
     im = im.convert('RGB')
     im = preprocessing_utils.resize_and_crop(im, (self.image_width, self.image_height))
     return np.array(im)
コード例 #2
0
ファイル: inputs.py プロジェクト: ylvaldes/gradio
    def preprocess(self, inp):
        """
        Default preprocessing method for is to convert the picture to black and white and resize to be 48x48
        """
        im = preprocessing_utils.decode_base64_to_image(inp)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            im = im.convert(self.image_mode)

        im = preprocessing_utils.resize_and_crop(im, (self.image_width, self.image_height))
        return np.array(im)
コード例 #3
0
 def preprocess(self, inp):
     """
     Default preprocessing method for the SketchPad is to convert the sketch to black and white and resize 28x28
     """
     im = preprocessing_utils.decode_base64_to_image(inp)
     im = im.convert('L')
     if self.invert_colors:
         im = ImageOps.invert(im)
     im = preprocessing_utils.resize_and_crop(im, (self.image_width, self.image_height))
     if self.flatten:
         array = np.array(im).flatten().reshape(1, self.image_width * self.image_height)
     else:
         array = np.array(im).flatten().reshape(1, self.image_width, self.image_height)
     array = array * self.scale + self.shift
     array = array.astype(self.dtype)
     return array
コード例 #4
0
ファイル: inputs.py プロジェクト: xjzpguob/gradio-UI
    def preprocess(self, inp):
        """
        Default preprocessing method for is to convert the picture to black and white and resize to be 48x48
        """
        im = preprocessing_utils.decode_base64_to_image(inp)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            im = im.convert(self.image_mode)

        im = preprocessing_utils.resize_and_crop(im, (self.image_width, self.image_height))
        im = np.array(im).flatten()
        im = im * self.scale + self.shift
        if self.num_channels is None:
            array = im.reshape(1, self.image_width, self.image_height)
        else:
            array = im.reshape(1, self.image_width, self.image_height, self.num_channels)
        return array