def save_img_results_test(imgs_tcpu, real_box, boxes_pred, count, test_dir): num = cfg.TRAIN.VIS_COUNT # The range of real_img (i.e., self.imgs_tcpu[i][0:num]) # is changed to [0, 1] by function vutils.save_image real_img = imgs_tcpu[-1][0:num] vutils.save_image( real_img, '%s/count_%09d_real_samples.png' % (test_dir, count), normalize=True) # save bounding box images vutils.save_bbox( real_img, real_box, '%s/count_%09d_real_bbox.png' % (test_dir, count), normalize=True) vutils.save_bbox( real_img, boxes_pred, '%s/count_%09d_fake_bbox.png' % (test_dir, count), normalize=True) # save floor plan images vutils.save_floor_plan( real_img, real_box, '%s/count_%09d_real_floor_plan.png' % (test_dir, count), normalize=True) vutils.save_floor_plan( real_img, boxes_pred, '%s/count_%09d_fake_floor_plan.png' % (test_dir, count), normalize=True)
def visualize(boxes_coords, boxes_types, save_pic_path): """ function: visualize the coord to check as follow box_collection: [(tensor([[boxes_coord],[boxes_coord],..]), [tensor,tensor,...])] example:[(tensor([[0.6235, 0.3686, 0.3373, 0.3686], [0.3373, 0.3686, 0.3373, 0.6941], [0.3373, 0.6941, 0.6235, 0.6941], [0.6235, 0.6941, 0.6235, 0.3686], [0.6235, 0.3686, 0.6235, 0.3686]]), [tensor(0.), tensor(0.), tensor(0.), tensor(0.), tensor(0.)])] """ import vutils boxes_types_tensor = [torch.tensor(boxes_types[t]) for t in range(len(boxes_types))] boxes_coords = torch.tensor(boxes_coords) boxes_collection = [(boxes_coords, boxes_types_tensor)] background = np.zeros((256, 256)) vutils.save_bbox(background, boxes_collection, save_pic_path, normalize=True, draw_line=True)
def visualize(boxes_coord, boxes_type, save_pic_path): """ boxes_coord:[[],[],..] boxes_type:[] box_collection: [(tensor([[boxes_coord],[boxes_coord],..]), [tensor,tensor,...])] example:[(tensor([[0.6235, 0.3686, 0.3373, 0.3686], [0.3373, 0.3686, 0.3373, 0.6941], [0.3373, 0.6941, 0.6235, 0.6941], [0.6235, 0.6941, 0.6235, 0.3686], [0.6235, 0.3686, 0.6235, 0.3686]]), [tensor(0.), tensor(0.), tensor(0.), tensor(0.), tensor(0.)])] """ # visualize the coord to check as follow import vutils boxes_type = [torch.tensor(boxes_type[i]) for i in range(len(boxes_type))] boxes_coord = torch.tensor(boxes_coord) boxes_collection = [(boxes_coord, boxes_type)] background = np.zeros((256, 256)) vutils.save_bbox(background, boxes_collection, save_pic_path, normalize=True, draw_line=True)