Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 5755f1f

Browse files
fix: this functions has internal subprocess calls
1 parent a15dd38 commit 5755f1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

s2p/initialization.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import rasterio
1111
import numpy as np
1212
import rpcm
13+
from multiprocessing import cpu_count
1314

1415
from s2p import common
1516
from s2p import geographiclib
@@ -346,6 +347,7 @@ def is_this_tile_useful(x, y, w, h, images, images_sizes, border_margin, cfg):
346347
mask = masking.image_tile_mask(x, y, w, h, roi_msk, cld_msk, wat_msk,
347348
images_sizes[0], border_margin=border_margin, temporary_dir=cfg['temporary_dir'])
348349
if not mask.any():
350+
349351
return False, None
350352
return True, mask
351353

@@ -379,10 +381,12 @@ def tiles_full_info(cfg, tw, th, tiles_txt, create_masks=False):
379381
with rasterio.open(img['img'], 'r') as f:
380382
images_sizes.append(f.shape)
381383

384+
# compute all masks in parallel as numpy arrays
385+
n_workers = cfg["max_processes"] if cfg["max_processes"] is not None else cpu_count()
382386
# compute all masks in parallel as numpy arrays
383387
tiles_usefulnesses = parallel.launch_calls(is_this_tile_useful,
384388
tiles_coords,
385-
cfg['max_processes'],
389+
min(n_workers, cpu_count()//2), # internal subprocess calls!,
386390
cfg['images'],
387391
images_sizes,
388392
cfg['border_margin'],

0 commit comments

Comments
 (0)