misc_utils.set_gpu(0) radius = 2500 width = 7 th = 5 model_name = 'faster_rcnn' merge_range = 100 for city_id in range(4): for tile_id in range(1, 4): K.clear_session() res50 = feature_extractor.Res50() print('Processing {}: tile {}'.format(city_list[city_id], tile_id)) # load data preds, raw_rgb, conf_img, line_gt, tower_gt, tower_pred, tower_conf = \ load_data(dirs, model_name, city_id, tile_id, merge_range=merge_range) tile_dim = raw_rgb.shape tower_pred = tower_gt features = get_features(raw_rgb, tower_pred, res50) # connect lines '''tower_pairs, tower_dists, line_confs = \ get_edge_info(tower_pred, conf_img, radius=radius, width=width, tile_min=(0, 0), tile_max=raw_rgb.shape) raw_pairs = connect_lines(tower_pairs, line_confs, th, cut_n=2) raw_pairs, _ = prune_lines(raw_pairs, tower_pred)''' raw_pairs = get_potential_connection_pair(tower_pred, radius) connected_pairs = [] # get line prediction
# settings merge_range = 100 radius = [2000] width = 7 th = 5 step = 5 patch_size = (500, 500) for city_id in range(4): for tile_id in [1, 2, 3]: print('Evaluating city {} tile {}'.format(city_id, tile_id)) # load data _, raw_rgb, conf_img, line_gt, tower_gt, _, tower_conf = \ load_data(dirs, 'faster_rcnn', city_id, tile_id, merge_range=merge_range) tower_pred = np.array(tower_gt) # get line confidences connected_pairs, connected_towers, unconnected_towers = None, None, None for r in radius: tower_pairs, tower_dists, line_confs = \ get_edge_info(tower_pred, conf_img, radius=r, width=width, tile_min=(0, 0), tile_max=raw_rgb.shape) # connect lines connected_pairs = connect_lines(tower_pairs, line_confs, th, cut_n=2) connected_pairs, unconnected_pairs = prune_lines(
line_conf[region[0]:region[1], region[2]:region[3]], 5) else: rgb = rgb line_conf = gaussian_filter(line_conf, 5) #misc_utils.save_file(os.path.join(dirs['image'], 'demo_rgb.png'), rgb) #misc_utils.save_file(os.path.join(dirs['image'], 'demo_line.png'), line_conf) # visualize_utils.compare_figures([rgb, line_conf], (1, 2), show_axis=False, fig_size=(12, 5), show_fig=False) tower_pred_demo(rgb_orig, pred_raw, tower_gt, None) #plt.savefig(os.path.join(dirs['image'], 'demo_pred.png')) if __name__ == '__main__': # settings city_id = 3 tile_id = 2 model_name = 'faster_rcnn' region = [800, 1400, 600, 1300] dirs = get_dirs() pred_raw, rgb, line_conf, line_gt, tower_gt, tower_pred, _ = load_data( dirs, model_name, city_id, tile_id) '''orig_demo(rgb, region) tower_pred_demo(rgb, pred_raw, tower_gt, region) lines_conf_demo(rgb, line_conf, region) plt.show()''' demo_plot(rgb, line_conf, pred_raw, tower_gt, region, dirs) plt.show()