def test_hyper(input_file, model, ckpt_dir, scale, cube_size, min_num, postfix=''): # Pre-process cubes, cube_positions, points_numbers = preprocess(input_file, scale, cube_size, min_num) ### Encoding y_strings, y_min_vs, y_max_vs, y_shape, z_strings, z_min_v, z_max_v, z_shape, x_ds = compress_hyper( cubes, model, ckpt_dir, True) # Write files filename = os.path.split(input_file)[-1][:-4] print(filename) rootdir = './compressed' + postfix + '/' bytes_strings, bytes_strings_head, bytes_strings_hyper, bytes_pointnums, bytes_cubepos = write_binary_files_hyper( filename, y_strings.numpy(), z_strings.numpy(), points_numbers, cube_positions, y_min_vs.numpy(), y_max_vs.numpy(), y_shape.numpy(), z_min_v.numpy(), z_max_v.numpy(), z_shape.numpy(), rootdir) # Read files y_strings_d, z_strings_d, points_numbers_d, cube_positions_d, y_min_vs_d, y_max_vs_d, y_shape_d, z_min_v_d, z_max_v_d, z_shape_d = \ read_binary_files_hyper(filename, rootdir) # Decoding cubes_d = decompress_hyper(y_strings_d, y_min_vs_d.astype('int32'), y_max_vs_d.astype('int32'), y_shape_d, z_strings_d, z_min_v_d, z_max_v_d, z_shape_d, model, ckpt_dir) # cheat!!! ############## cubes_d = x_ds ############## # bpp N = get_points_number(input_file) bpp = round( 8 * (bytes_strings + bytes_strings_head + bytes_strings_hyper + bytes_pointnums + bytes_cubepos) / float(N), 4) bpp_strings = round(8 * bytes_strings / float(N), 4) bpp_strings_hyper = round(8 * bytes_strings_hyper / float(N), 4) bpp_strings_head = round(8 * bytes_strings_head / float(N), 4) bpp_pointsnums = round(8 * bytes_pointnums / float(N), 4) bpp_cubepos = round(8 * bytes_cubepos / float(N), 4) bpps = [ bpp, bpp_strings, bpp_strings_hyper, bpp_strings_head, bpp_pointsnums, bpp_cubepos ] return cubes_d, cube_positions_d, points_numbers_d, N, bpps
postprocess(args.output, cubes_d.numpy(), points_numbers_d, cube_positions_d, args.scale, args.cube_size, args.rho) if args.mode == "hyper": if args.command == "compress": if not args.output: args.output = os.path.split(args.input)[-1][:-4] rootdir = './compressed' else: rootdir, args.output = os.path.split(args.output) cubes, cube_positions, points_numbers = preprocess(args.input, args.scale, args.cube_size, args.min_num) y_strings, y_min_vs, y_max_vs, y_shape, z_strings, z_min_v, z_max_v, z_shape = compress_hyper(cubes, model, args.ckpt_dir) bytes_strings, bytes_strings_head, bytes_strings_hyper, bytes_pointnums, bytes_cubepos = write_binary_files_hyper( args.output, y_strings.numpy(), z_strings.numpy(), points_numbers, cube_positions, y_min_vs.numpy(), y_max_vs.numpy(), y_shape.numpy(), z_min_v.numpy(), z_max_v.numpy(), z_shape.numpy(), rootdir=rootdir) elif args.command == "decompress": rootdir, filename = os.path.split(args.input) if not args.output: args.output = filename + "_rec.ply" y_strings_d, z_strings_d, points_numbers_d, cube_positions_d, \ y_min_vs_d, y_max_vs_d, y_shape_d, z_min_v_d, z_max_v_d, z_shape_d = read_binary_files_hyper(filename, rootdir) cubes_d = decompress_hyper(y_strings_d, y_min_vs_d, y_max_vs_d, y_shape_d, z_strings_d, z_min_v_d, z_max_v_d, z_shape_d, model, args.ckpt_dir) postprocess(args.output, cubes_d.numpy(), points_numbers_d, cube_positions_d, args.scale, args.cube_size, args.rho)