Skip to content

Commit

Permalink
Merge pull request #170 from XAITK/update-to-v0.11.0
Browse files Browse the repository at this point in the history
Update to v0.11.0
  • Loading branch information
bjrichardwebster authored Jan 12, 2025
2 parents 0355523 + 7ae10e3 commit bbeb475
Show file tree
Hide file tree
Showing 61 changed files with 2,054 additions and 506 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-stage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
- name: Setup Poetry
run: |
pip install --root-user-action=ignore --upgrade pip -q
pip install --root-user-action=ignore --user -U poetry -q
pip install --root-user-action=ignore --user -U "poetry<2.0" -q
shell: bash
- name: Configure Poetry
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include:
file: ".gitlab-ci.yml"

# job overrides specific to this repo
- local: .gitlab-ci/.gitlab-build.yml
- local: .gitlab-ci/.gitlab-docs.yml
- local: .gitlab-ci/.gitlab-test.yml
- local: .gitlab-ci/.gitlab-security.yml
13 changes: 0 additions & 13 deletions .gitlab-ci/.gitlab-build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
- pip install "poetry<2.0"
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ Ensure the source tree is acquired locally before proceeding.

To install the current version via `pip`:
```bash
pip install xaitk-saliency
pip install xaitk-saliency[<extra1>,<extra2>,...]
```

