Ejemplo n.º 1
0
                    labels to one hot encoding",
                    type=str2bool,
                    default=True)
args = parser.parse_args()

print('=' * 50)
print('Parameters')
print(f'patch size={args.patch_size}')
print(f'stride={args.stride}')
print(f'Number of classes={args.num_classes} ')
print('=' * 50)

root_path = './DATASETS/ISPRS_npy'
# Load images
img_train_path = 'Image_Train.npy'
img_train = load_npy_image(os.path.join(root_path, img_train_path))
# Convert shape from C x H x W --> H x W x C
img_train = img_train.transpose((1, 2, 0))
# img_train_normalized = normalization(img_train)
print('Imagem RGB')
print(img_train.shape)

# Load reference
img_train_ref_path = 'Reference_Train.npy'
img_train_ref = load_npy_image(os.path.join(root_path, img_train_ref_path))
# Convert from C x H x W --> H x W x C
img_train_ref = img_train_ref.transpose((1, 2, 0))
print('Imagem de referencia')
print(img_train_ref.shape)

label_dict = {
Ejemplo n.º 2
0
parser = argparse.ArgumentParser()
parser.add_argument("--resunet_a",
                    help="choose resunet-a model or not",
                    type=int,
                    default=0)
parser.add_argument("--multitasking",
                    help="choose resunet-a model or not",
                    type=int,
                    default=0)
args = parser.parse_args()

root_path = './DATASETS/'

# Load images
# img_t1 = load_tiff_image(root_path+'images/18_08_2017_image'+'.tif').astype(np.float32)
img_t1 = load_npy_image(root_path + 'images_npy/18_08_2017_image' +
                        '.npy').astype(np.float32)
img_t1 = img_t1.transpose((1, 2, 0))

# img_t2 = load_tiff_image(root_path+'images/21_08_2018_image'+'.tif').astype(np.float32)
img_t2 = load_npy_image(root_path + 'images_npy/21_08_2018_image' +
                        '.npy').astype(np.float32)
img_t2 = img_t2.transpose((1, 2, 0))

# Concatenation of images
image_array1 = np.concatenate((img_t1, img_t2), axis=-1).astype(np.float32)
h_, w_, channels = image_array1.shape
print(image_array1.shape)

# Normalization
type_norm = 1
image_array = normalization(image_array1, type_norm)
parser.add_argument("--resunet_a",
                    help="choose resunet-a model or not",
                    type=int,
                    default=0)
parser.add_argument("--multitasking",
                    help="choose resunet-a model or not",
                    type=int,
                    default=0)
args = parser.parse_args()

root_path = './DATASETS/dataset_npy'
img_t1_path = 'clipped_raster_004_66_2018.npy'
img_t2_path = 'clipped_raster_004_66_2019.npy'

# Load images
img_t1 = load_npy_image(os.path.join(root_path,
                                     img_t1_path)).astype(np.float32)
img_t1 = img_t1.transpose((1, 2, 0))
img_t2 = load_npy_image(os.path.join(root_path,
                                     img_t2_path)).astype(np.float32)
img_t2 = img_t2.transpose((1, 2, 0))

# Concatenation of images
image_array1 = np.concatenate((img_t1, img_t2), axis=-1).astype(np.float32)
image_array1 = image_array1[:6100, :6600]
h_, w_, channels = image_array1.shape
print(f"Input image shape: {image_array1.shape}")

# Normalization
type_norm = 1
image_array = normalization(image_array1, type_norm)
#print(np.min(image_array), np.max(image_array))
                    help="Number of classes",
                    type=int,
                    default=5)
parser.add_argument("--output_path",
                    help="Path to where save predictions",
                    type=str,
                    default='results/preds_run')
args = parser.parse_args()

# Test model

root_path = args.dataset_path

# Load images
img_test_path = 'Image_Test.npy'
img_test = load_npy_image(os.path.join(root_path,
                                       img_test_path)).astype(np.float32)
if args.norm_type == 3:
    img_test_normalized = normalization(img_test)
else:
    img_test_normalized = normalize_rgb(img_test, norm_type=args.norm_type)
# Transform the image into W x H x C shape
img_test_normalized = img_test_normalized.transpose((1, 2, 0))
print(img_test_normalized.shape)

# Load reference
img_test_ref_path = 'Reference_Test.npy'
img_test_ref = load_npy_image(os.path.join(root_path, img_test_ref_path))
# Transform the image into W x H x C shape
img_test_ref = img_test_ref.transpose((1, 2, 0))
print(img_test_ref.shape)