From 00bab7a742649733d30bd0228eb5c514124919b9 Mon Sep 17 00:00:00 2001 From: Paul Tunison Date: Thu, 5 Jan 2023 12:01:46 -0500 Subject: [PATCH 1/2] Small formatting update to benchmark util to make easier to read --- docs/release_notes/pending_release.rst | 4 ++++ xaitk_saliency/utils/masking.py | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/release_notes/pending_release.rst b/docs/release_notes/pending_release.rst index dbc99585..4b1e03e6 100644 --- a/docs/release_notes/pending_release.rst +++ b/docs/release_notes/pending_release.rst @@ -4,5 +4,9 @@ Pending Release Notes Updates / New Features ---------------------- +Utils + +* Updated logging format of occlusion masking benchmark utility. + Fixes ----- diff --git a/xaitk_saliency/utils/masking.py b/xaitk_saliency/utils/masking.py index 8e7c8895..e22c9583 100644 --- a/xaitk_saliency/utils/masking.py +++ b/xaitk_saliency/utils/masking.py @@ -233,50 +233,53 @@ def benchmark_occlude_image( perf_counter = time.perf_counter print(f"Image shape={img_mat.shape}, masks={masks.shape}, fill_1c={fill_1c}, fill_{img_channels}c={fill_mc}") + def log_line(op: str, mode: str, cores: int, fill: str, seconds: float) -> None: + print(f"{op:12s}{mode:16s}{cores:2d} {fill:9s}{seconds} s") + s = perf_counter() occlude_image_batch(img_mat, masks) e = perf_counter() - print(f"Batch - no-fill - {e-s} s") + log_line("Batch", "main", 0, "no-fill", e-s) for threads in threading_tests: s = perf_counter() occlude_image_batch(img_mat, masks, threads=threads) e = perf_counter() - print(f"Batch - threads={threads:2d} - no-fill - {e-s} s") + log_line("Batch", "threads", threads, "no-fill", e - s) for threads in threading_tests: s = perf_counter() np.asarray(list(occlude_image_streaming(img_mat, masks, threads=threads))) e = perf_counter() - print(f"Streaming - threads={threads:2d} - no-fill - {e-s} s") + log_line("Streaming", "threads", threads, "no-fill", e - s) s = perf_counter() occlude_image_batch(img_mat, masks, fill=fill_1c) e = perf_counter() - print(f"Batch - fill-1c - {e-s} s") + log_line("Batch", "main", 0, "fill-1c", e-s) for threads in threading_tests: s = perf_counter() occlude_image_batch(img_mat, masks, fill=fill_1c, threads=threads) e = perf_counter() - print(f"Batch - threads={threads:2d} - fill-1c - {e-s} s") + log_line("Batch", "threads", threads, "fill-1c", e - s) for threads in threading_tests: s = perf_counter() np.asarray(list(occlude_image_streaming(img_mat, masks, fill=fill_1c, threads=threads))) e = perf_counter() - print(f"Streaming - threads={threads:2d} - fill-1c - {e-s} s") + log_line("Streaming", "threads", threads, "fill-1c", e - s) s = perf_counter() occlude_image_batch(img_mat, masks, fill=fill_mc) e = perf_counter() - print(f"Batch - fill-{img_channels}c - {e-s} s") + log_line("Batch", "main", 0, f"fill-{img_channels}c", e-s) for threads in threading_tests: s = perf_counter() occlude_image_batch(img_mat, masks, fill=fill_mc, threads=threads) e = perf_counter() - print(f"Batch - threads={threads:2d} - fill-{img_channels}c - {e-s} s") + log_line("Batch", "threads", threads, f"fill-{img_channels}c", e - s) for threads in threading_tests: s = perf_counter() np.asarray(list(occlude_image_streaming(img_mat, masks, fill=fill_mc, threads=threads))) e = perf_counter() - print(f"Streaming - threads={threads:2d} - fill-{img_channels}c - {e-s} s") + log_line("Streaming", "threads", threads, f"fill-{img_channels}c", e - s) def weight_regions_by_scalar( From 07667c7410925b91602bbf4b3a9d504a867c533c Mon Sep 17 00:00:00 2001 From: Paul Tunison Date: Tue, 30 Jan 2024 14:27:25 -0500 Subject: [PATCH 2/2] Fix ReadTheDocs configuration for building Update RTD-specific requirements file --- .readthedocs.yaml | 7 ++++++- docs/readthedocs-reqs.txt | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 6943b8f1..8eb17a10 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,12 +1,17 @@ version: 2 formats: - pdf +build: + os: ubuntu-22.04 + tools: + python: "3.8" + python: - version: 3.8 install: - requirements: docs/readthedocs-reqs.txt - method: pip path: . + sphinx: builder: html configuration: docs/conf.py diff --git a/docs/readthedocs-reqs.txt b/docs/readthedocs-reqs.txt index f05a35a2..48b1dd67 100644 --- a/docs/readthedocs-reqs.txt +++ b/docs/readthedocs-reqs.txt @@ -1,2 +1,3 @@ # Additional requirements for building our documentation in read-the-docs build -sphinx-prompt +sphinx-prompt==1.3.0 +sphinx-rtd-theme==1.2.2