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

Fix installing package from wheel, rename package #6

Merged
merged 10 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
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
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: src
files: autoxai
types: [ python ]
entry: poetry run mypy
- id: locks
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

The project was tested using Python version `3.8`.

## CUDA

Recommended version of CUDA is `10.2` as it is supported since version
`1.5.0` of `torch`. You can check compatilibity of Your CUDA version
with current version of `torch`:
https://pytorch.org/get-started/previous-versions/.

## Poetry

To separate runtime environments for different services and repositories, it is
Expand Down Expand Up @@ -34,6 +41,34 @@ Once all the steps have been completed, the environment is ready to go.
Virtual environment by default will be created with name `.venv` inside
project directory.

## pyenv

`pyenv` is a tool used to manage multiple version of Python. To install
this package follow instructions on project repository page:
https://github.com/pyenv/pyenv#installation. After installation You can
install desired Python version, e.g. `3.8.16`:
```bash
pyenv install 3.8.16
```

The next step is required to be able to use desired version of Python with
`poetry`. To activate specific version of Python interpreter execute command:
```bash
pyenv local 3.8.16 # or `pyenv global 3.8.16`
```

Inside repository with `poetry` You can select specific version of Python
interpreter with command:
```bash
poetry env use 3.8.16
```

After changing interpreter version You have to once again install all
dependencies:
```bash
poetry install
```

### Installation errors

If You encounter errors during dependencies installation You can disable
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/callback.py → autoxai/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import pytorch_lightning as pl
import torch

from src.cache_manager import LocalDirCacheManager
from src.path_manager import ExperimentDataClass
from autoxai.cache_manager import LocalDirCacheManager
from autoxai.path_manager import ExperimentDataClass

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/explainer/gradcam.py → autoxai/explainer/gradcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import torch
from captum.attr import GuidedGradCam, LayerGradCam

from src.explainer.model_utils import modify_modules
from src.explainer.occulusion import CVExplainer
from autoxai.explainer.model_utils import modify_modules
from autoxai.explainer.occulusion import CVExplainer


