Skip to content

Commit

Permalink
Merge pull request #60 from softwaremill/ref/fix_foxai_names
Browse files Browse the repository at this point in the history
Changing naming to Foxai everywhere
  • Loading branch information
rpytel1 authored Feb 14, 2023
2 parents 9da4963 + 0594040 commit 5cbd591
Show file tree
Hide file tree
Showing 51 changed files with 226 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-module/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ runs:
- name: Run MyPy checks
shell: bash
run: |
poetry run mypy -p autoxai --show-error-context --pretty --namespace-packages --explicit-package-bases --ignore-missing-imports
poetry run mypy -p foxai --show-error-context --pretty --namespace-packages --explicit-package-bases --ignore-missing-imports
working-directory: "${{ inputs.moduleFolder }}"
- name: Run tests
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
POETRY_VERSION: '1.2.1'
PYTHON_VERSION: '3.8'
jobs:
autoxai:
foxai:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/installation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
POETRY_VERSION: '1.2.1'
PYTHON_VERSION: '3.8'
jobs:
autoxai:
foxai:
strategy:
matrix:
CUDA_VERSION: ["10.2"] # "11.0" , "11.4", "11.6"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: echo ::set-output name=VERSION::$(poetry version | cut -d " " -f 2)

- name: Build docs
run: poetry run sphinx-apidoc -o docs/source autoxai && cd docs && poetry run make html
run: poetry run sphinx-apidoc -o docs/source foxai && cd docs && poetry run make html

- name: Compress production artifacts
run: tar -czvf docs/build/foxai-docs-${{ steps.get_version.outputs.VERSION }}.tar.gz docs/build/html/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sphinx_docs_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
poetry install
working-directory: ""
- name: Build docs
run: poetry run sphinx-apidoc -o docs/source autoxai && cd docs && poetry run make html
run: poetry run sphinx-apidoc -o docs/source foxai && cd docs && poetry run make html
- name: Compress production artifacts
run: tar -czvf docs/build/html.tar.gz docs/build/html/
- name: Archive production artifacts
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
- id: mypy
name: mypy
language: system
files: autoxai
files: foxai
types: [ python ]
entry: poetry run mypy
args: ["--ignore-missing-imports"]
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# instead of copy you can fetch repository
# RUN git clone https://github.com/softwaremill/AutoXAI.git && cd AutoXAI/
COPY autoxai/ ./autoxai
COPY foxai/ ./foxai
COPY poetry.lock .
COPY pyproject.toml .
COPY README.md .
Expand All @@ -51,5 +50,5 @@ RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.2.1 python3 -
&& poetry config virtualenvs.in-project true \
&& poetry install --no-root \
&& poetry build
RUN python3 -m pip install dist/autoxai-0.5.3-py3-none-any.whl
RUN python3 -m pip install dist/foxai-0.5.3-py3-none-any.whl
RUN python3 -m pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AutoXAI
# FoXAI

