VIDA-NYU / tile2net

Automated mapping of pedestrian networks from aerial imagery tiles
BSD 3-Clause "New" or "Revised" License
146 stars 22 forks source link

Resolve memory leak; tile background black and symlink #50

Closed dhodcz2 closed 6 months ago

dhodcz2 commented 6 months ago
  1. Resolve Memory Leak We had an issue of running out of memory for very large iterations during the inference step. It turned out that two segments of code were caching numpy arrays across all iterations:

                    pred[img_names[0]][values[v]] = counts[v]

    self.imgs_to_tensorboard.append(to_tensorboard) These segments have been commented out without any issue of functionality.

  2. Tile Background Black and Symlink A base black array is used as a placeholder for empty or missing tiles, and instead of writing empty black tiles to file, a symlink to the black tile array is made.

            if loc.any():
                src = self.black.__fspath__()
                for path in paths[loc]:
                    os.symlink(src, path)
                logger.debug(
                    f'{loc.sum():,} tiles were not found and returned 404 from the server '
                    f'so they were set as symlinks to {src}.'
                )