class BaseGradCAMCVExplainer(CVExplainer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from captum.attr import GradientShap, LayerGradientShap

from src.explainer.base_explainer import CVExplainer
from autoxai.explainer.base_explainer import CVExplainer


class BaseGradientSHAPCVExplainer(CVExplainer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from captum.attr import IntegratedGradients, LayerIntegratedGradients

from src.explainer.base_explainer import CVExplainer
from autoxai.explainer.base_explainer import CVExplainer


class BaseIntegratedGradientsCVExplainer(CVExplainer):
Expand Down
4 changes: 2 additions & 2 deletions src/explainer/lrp.py → autoxai/explainer/lrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import torch
from captum.attr import LRP, LayerLRP

from src.explainer.base_explainer import CVExplainer
from src.explainer.model_utils import modify_modules
from autoxai.explainer.base_explainer import CVExplainer
from autoxai.explainer.model_utils import modify_modules


class BaseLRPCVExplainer(CVExplainer):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from captum.attr import IntegratedGradients, LayerIntegratedGradients, NoiseTunnel

from src.explainer.occulusion import CVExplainer
from autoxai.explainer.occulusion import CVExplainer


class BaseNoiseTunnelCVExplainer(CVExplainer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch
from captum.attr import Occlusion

from src.explainer.base_explainer import CVExplainer
from autoxai.explainer.base_explainer import CVExplainer


class OcculusionCVExplainer(CVExplainer):
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions example/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from pytorch_lightning.callbacks.progress import TQDMProgressBar
from streamlit_app.mnist_model import LitMNIST

from src.cache_manager import LocalDirCacheManager
from src.callback import CustomPytorchLightningCallback
from src.path_manager import ExperimentDataClass
from autoxai.cache_manager import LocalDirCacheManager
from autoxai.callback import CustomPytorchLightningCallback
from autoxai.path_manager import ExperimentDataClass


def main() -> None: # pylint: disable = (duplicate-code)
Expand All @@ -35,7 +35,7 @@ def main() -> None: # pylint: disable = (duplicate-code)

model = LitMNIST(data_dir=data_dir, batch_size=batch_size)
trainer = Trainer(
accelerator="auto",
accelerator="gpu",
devices=1 if torch.cuda.is_available() else None,
max_epochs=max_epochs,
callbacks=[TQDMProgressBar(refresh_rate=20), callback],
Expand Down
4 changes: 2 additions & 2 deletions example/offline_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import torchvision
from PIL import Image

from src.cache_manager import LocalDirCacheManager
from src.path_manager import ExperimentDataClass
from autoxai.cache_manager import LocalDirCacheManager
from autoxai.path_manager import ExperimentDataClass


class DataTransformer: # pylint: disable = (too-few-public-methods)
Expand Down
12 changes: 6 additions & 6 deletions example/streamlit_app/method_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
from enum import Enum
from typing import Optional

from src.explainer.gradcam import GuidedGradCAMCVExplainer, LayerGradCAMCVExplainer
from src.explainer.gradient_shap import (
from autoxai.explainer.gradcam import GuidedGradCAMCVExplainer, LayerGradCAMCVExplainer
from autoxai.explainer.gradient_shap import (
GradientSHAPCVExplainer,
LayerGradientSHAPCVExplainer,
)
from src.explainer.integrated_gradients import (
from autoxai.explainer.integrated_gradients import (
IntegratedGradientsCVExplainer,
LayerIntegratedGradientsCVExplainer,
)
from src.explainer.lrp import LayerLRPCVExplainer, LRPCVExplainer
from src.explainer.noise_tunnel import (
from autoxai.explainer.lrp import LayerLRPCVExplainer, LRPCVExplainer
from autoxai.explainer.noise_tunnel import (
LayerNoiseTunnelCVExplainer,
NoiseTunnelCVExplainer,
)
from src.explainer.occulusion import OcculusionCVExplainer
from autoxai.explainer.occulusion import OcculusionCVExplainer


class MethodName(Enum):
Expand Down
4 changes: 2 additions & 2 deletions example/streamlit_app/mnist_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from torchvision.datasets import MNIST


class LitMNIST(
class LitMNIST( # pylint: disable = (abstract-method, too-many-ancestors, too-many-instance-attributes)
LightningModule
): # pylint: disable = (too-many-ancestors, too-many-instance-attributes)
):
"""Model to classify MNIST images."""

def __init__(
Expand Down
14 changes: 7 additions & 7 deletions example/streamlit_app/run_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
convert_figure_to_numpy,
)

from src.explainer.base_explainer import CVExplainer
from src.explainer.gradcam import GuidedGradCAMCVExplainer, LayerGradCAMCVExplainer
from src.explainer.gradient_shap import (
from autoxai.explainer.base_explainer import CVExplainer
from autoxai.explainer.gradcam import GuidedGradCAMCVExplainer, LayerGradCAMCVExplainer
from autoxai.explainer.gradient_shap import (
GradientSHAPCVExplainer,
LayerGradientSHAPCVExplainer,
)
from src.explainer.integrated_gradients import (
from autoxai.explainer.integrated_gradients import (
IntegratedGradientsCVExplainer,
LayerIntegratedGradientsCVExplainer,
)
from src.explainer.lrp import LayerLRPCVExplainer, LRPCVExplainer
from src.explainer.noise_tunnel import (
from autoxai.explainer.lrp import LayerLRPCVExplainer, LRPCVExplainer
from autoxai.explainer.noise_tunnel import (
LayerNoiseTunnelCVExplainer,
NoiseTunnelCVExplainer,
)
from src.explainer.occulusion import OcculusionCVExplainer
from autoxai.explainer.occulusion import OcculusionCVExplainer

cache_path = os.environ.get("LOGDIR", "logs")

Expand Down
2 changes: 1 addition & 1 deletion example/streamlit_app/streamlit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch
from settings import Settings # pylint: disable = (import-error)

from src.cache_manager import LocalDirCacheManager
from autoxai.cache_manager import LocalDirCacheManager


def load_subdir(path: str) -> Union[Dict[str, Any], List[str]]:
Expand Down
2 changes: 1 addition & 1 deletion example/streamlit_app/visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas

from src.explainer.base_explainer import CVExplainer
from autoxai.explainer.base_explainer import CVExplainer


def convert_figure_to_numpy(figure: matplotlib.pyplot.Figure) -> np.ndarray:
Expand Down
Loading