Skip to content

Commit

Permalink
Fixed a couple sonarcloud issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrichardwebster committed Oct 28, 2024
1 parent 4a43e2b commit 1dd078c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1,001 deletions.
12 changes: 6 additions & 6 deletions examples/ModelComparisonWithSaliency.ipynb

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions examples/SerializedDetectionSaliency.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
}
],
"source": [
"import sys\n",
"\n",
"!{sys.executable} -m pip install -qU pip\n",
"print(\"Installing xaitk-saliency...\")\n",
"!{sys.executable} -m pip install -q xaitk-saliency[tools]\n",
Expand Down Expand Up @@ -401,7 +399,7 @@
"\n",
" bbox = dets_dset.anns[detection_id][\"bbox\"]\n",
" plt.gca().add_patch(Rectangle((bbox[0], bbox[1]), bbox[2], bbox[3], linewidth=1, edgecolor=\"r\", facecolor=\"none\"))\n",
" plt.imshow(sal_maps_results[detection_id], cmap=\"jet\", alpha=0.3)\n",
" plt.imshow(sal_maps_results[det_id], cmap=\"jet\", alpha=0.3)\n",
"\n",
"\n",
"plot_saliency_map(detection_id)"
Expand Down
989 changes: 8 additions & 981 deletions examples/covid_classification.ipynb

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions src/xaitk_saliency/utils/bin/sal_on_coco_dets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
is_usable = False


def _generate_config_file(generate_config_file: TextIO):
"""
An internal function that generates a config and dumps it out to the provided path.
:param generate_config_file: File to write default config file, only written
if specified.
This skips the normal operation of this tool and only outputs the file.
"""
if generate_config_file:
config = {}

config["DetectImageObjects"] = make_default_config(DetectImageObjects.get_impls())
config["GenerateObjectDetectorBlackboxSaliency"] = make_default_config(
GenerateObjectDetectorBlackboxSaliency.get_impls(),
)

json.dump(config, generate_config_file, indent=4)

exit()

@click.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("coco_file", type=click.Path(exists=True))
@click.argument("output_dir", type=click.Path(exists=False))
Expand Down Expand Up @@ -69,17 +89,7 @@ def sal_on_coco_dets(
:param verbose: Display progress messages. Default is false.
"""

if generate_config_file:
config = {}

config["DetectImageObjects"] = make_default_config(DetectImageObjects.get_impls())
config["GenerateObjectDetectorBlackboxSaliency"] = make_default_config(
GenerateObjectDetectorBlackboxSaliency.get_impls(),
)

json.dump(config, generate_config_file, indent=4)

exit()
_generate_config_file(generate_config_file)

if not is_usable:
print("This tool requires additional dependencies, please install 'xaitk-saliency[tools]'")
Expand Down

0 comments on commit 1dd078c

Please sign in to comment.