Skip to content

Commit

Permalink
📚 Update the installation instructions (#1790)
Browse files Browse the repository at this point in the history
* Update the installation instructions

* Add name arg to Folder

* Update the installation instructions
  • Loading branch information
samet-akcay authored Feb 28, 2024
1 parent 88990e0 commit 2fc5a13
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 5 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,31 @@ Anomalib provides two ways to install the library. The first is through PyPI, an

<details>
<summary>Install from PyPI</summary>
Installing the library with pip is the easiest way to get started with `anomalib`.
Installing the library with pip is the easiest way to get started with anomalib.

```bash
pip install anomalib
```

This will install Anomalib CLI using the [installer](requirements/installer.txt) dependecies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command:

```bash
# Get help for the installation arguments
anomalib install -h

# Install the full package
anomalib install

# Install with verbose output
anomalib install -v

# Install the core package option only to train and evaluate models via Torch and Lightning
anomalib install --option core

# Install with OpenVINO option only. This is useful for edge deployment as the wheel size is smaller.
anomalib install --option openvino
```

</details>

<details>
Expand All @@ -73,6 +92,25 @@ cd anomalib
pip install -e .
```

This will install Anomalib CLI using the [installer](requirements/installer.txt) dependecies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command:

```bash
# Get help for the installation arguments
anomalib install -h

# Install the full package
anomalib install

# Install with verbose output
anomalib install -v

# Install the core package option only to train and evaluate models via Torch and Lightning
anomalib install --option core

# Install with OpenVINO option only. This is useful for edge deployment as the wheel size is smaller.
anomalib install --option openvino
```

</details>

# 🧠 Training
Expand Down
42 changes: 40 additions & 2 deletions docs/source/markdown/get_started/anomalib.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ This section will walk you through the steps to train a model and use it to dete

Installation is simple and can be done in two ways. The first is through PyPI, and the second is through a local installation. PyPI installation is recommended if you want to use the library without making any changes to the source code. If you want to make changes to the library, then a local installation is recommended.

:::::{dropdown} Installing the Installer
:open:

Anomalib comes with a CLI installer that can be used to install the full package.
The installer can be installed using the following commands:

::::{tab-set}

:::{tab-item} PyPI
:::{tab-item} API
:sync: label-1

```{literalinclude} ../../snippets/install/pypi.txt
:language: bash
Expand All @@ -17,14 +24,45 @@ Installation is simple and can be done in two ways. The first is through PyPI, a
:::

:::{tab-item} Source
:sync: label-2

```{literalinclude} ../../snippets/install/source.txt
:language: bash
```

:::

::::
The main reason why PyPI and source installer does not install the full package
is to keep the installation wheel small. The CLI installer also automates the
installation such as finding the torch version with the right CUDA/CUDNN version.

The next section demonstrates how to install the full package using the CLI installer.
:::::

:::::{dropdown} Installing the Full Package
After installing anomalib, you can install the full package using the following commands:

```{literalinclude} ../../snippets/install/anomalib_help.txt
:language: bash
```

As can be seen above, the only available sub-command is `install` at the moment.
The `install` sub-command has options to install either the full package or the
specific components of the package.

```{literalinclude} ../../snippets/install/anomalib_install_help.txt
:language: bash
```

By default the `install` sub-command installs the full package. If you want to
install only the specific components of the package, you can use the `--option` flag.

```{literalinclude} ../../snippets/install/anomalib_install.txt
:language: bash
```

After following these steps, your environment will be ready to use anomalib!
:::::

## {octicon}`mortar-board` Training

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from anomalib.data import Folder

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/hazelnut_toy",
normal_dir="good",
abnormal_dir="crack",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from anomalib.data.utils import TestSplitMode, ValSplitMode

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/hazelnut_toy",
normal_dir="good",
val_split_mode=ValSplitMode.NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from anomalib.data.utils import TestSplitMode

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/hazelnut_toy",
normal_dir="good",
test_split_mode=TestSplitMode.SYNTHETIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from anomalib.data import Folder

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/hazelnut_toy",
normal_dir="good",
abnormal_dir="crack",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from anomalib.data.utils import TestSplitMode, ValSplitMode

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/MVTec/transistor",
normal_dir="train/good",
val_split_mode=ValSplitMode.NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from anomalib.data.utils import TestSplitMode

# Create the datamodule
datamodule = Folder(
name="hazelnut_toy",
root="datasets/hazelnut_toy",
normal_dir="good",
test_split_mode=TestSplitMode.SYNTHETIC,
Expand Down
26 changes: 26 additions & 0 deletions docs/source/snippets/install/anomalib_help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
❯ anomalib -h
To use other subcommand using `anomalib install`
To use any logger install it using `anomalib install -v`
╭─ Arguments ───────────────────────────────────────────────────────────────────╮
│ Usage: anomalib [-h] [-c CONFIG] [--print_config [=flags]] {install} ... │
│ │
│ │
│ Options: │
│ -h, --help Show this help message and exit. │
│ -c, --config CONFIG Path to a configuration file in json or yaml format. │
│ --print_config [=flags] │
│ Print the configuration after applying all other │
│ arguments and exit. The optional flags customizes the │
│ output and are one or more keywords separated b comma.│
│ The supported flags are: comments, skip_default, │
│ skip_null. │
│ │
│ Subcommands: │
│ For more details of each subcommand, add it as an argument followed by │
│ --help. │
│ │
│ │
│ Available subcommands: │
│ install Install the full-package for anomalib. │
│ │
╰───────────────────────────────────────────────────────────────────────────────╯
14 changes: 14 additions & 0 deletions docs/source/snippets/install/anomalib_install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Get help for the installation arguments
anomalib install -h

# Install the full package
anomalib install

# Install with verbose output
anomalib install -v

# Install the core package option only to train and evaluate models via Torch and Lightning
anomalib install --option core

# Install with OpenVINO option only. This is useful for edge deployment as the wheel size is smaller.
anomalib install --option openvino
17 changes: 17 additions & 0 deletions docs/source/snippets/install/anomalib_install_help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
❯ anomalib install -h
To use other subcommand using `anomalib install`
To use any logger install it using `anomalib install -v`
╭─ Arguments ───────────────────────────────────────────────────────────────────╮
│ Usage: anomalib [options] install [-h] │
│ [--option {full,core,dev,loggers,notebooks,openvino}] │
│ [-v] │
│ │
│ │
│ Options: │
│ -h, --help Show this help message and exit. │
│ --option {full,core,dev,loggers,notebooks,openvino} │
│ Install the full or optional-dependencies. │
│ (type: None, default: full) │
│ -v, --verbose Set Logger level to INFO (default: False) │
│ │
╰───────────────────────────────────────────────────────────────────────────────╯
6 changes: 4 additions & 2 deletions notebooks/000_getting_started/001_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"outputs": [],
"source": [
"# Option - I: Uncomment the next line if you want to install via pip.\n",
"# %pip install anomalib"
"# %pip install anomalib\n",
"# %anomalib install -v"
]
},
{
Expand All @@ -82,7 +83,8 @@
"# Option - II: Uncomment the next three lines if you want to install from the source.\n",
"# !git clone https://github.com/openvinotoolkit/anomalib.git\n",
"# %cd anomalib\n",
"# %pip install ."
"# %pip install .\n",
"# %anomalib install -v"
]
},
{
Expand Down

0 comments on commit 2fc5a13

Please sign in to comment.