Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add args to adjust tqdm output #108

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion torch_em/util/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def predict_with_halo(
postprocess=None,
with_channels=False,
skip_block=None,
disable_tqdm=False,
tqdm_desc='predict with halo'
):
""" Run block-wise network prediction with halo.

Expand All @@ -125,6 +127,8 @@ def predict_with_halo(
postprocess [callable] - function to postprocess the network predictions (default: None)
with_channels [bool] - whether the input has a channel axis (default: False)
skip_block [callable] - function to evaluate wheter a given input block should be skipped (default: None)
disable_tqdm [bool] - flag that allows to disable tqdm output (e.g. if function is called multiple times)
tqdm_desc [str] - description shown by the tqdm output
"""
devices = [torch.device(gpu) for gpu in gpu_ids]
models = [
Expand Down Expand Up @@ -191,6 +195,6 @@ def predict_block(block_id):

n_blocks = blocking.numberOfBlocks
with futures.ThreadPoolExecutor(n_workers) as tp:
list(tqdm(tp.map(predict_block, range(n_blocks)), total=n_blocks))
list(tqdm(tp.map(predict_block, range(n_blocks)), total=n_blocks, disable=disable_tqdm, desc=tqdm_desc))

return output