Alternatively, you can use [Poetry](https://python-poetry.org/):
```bash
poetry install
poetry install --with main,linting,tests,docs --extras "<extra1> <extra2> ..."
```

Certain plugins may require additional runtime dependencies. Details on these requirements can be found [here](https://xaitk-saliency.readthedocs.io/en/latest/implementations.html).
Expand All @@ -72,7 +72,7 @@ Documentation for both release snapshots and the latest master branch is availab
To build the Sphinx-based documentation locally for the latest reference:
```bash
# Install dependencies
poetry install --sync --with linting,tests,docs
poetry install --sync --with main,linting,tests,docs
# Navigate to the documentation root
cd docs
# Build the documentation
Expand All @@ -91,7 +91,7 @@ Pre-commit hooks ensure that code complies with required linting and formatting
To install and use pre-commit hooks:
```bash
# Install required dependencies
poetry install --sync --with linting,tests,docs
poetry install --sync --with main,linting,tests,docs
# Initialize pre-commit hooks for the repository
poetry run pre-commit install
# Run pre-commit checks on all files
Expand Down Expand Up @@ -127,7 +127,10 @@ All development prior to Nov 19, 2024 falls under [BSD-3-Clause](./LICENSE.old)
## Contacts

**Principal Investigator**: Brian Hu (Kitware) @brian.hu

**Product Owner**: Austin Whitesell (MITRE) @awhitesell

**Scrum Master / Tech Lead**: Brandon RichardWebster (Kitware) @b.richardwebster

**Deputy Tech Lead**: Emily Veenhuis (Kitware) @emily.veenhuis
<!-- :auto contacts: -->
1 change: 1 addition & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Release Notes
release_notes/v0.9.1
release_notes/v0.9.2
release_notes/v0.10.0
release_notes/v0.11.0
15 changes: 15 additions & 0 deletions docs/release_notes/v0.11.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
v0.11.0
=======

Improved linting, formating, and dependency management.

Updates / New Features
----------------------

CI/CD

* Updated and applied ruff configuration.


Fixes
-----
8 changes: 7 additions & 1 deletion examples/DRISE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
" sal_map_generator: GenerateObjectDetectorBlackboxSaliency,\n",
" fill: Optional[Union[int, Sequence[int]]] = None,\n",
") -> None:\n",
" \"\"\"Helper to generate and visualize saliency maps\"\"\"\n",
" # Load the image\n",
" ref_image = np.asarray(PIL.Image.open(image_filepath))\n",
"\n",
Expand Down Expand Up @@ -361,6 +362,11 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -371,7 +377,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
54 changes: 37 additions & 17 deletions examples/MNIST_scikit_saliency.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"cell_type": "markdown",
"id": "c44e6e20",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
Expand Down Expand Up @@ -124,9 +123,7 @@
"X = X / X.max()\n",
"\n",
"# Find examples of each class\n",
"ref_inds = []\n",
"for i in range(10):\n",
" ref_inds.append(np.where(np.int64(y) == i)[0][0])\n",
"ref_inds = [np.nonzero(np.int64(y) == i)[0][0] for i in range(10)]\n",
"\n",
"ref_imgs = X[ref_inds]\n",
"\n",
Expand Down Expand Up @@ -162,7 +159,11 @@
"metadata": {},
"outputs": [],
"source": [
"from collections.abc import Iterable, Sequence\n",
"from typing import Any\n",
"\n",
"from smqtk_classifier import ClassifyImage\n",
"from typing_extensions import override\n",
"\n",
"from xaitk_saliency import GenerateImageClassifierBlackboxSaliency\n",
"\n",
Expand All @@ -172,6 +173,7 @@
" image_classifier: ClassifyImage,\n",
" saliency_generator: GenerateImageClassifierBlackboxSaliency,\n",
") -> None:\n",
" \"\"\"Helper to generate and visualize saliency maps\"\"\"\n",
" # Generate saliency maps\n",
" sal_maps_set = []\n",
" for img in images:\n",
Expand Down Expand Up @@ -301,7 +303,6 @@
"cell_type": "markdown",
"id": "e6d18472",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
Expand All @@ -318,18 +319,25 @@
"outputs": [],
"source": [
"class MNISTClassifierLog(ClassifyImage):\n",
" def get_labels(self):\n",
" \"\"\"ClassifyImage wrapper for LogisticRegression\"\"\"\n",
"\n",
" @override\n",
" def get_labels(self) -> Sequence[int]:\n",
" \"\"\"Return class labels\"\"\"\n",
" return list(range(10))\n",
"\n",
" def classify_images(self, image_iter):\n",
" @override\n",
" def classify_images(self, image_iter: Iterable[np.ndarray]) -> Sequence[dict[str, Any]]:\n",
" \"\"\"Generate predictions\"\"\"\n",
" # Yes, \"images\" in this example case are really 1-dim (28*28=784).\n",
" # MLP input needs a (n_samples, n_features) matrix input.\n",
" images = np.asarray(list(image_iter)) # may fail because input is not consistent in shape\n",
" images = images.reshape(-1, 28 * 28) # may fail because input was not the correct shape\n",
" return (dict(zip(range(10), p)) for p in clf.decision_function(images))\n",
"\n",
" # Required for implementation\n",
" def get_config(self):\n",
" @override\n",
" def get_config(self) -> dict[str, Any]:\n",
" \"\"\"Required for implementation\"\"\"\n",
" return {}\n",
"\n",
"\n",
Expand All @@ -355,7 +363,7 @@
"source": [
"from xaitk_saliency.impls.gen_image_classifier_blackbox_sal.slidingwindow import SlidingWindowStack\n",
"\n",
"gen_slidingWindow = SlidingWindowStack(window_size=(2, 2), stride=(1, 1), threads=4)"
"gen_sliding_window = SlidingWindowStack(window_size=(2, 2), stride=(1, 1), threads=4)"
]
},
{
Expand Down Expand Up @@ -405,7 +413,7 @@
}
],
"source": [
"app(X[0:20], image_classifier_log, gen_slidingWindow)"
"app(X[0:20], image_classifier_log, gen_sliding_window)"
]
},
{
Expand Down Expand Up @@ -494,18 +502,25 @@
"outputs": [],
"source": [
"class MNISTClassifierMLP(ClassifyImage):\n",
" def get_labels(self):\n",
" \"\"\"ClassifyImage wrapper for MLPClassifier\"\"\"\n",
"\n",
" @override\n",
" def get_labels(self) -> Sequence[int]:\n",
" \"\"\"Return class labels\"\"\"\n",
" return list(range(10))\n",
"\n",
" def classify_images(self, image_iter):\n",
" @override\n",
" def classify_images(self, image_iter: Iterable[np.ndarray]) -> Sequence[dict[str, Any]]:\n",
" \"\"\"Generate predictions\"\"\"\n",
" # Yes, \"images\" in this example case are really 1-dim (28*28=784).\n",
" # MLP input needs a (n_samples, n_features) matrix input.\n",
" images = np.asarray(list(image_iter)) # may fail because input is not consistent in shape\n",
" images = images.reshape(-1, 28 * 28) # may fail because input was not the correct shape\n",
" return (dict(zip(range(10), p)) for p in mlp.predict_proba(images))\n",
"\n",
" # Required for implementation\n",
" def get_config(self):\n",
" @override\n",
" def get_config(self) -> dict[str, Any]:\n",
" \"\"\"Required for implementation\"\"\"\n",
" return {}\n",
"\n",
"\n",
Expand Down Expand Up @@ -552,11 +567,16 @@
}
],
"source": [
"app(X[0:20], image_classifier_mlp, gen_slidingWindow)"
"app(X[0:20], image_classifier_mlp, gen_sliding_window)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -567,7 +587,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit bbeb475

Please sign in to comment.