openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
https://anomalib.readthedocs.io/en/latest/
Apache License 2.0
3.68k stars 653 forks source link

[Task]: Installation guide and Getting started notebook discrepancies #1792

Closed Issa-Bqain closed 7 months ago

Issa-Bqain commented 7 months ago

What is the motivation for this task?

Please correct me if I am wrong but I believe the getting started notebook here may provide an incorrect installation guide.

1) The guide provides installation through PyPI or from source. Installation from source provides anomallib v1.0.0.dev0 and installation through PyPI provides anomalib v0.7.0.

As a result, the subsequent package imports immediately proceeding the library installation provided in the notebook will not work and therefore new users following this guide can no longer proceed to learn how to use the anomalib library:

from anomalib import TaskType
from anomalib.data import MVTec
from anomalib.data.utils import read_image
from anomalib.deploy import ExportType, OpenVINOInferencer
from anomalib.engine import Engine
from anomalib.models import Padim

For example,

TaskType is no longer a class in the init file of src/anomalib in version 0.7.0 and as a result from anomalib import TaskType yields: ImportError: cannot import name 'TaskType' from 'anomalib'

Same issue happens with from anomalib.deploy import ExportType, OpenVINOInferencer which yields

  File "c:\....\anomalib/test.py", line 3, in <module>
    from anomalib.deploy import ExportType, OpenVINOInferencer
  File "C:\....\anomalib\deploy\__init__.py", line 6, in <module>
    from .export import ExportMode, export, get_metadata, get_model_metadata
  File "C:\....\anomalib\deploy\export.py", line 23, in <module>
    from anomalib.models.components import AnomalyModule
  File "C:\....\anomalib\models\__init__.py", line 33, in <module>
    from anomalib.models.uflow import Uflow
  File "C:\....\anomalib\models\uflow\__init__.py", line 6, in <module>
    from .lightning_model import Uflow, UflowLightning
  File "C:\....\anomalib\models\uflow\lightning_model.py", line 19, in <module>
    from anomalib.models.uflow.torch_model import UflowModel
  File "C:\....\anomalib\models\uflow\torch_model.py", line 43, in <module>
    class UflowModel(nn.Module):
  File "C:\....\anomalib\models\uflow\torch_model.py", line 46, in UflowModel
    input_size: tuple[int, int] = (448, 448),
TypeError: 'type' object is not subscriptable

**The package imports in the notebook do not work with anomalib v.0.7.0 OR anomalib v1.0.0.dev0, which version was this notebook written for?**

Describe the solution you'd like

It would be great for all new users of this library, such as myself, if this could please be updated as new users will not be familiar with these classes and their locations.

It may be prudent to change the install guide to a fixed version which works with the notebook provided. The link to install instruction here is broken.

Additional context

No response

Fan1fei commented 7 months ago

I'm also having the same issue that NO module named 'lighting'

samet-akcay commented 7 months ago

I'm also having the same issue that NO module named 'lighting'

@Fan1fei if you follow the following instructions it should install ligthning

git clone https://github.com/openvinotoolkit/anomalib.git
cd anomalib
pip install -e .
anomalib install -v
samet-akcay commented 7 months ago

This issue is now complete as the version is pushed to pypi https://github.com/openvinotoolkit/anomalib/pull/1799

krupeshp commented 2 months ago

To use other subcommand using anomalib install Could not find anomalib. To use this feature, ensure that you have anomalib installed. Could not find openvino. To use this feature, ensure that you have openvino installed. To use comet logger install it using pip install comet-ml To use any logger install it using anomalib install -v /usr/local/lib/python3.10/dist-packages/anomalib/cli/install.py:63: UserWarning: Torch Version will be selected as 2.2.0. torch_install_args = get_torch_install_args(torch_requirement) /usr/local/lib/python3.10/dist-packages/anomalib/cli/utils/installation.py:271: UserWarning: Installed CUDA version is v12.2. v11.8 <= Supported CUDA version <= v12.1. This script will use CUDA v12.1. However, this may not be safe, and you are advised to install the correct version of CUDA. For more details, refer to https://pytorch.org/get-started/locally/ cuda_version = update_cuda_version_with_available_torch_cuda_build(cuda_version, torch_version) ⠋ Installing packages... This may take a few minutes.

[11:21:44] Installation list: ['gitpython', 'anomalib', 'tox', 'timm<=1.0.7,>=1.0.7',

Same issue. This issue occurring in the google colab. It shows these logs and shell completes running. In both scenarios using pip and from source. %anomalib doesn't work as I use !anomalib install -v. Still having same problem. @samet-akcay