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

[Bug]: ValueError: Not possible to determine the import path for object typing.Iterable[pytorch_lightning.loggers.logger.Logger]. #2198

Open joehays opened 2 months ago

joehays commented 2 months ago

Describe the bug

Brand new user here. I was trying to follow: https://anomalib.readthedocs.io/en/latest/markdown/get_started/anomalib.html

I'm getting the following error when I run anomalib fit -h:

raise ValueError(f"Not possible to determine the import path for object {value}.")
ValueError: Not possible to determine the import path for object typing.Iterable[pytorch_lightning.loggers.logger.Logger].

Dataset

N/A

Model

N/A

Steps to reproduce the behavior

OS information

OS information:

Expected behavior

Same as what the getting started shows.

Screenshots

~/dev/anomalib$ anomalib -h
usage: anomalib [-h] [-c CONFIG] [--print_config[=flags]] {fit,validate,test,predict,tune} ...

pytorch-lightning trainer command line tool

optional arguments:
  -h, --help            Show this help message and exit.
  -c CONFIG, --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 by 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:
    fit                 Runs the full optimization routine.
    validate            Perform one evaluation epoch over the validation set.
    test                Perform one evaluation epoch over the test set.
    predict             Run inference on your data.
    tune                Runs routines to tune hyperparameters before training.

Does not include the install option

Pip/GitHub

pip

What version/branch did you use?

No response

Configuration YAML

just following the getting started. I have not learned about configuration files yet.

Logs

?

Code of Conduct

samet-akcay commented 2 months ago

Hi @joehays, I see that you are using python 3.8. Can you use 3.10+? With pyenv you could run the following:

pyenv install 3.11
pyenv virtualenv 3.11 anomalib
pyenv local anomalib

pip install anomalib
anomalib -h
anomalib fit -h
joehays commented 2 months ago

@samet-akcay That helped get passed the initial problem but now I get the following error when I run CUDA_HOME=/usr/local/cuda-12.0 anomalib install,

$ CUDA_HOME=/usr/local/cuda-12.0/ anomalib install
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 any logger install it using `anomalib install -v`
/home/joehays/.pyenv/versions/3.11.1/envs/anomalib2/lib/python3.11/site-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)
[13:52:14] Installation list: ['ipywidgets', 'gradio>=4', 'pre-commit',                          install.py:73
           'sphinx-autodoc-typehints', 'docstring-parser', 'rich>=13.5.2', 'einops>=0.3.2',
           'sphinx-copybutton', 'myst-parser', 'jsonargparse>=4.27.7', 'freia>=0.2',
           'omegaconf>=2.1.1', 'imgaug==0.4.0', 'pytest-sugar', 'lightning>=2.2', 'pandoc',
           'pytest', 'openvino>=2024.0', 'gitpython', 'tox', 'pytest-cov', 'matplotlib>=3.4.3',
           'ipykernel', 'coverage', 'opencv-python>=4.5.3.56', 'timm<=1.0.3,>=0.5.4',
           'torchmetrics>=1.3.2', 'nncf>=2.10.0', 'pytest-xdist', 'pytest-mock', 'onnx>=1.16.0',
           'anomalib', 'anomalib', 'sphinx-book-theme', 'av>=10.0.0', 'wandb<=0.15.9,>=0.12.17',
           'sphinx<8.0', 'comet-ml>=3.31.7', 'rich-argparse', 'pandas>=1.1.0', 'sphinx-design',
           'tensorboard', 'nbsphinx', 'kornia>=0.6.6', 'mlflow>=1.0.0',
           'open-clip-torch>=2.23.0', 'notebook', '--extra-index-url',
           'https://download.pytorch.org/whl/cu120', 'torch>=2+cu120', 'torchvision>=0.16.2']
[07/19/24 13:52:14] Invalid requirement: 'torch>=2+cu120': Local version label can only be used with `==` or
                    `!=` operators
                        torch>=2+cu120
                             ~~~^
⠹ Installing packages...  This may take a few minutes.
ERROR: Invalid requirement: 'torch>=2+cu120': Local version label can only be used with `==` or `!=` operators
    torch>=2+cu120

I'm now using python 3.11.1

Thoughts?

samet-akcay commented 2 months ago

Looks like the duplicate of https://github.com/openvinotoolkit/anomalib/issues/2156. You could fix this issue by either

joehays commented 2 months ago

@samet-akcay Downgrading pip to 24.0 does infact get past that bug. The anomalib install command now runs and completes successfully. Now, I expect anomalib -h to show other options aside from install but it doesn't. It gives an error,

Could not find anomalib. To use this feature, ensure that you have anomalib installed.

but pip freeze shows anomalib installed, the installation claimed to be complete/successful but it's acting as if it isn't.

I've duplicated this problem in two different virtual environments: one installed from source, and one from PIP.

Didn't find any ISSUES similar to this problem.