AutoXAI simplifies the application of e**X**plainable **AI** algorithms to explain the
FoXAI simplifies the application of e**X**plainable **AI** algorithms to explain the
performance of neural network models during training. The library acts as an
aggregator of existing libraries with implementations of various XAI algorithms and
seeks to facilitate and popularize their use in machine learning projects.
Expand Down Expand Up @@ -45,21 +45,21 @@ The assumption is that the `poetry` package is installed. You can find how to in
`poetry` [here](#poetry). To build `wheel` package run:

```bash
git clone https://github.com/softwaremill/AutoXAI.git
cd AutoXAI/
git clone https://github.com/softwaremill/FoXAI.git
cd FoXAI/
poetry install
poetry build
```

As a result you will get `wheel` file inside `dist/` directory that you can install
via `pip`:
```bash
pip install dist/autoxai-x.y.z-py3-none-any.whl
pip install dist/foxai-x.y.z-py3-none-any.whl
```

# Getting started

To use the AutoXAI library in your ML project, simply add an additional object of type
To use the FoXAI library in your ML project, simply add an additional object of type
`WandBCallback` to the `Trainer`'s callback list from the `pytorch-lightning` library.
Currently, only the Weights and Biases tool for tracking experiments is supported.

Expand All @@ -71,8 +71,8 @@ from pytorch_lightning import Trainer
from pytorch_lightning.loggers import WandbLogger

import wandb
from autoxai.callbacks.wandb_callback import WandBCallback
from autoxai.context_manager import Explainers, ExplainerWithParams
from foxai.callbacks.wandb_callback import WandBCallback
from foxai.context_manager import Explainers, ExplainerWithParams

...
wandb.login()
Expand Down Expand Up @@ -108,12 +108,12 @@ W&B offline. This tool is using `hydra` to handle the configuration of `yaml` fi
To check options type:

```bash
autoxai-wandb-updater --help
foxai-wandb-updater --help
```

Typical usage with configuration in `config/config.yaml`:
```bash
autoxai-wandb-updater --config-dir config/ --config-name config
foxai-wandb-updater --config-dir config/ --config-name config
```

Content of `config.yaml`:
Expand Down
29 changes: 0 additions & 29 deletions autoxai/explainer/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

sys.path.insert(0, os.path.abspath("../.."))

project = "AutoXAI"
project = "FoXAI"
copyright = "2023, ReasonField Lab" # pylint: disable = (redefined-builtin)
author = "Adam Jan Kaczmarek, Kamil Rzechowski, Adam Wawrzyński"
author = "ReasonField Lab Team"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. AutoXAI documentation master file, created by
.. FoXAI documentation master file, created by
sphinx-quickstart on Thu Jan 5 16:02:36 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to AutoXAI's documentation!
Welcome to FoXAI's documentation!
===================================

.. toctree::
Expand Down
4 changes: 2 additions & 2 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ You can build ``wheel`` with Python package yourself. To do so clone repository

.. code-block:: bash
$ git clone https://github.com/softwaremill/AutoXAI.git
$ cd AutoXAI/
$ git clone https://github.com/softwaremill/FoXAI.git
$ cd FoXAI/
Then setup development environment by installing ``Poetry`` and project dependencies.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
autoxai
foxai
=======

.. toctree::
:maxdepth: 4

autoxai
foxai
4 changes: 2 additions & 2 deletions example/mnist_wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from torchvision.datasets import MNIST

import wandb
from autoxai.callbacks.wandb_callback import WandBCallback
from autoxai.context_manager import Explainers, ExplainerWithParams
from foxai.callbacks.wandb_callback import WandBCallback
from foxai.context_manager import Explainers, ExplainerWithParams


class LitMNIST( # pylint: disable = (abstract-method, too-many-ancestors, too-many-instance-attributes)
Expand Down
45 changes: 24 additions & 21 deletions example/notebooks/basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"from torchvision import transforms\n",
"from torchvision.datasets import MNIST, ImageNet\n",
"\n",
"from autoxai.explainer.base_explainer import CVExplainer\n",
"from autoxai.context_manager import AutoXaiExplainer, ExplainerWithParams, Explainers\n",
"from autoxai.visualizer import mean_channels_visualization, single_channel_visualization\n",
"from foxai.explainer.base_explainer import CVExplainer\n",
"from foxai.context_manager import FoXaiExplainer, ExplainerWithParams, Explainers\n",
"from foxai.visualizer import mean_channels_visualization, single_channel_visualization\n",
"\n",
"from IPython.display import Markdown, display"
]
Expand All @@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Install missing libraries required by `YOLOv5` that are not part of `autoxai` package."
"Install missing libraries required by `YOLOv5` that are not part of `foxai` package."
]
},
{
Expand Down Expand Up @@ -352,7 +352,7 @@
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"from autoxai.array_utils import convert_float_to_uint8\n",
"from foxai.array_utils import convert_standardized_float_to_uint8, standardize_array\n",
"\n",
"counter: int = 0\n",
" \n",
Expand All @@ -364,7 +364,8 @@
" for sample, label in zip(*batch):\n",
" # change image shape from (C X H X W) to (H X W X C)\n",
" # where C stands for colour, X is height and W is width dimension\n",
" sample_np = sample.permute((1, 2, 0)).numpy()\n",
"# sample_np = sample.permute((1, 2, 0)).numpy().astype(float)\n",
" sample_np = sample.permute((1, 2, 0)).numpy().astype(float)\n",
" \n",
" # set title\n",
" axes.flat[counter].set_title(f\"Label: {categories[label.item()]}\")\n",
Expand All @@ -374,7 +375,7 @@
" axes.flat[counter].get_yaxis().set_visible(False)\n",
"\n",
" # convert image from float to uint8 and display it\n",
" axes.flat[counter].imshow(convert_float_to_uint8(sample_np))\n",
" axes.flat[counter].imshow(convert_standardized_float_to_uint8(standardize_array(sample_np.astype(float))))\n",
" counter += 1\n",
"\n",
" if counter >= max_samples_explained:\n",
Expand All @@ -396,18 +397,17 @@
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### Choosing autoxai explainers (general algorithms)"
"### Choosing foxai explainers (general algorithms)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define list of explainers from `autoxai` package You want to use on specified model. Full list of supported explainers can be found at definition of `Explainers` enum class."
"Define list of explainers from `foxai` package You want to use on specified model. Full list of supported explainers can be found at definition of `Explainers` enum class."
]
},
{
Expand All @@ -428,7 +428,6 @@
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
Expand Down Expand Up @@ -463,7 +462,7 @@
" input_data = sample.reshape(1, sample.shape[0], sample.shape[1], sample.shape[2]).to(device)\n",
" category_name = categories[label.item()]\n",
" # move it to specified device\n",
" with AutoXaiExplainer(\n",
" with FoXaiExplainer(\n",
" model=model,\n",
" explainers=explainer_list,\n",
" target=label,\n",
Expand All @@ -478,14 +477,11 @@
" os.makedirs(artifact_explainer_dir)\n",
"\n",
" # create figure from attributes and original image \n",
" figure = mean_channels_visualization(attributions=value[0], transformed_img=sample, title=\"Mean of channels\")\n",
" figure = mean_channels_visualization(attributions=value[0], transformed_img=sample, title= f\"Mean of channels ({key})\")\n",
"\n",
" # save figure to artifact directory\n",
" figure.savefig(os.path.join(artifact_explainer_dir, f\"artifact_{sample_counter}_{category_name}.png\"))\n",
" show_figure(figure)\n",
" for i in range(0, sample.shape[0]):\n",
" figure = single_channel_visualization(attributions=value[0], transformed_img=sample, selected_channel=i, title=f\"Channel: {i}\")\n",
" show_figure(figure)\n",
" \n",
" sample_counter += 1\n",
" # if we processed desired number of samples break the loop\n",
Expand Down Expand Up @@ -533,7 +529,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Choosing autoxai explainers (layer-specific algorithms)"
"### Choosing foxai explainers (layer-specific algorithms)"
]
},
{
Expand Down Expand Up @@ -589,7 +585,7 @@
" # add batch size dimension to the data sample\n",
" input_data = sample.reshape(1, sample.shape[0], sample.shape[1], sample.shape[2]).to(device)\n",
" category_name = categories[label.item()]\n",
" with AutoXaiExplainer(\n",
" with FoXaiExplainer(\n",
" model=model,\n",
" explainers=explainer_list,\n",
" target=label,\n",
Expand All @@ -604,7 +600,7 @@
" os.makedirs(artifact_explainer_dir)\n",
"\n",
" # create figure from attributes and original image \n",
" figure = mean_channels_visualization(attributions=value[0], transformed_img=sample, title=\"Mean of channels\")\n",
" figure = mean_channels_visualization(attributions=value[0], transformed_img=sample, title= f\"Mean of channels ({key})\")\n",
"\n",
" # save figure to artifact directory\n",
" figure.savefig(os.path.join(artifact_explainer_dir, f\"artifact_{sample_counter}_{category_name}.png\"))\n",
Expand Down Expand Up @@ -633,11 +629,18 @@
"source": [
"You have learned to use the basic functionality of the library. You can now experiment and gain confidence in your ML models."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.4 ('.venv': poetry)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -651,7 +654,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.7.13"
},
"vscode": {
"interpreter": {
Expand Down
Loading

0 comments on commit 5cbd591

Please sign in to comment.