| 26 | pyvips.Image.new_from_array(np.uint8(dmap['confidence_map'] * (1 / dmap['confidence_map'].max()) * 255)).write_to_file('%s_confidence_map.png' % basename) |
| 27 | |
| 28 | def main(): |
| 29 | parser = ArgumentParser() |
| 30 | parser.add_argument('-i', '--input', type=str, required=True, help='Path to the DMAP file directory') |
| 31 | parser.add_argument('-t', '--threads', type=int, default=int(os.cpu_count() * 0.5) - 1, help='Number of parallel computations') |
| 32 | parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output directory') |
| 33 | args = parser.parse_args() |
| 34 | |
| 35 | dmap_paths = glob(os.path.join(args.input, '*.dmap')) |
| 36 | |
| 37 | os.makedirs(args.output, exist_ok = True) |
| 38 | os.chdir(args.output) |
| 39 | |
| 40 | with ProcessPoolExecutor(max_workers=args.threads) as executor: |
| 41 | executor.map(exportDMAPContent, dmap_paths) |
| 42 | |
| 43 | if __name__ == '__main__': |
| 44 | main() |