示例#1
0
                                validation_steps=len(test_set))
        model.save(self.model_save_path)

    def test(self):
        model = load_model(self.model_save_path)
        image = load_img(self.test_image_path, target_size=(224, 224))
        image1 = img_to_array(image)
        image1 = image1.reshape(
            (1, image1.shape[0], image1.shape[1], image1.shape[2]))
        image1 = preprocess_input(image1)
        yhat = model.predict(image1)
        pred = np.argmax(yhat)
        #change according to your dataset
        if pred == 0:
            prediction = 'satellite_image'
            print(prediction)
            plt.imshow(image)
        else:
            prediction = 'non_satellite_image'
            print(prediction)
            plt.imshow(image)


if __name__ == "__main__":
    train_path = input('Enter the Input folder path:')
    model_save_path = input('Enter the path to save model in terms of .h5')
    test_image_path = input('Enter the image path to test:')
    a = Xception(train_path, model_save_path, test_image_path)
    b = a.train()
    c = a.test()