hyperparams = dict((k, v) for k, v in hyperparams.items() if v is not None) # Show the image and the ground truth display_dataset(img, gt, RGB_BANDS, LABEL_VALUES, palette, viz) # display_dataset(ori_img, ori_gt, RGB_BANDS, LABEL_VALUES, palette, viz) color_gt = convert_to_color(gt) if DATAVIZ: # Data exploration : compute and show the mean spectrums mean_spectrums, std_spectrums = explore_spectrums( img, gt, LABEL_VALUES, viz, ignored_labels=IGNORED_LABELS) with open("mean_spectrum_Salinas.txt", 'w') as f: for ln, lv in mean_spectrums.items(): f.write(str(lv)) f.write('\n') plot_spectrums(mean_spectrums, viz, title='Mean spectrum/class') plot_spectrums_(std_spectrums, viz, title='Std spectrum/class') results = [] # run the experiment several times for run in range(N_RUNS): if TRAIN_GT is not None and TEST_GT is not None: train_gt = open_file(TRAIN_GT) test_gt = open_file(TEST_GT) elif TRAIN_GT is not None: train_gt = open_file(TRAIN_GT) test_gt = np.copy(gt) w, h = test_gt.shape test_gt[(train_gt > 0)[:w, :h]] = 0 elif TEST_GT is not None: test_gt = open_file(TEST_GT)
# Show the image and the ground truth display_dataset(img, gt, RGB_BANDS, LABEL_VALUES, palette, viz) color_gt = convert_to_color(gt) # KD if (T_BAND_GROUP != 0): display_dataset(t_img, gt, RGB_BANDS, LABEL_VALUES, palette, viz) if DATAVIZ: # Data exploration : compute and show the mean spectrums mean_spectrums = explore_spectrums(img, gt, LABEL_VALUES, viz, ignored_labels=IGNORED_LABELS) plot_spectrums(mean_spectrums, viz, title="Mean spectrum/class") results = [] # run the experiment several times for run in range(N_RUNS): if TRAIN_GT is not None and TEST_GT is not None: print("Using existing train/test split...") train_gt = open_file(TRAIN_GT)['train_gt'] test_gt = open_file(TEST_GT)['test_gt'] elif TRAIN_GT is not None: train_gt = open_file(TRAIN_GT) test_gt = np.copy(gt) w, h = test_gt.shape test_gt[(train_gt > 0)[:w, :h]] = 0 elif TEST_GT is not None: test_gt = open_file(TEST_GT)