コード例 #1
0
# 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

    path = os.path.join('crater_data', 'tiles')
    img = cv.imread(os.path.join(path, tile_img + '.pgm'), 0)
コード例 #2
0
# 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',
                          'crater_east_model_nn.ckpt')
model.restore(model_path)
コード例 #3
0
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 = []
    for img_path in path_list:
        src_img = cv2.imread(img_path)
        gray_img = rgb2gray(src_img)