Beispiel #1
0
    def predict(self, image):
        if K.image_dim_ordering() == 'th' and image.shape != (1, 3, IMAGE_SIZE, IMAGE_SIZE):
            image = resize_with_pad(image)
            image = image.reshape((1, 3, IMAGE_SIZE, IMAGE_SIZE))
        elif K.image_dim_ordering() == 'tf' and image.shape != (1, IMAGE_SIZE, IMAGE_SIZE, 3):
            image = resize_with_pad(image)
            image = image.reshape((1, IMAGE_SIZE, IMAGE_SIZE, 3))
        image = image.astype('float32')
        image /= 255
        result = self.model.predict_proba(image)
        print(result)
        result = self.model.predict_classes(image)

        return result[0]
Beispiel #2
0
 def predict(self, image):
     if image.shape != (1, IMAGE_SIZE, IMAGE_SIZE, 3):
         image = resize_with_pad(image)
         image = image.reshape((1, IMAGE_SIZE, IMAGE_SIZE, 3))
     image = image.astype('float32')
     image /= 255
     result = self.model.predict_proba(image)
     return result[0]
Beispiel #3
0
    def predict(self, predict_image):
        image = resize_with_pad(predict_image)
        image = image.astype('float32')
        image /= 255

        result = self.model.predict(np.array([image]))[0]
        whois = 0 if (result[0] > result[1]) else 1

        return whois
Beispiel #4
0
    def predict(self, image, img_channels=3):
        if K.image_dim_ordering() == 'th' and image.shape != (
                1, img_channels, IMAGE_SIZE, IMAGE_SIZE):
            image = resize_with_pad(image)
            image = image.reshape((1, img_channels, IMAGE_SIZE, IMAGE_SIZE))
        elif K.image_dim_ordering() == 'tf' and image.shape != (
                1, IMAGE_SIZE, IMAGE_SIZE, img_channels):
            image = resize_with_pad(image)
            image = image.reshape((1, IMAGE_SIZE, IMAGE_SIZE, img_channels))
        image = image.astype('float32')
        image /= 255
        if DEBUG_MUTE:
            result = self.model.predict_proba(image, verbose=0)
            result = self.model.predict_classes(image, verbose=0)
        else:
            result = self.model.predict_proba(image)
            print(result)
            result = self.model.predict_classes(image)
            print(result)

        return result[0]