from crater_loader import load_crater_data
from crater_data import Data

# Load dataxcv
images, labels, hot_one = load_crater_data()
data = Data(images, hot_one, random_state=42)

print("Size of:")
print("- Training-set:\t\t{}".format(len(data.train.labels)))
print("- Test-set:\t\t{}".format(len(data.test.labels)))
print("- Validation-set:\t{}".format(len(data.validation.labels)))

model = Network(img_shape=(50, 50, 1))
model.add_flat_layer()
model.add_fc_layer(size=50 * 50, use_relu=True)
model.add_fc_layer(size=16, use_relu=True)
model.add_fc_layer(size=2, use_relu=False)
model.finish_setup()
#model.set_data(data)

cnn = Network(img_shape=(50, 50, 1))
cnn.add_convolutional_layer(5, 16)
cnn.add_convolutional_layer(5, 36)
cnn.add_flat_layer()
cnn.add_fc_layer(size=64, use_relu=True)
cnn.add_fc_layer(size=16, use_relu=True)
cnn.add_fc_layer(size=2, use_relu=False)
cnn.finish_setup()

model_path = os.path.join(cwd, 'results', 'nn_models',
import Param
import argparse

# This script will go through all image tiles and detects crater area using sliding window method.
# Then, write results as a csv file to the results folder. The results of this script is the input to the remove_duplicates.py script.
# you need to provide the tile image name as argument after --tileimg command. For instance tile1_24

param = Param.Param()
cwd = os.getcwd()

# setup CNN
cnn = CNN(img_shape=(50, 50, 1))
cnn.add_convolutional_layer(5, 16)
cnn.add_convolutional_layer(5, 36)
cnn.add_flat_layer()
cnn.add_fc_layer(size=64, use_relu=True)
cnn.add_fc_layer(size=16, use_relu=True)
cnn.add_fc_layer(size=2, use_relu=False)
cnn.finish_setup()
# model.set_data(data)

# restore previously trained CNN model
cnn_model_path = os.path.join(cwd, 'models/cnn/crater_model_cnn.ckpt')
cnn.restore(cnn_model_path)

# go through all the tile folders
gt_list = ["1_24", "1_25", "2_24", "2_25", "3_24", "3_25"]

for gt_num in gt_list:

    tile_img = 'tile' + gt_num
예제 #3
0
import matplotlib.pyplot as plt

from crater_cnn import Network
from crater_plots import plot_image, plot_conv_weights, plot_conv_layer
from keras.applications import imagenet_utils
from keras.preprocessing import image
from skimage.color import gray2rgb, rgb2gray

cwd = os.getcwd()

input_shape = (50, 50)
preprocess = imagenet_utils.preprocess_input
# setup NN
nn = Network(img_shape=(50, 50, 1))
nn.add_flat_layer()
nn.add_fc_layer(size=50 * 50, use_relu=True)
nn.add_fc_layer(size=16, use_relu=True)
nn.add_fc_layer(size=2, use_relu=False)
nn.finish_setup()
# model.set_data(data)

# restore previously trained CNN model
print("loading the pre-trained NN model")
nn_model_path = os.path.join(cwd, 'results', 'nn_models',
                             'crater_east_model_nn.ckpt')
nn.restore(nn_model_path)


def transform_img_fn(path_list):
    org_out = []
    trans_out = []
예제 #4
0
preprocess(img_dimensions=(50, 50), 'tile1_25')

from crater_loader import load_crater_data
from crater_data import Data

# Load data
images, labels, hot_one = load_crater_data()
data = Data(images, hot_one, random_state=42)

print("Size of:")
print("- Training-set:\t\t{}".format(len(data.train.labels)))
print("- Test-set:\t\t{}".format(len(data.test.labels)))

model = Network(img_shape=(50, 50, 1))
model.add_flat_layer()
model.add_fc_layer(size=50 * 50, use_relu=True)
model.add_fc_layer(size=16, use_relu=True)
model.add_fc_layer(size=2, use_relu=False)
model.finish_setup()
model.set_data(data)

model_path = os.path.join(cwd, 'results', 'models', 'crater_model_nn.ckpt')
#model.restore(model_path)

model.print_test_accuracy()

model.optimize(epochs=20)

model.save(model_path)

model.print_test_accuracy()
예제 #5
0
from crater_data import Data

# Load data
images, labels, hot_one = load_crater_data()
data = Data(images, hot_one, random_state=42)

print("Size of:")
print("- Training-set:\t\t{}".format(len(data.train.labels)))
print("- Test-set:\t\t{}".format(len(data.test.labels)))
print("- Validation-set:\t{}".format(len(data.validation.labels)))

model = Network(img_shape=(50, 50, 1))
model.add_convolutional_layer(5, 16)
model.add_convolutional_layer(5, 36)
model.add_flat_layer()
model.add_fc_layer(size=64, use_relu=True)
model.add_fc_layer(size=16, use_relu=True)
model.add_fc_layer(size=2, use_relu=False)
model.finish_setup()
model.set_data(data)

model_path = os.path.join(cwd, 'results', 'models', 'crater_east_model_cnn.ckpt')
#model.restore(model_path)

model.print_test_accuracy()

model.optimize(epochs=20)

model.save(model_path)

model.print_test_accuracy()