You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I mainly use anomalib on Google Colab but it only supports python=3.7 at the moment. There is an error when running the training command: python -m tools.train --model_config_path path/to/config.yaml
The error was:
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/anomalib/tools/train.py", line 66, in <module>
train()
File "/content/anomalib/tools/train.py", line 55, in train
model = get_model(config)
File "/content/anomalib/anomalib/models/__init__.py", line 61, in get_model
module = import_module(f"anomalib.models.{config.model.name}.model")
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/content/anomalib/anomalib/models/stfpm/__init__.py", line 17, in <module>
from .model import ( # noqa # pylint: disable=unused-import
File "/content/anomalib/anomalib/models/stfpm/model.py", line 31, in <module>
from anomalib.data.tiler import Tiler
File "/content/anomalib/anomalib/data/tiler.py", line 19, in <module>
from typing import Optional, Sequence, SupportsIndex, Tuple, Union
ImportError: cannot import name 'SupportsIndex' from 'typing' (/usr/lib/python3.7/typing.py)
Suggestion
AFAIK, SupportsIndex is used for type-hint of classes that have __item__ method, but the default value doesn't seem right and int is better.
After making the below modification:
diff --git a/anomalib/data/tiler.py b/anomalib/data/tiler.py
index 5a274c2..d061337 100644
--- a/anomalib/data/tiler.py
+++ b/anomalib/data/tiler.py
@@ -16,7 +16,7 @@
from itertools import product
from math import ceil
-from typing import Optional, Sequence, SupportsIndex, Tuple, Union
+from typing import Optional, Sequence, Tuple, Union
import torch
import torchvision.transforms as T
@@ -161,7 +161,7 @@ class Tiler:
stride: Union[int, Sequence],
remove_border_count: int = 0,
mode: str = "padding",
- tile_count: SupportsIndex = 4,
+ tile_count: int = 4,
) -> None:
self.tile_size_h, self.tile_size_w = self.__validate_size_type(tile_size)
The code works well.
I did not have further investigation, e.g. checking dependencies, other models, etc; but I think supporting python 3.7 is possible with minimal changes. I ran with the STFMP model.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I mainly use
anomalib
on Google Colab but it only supports python=3.7 at the moment. There is an error when running the training command:python -m tools.train --model_config_path path/to/config.yaml
The error was:
Suggestion
AFAIK,
SupportsIndex
is used for type-hint of classes that have__item__
method, but the default value doesn't seem right andint
is better.After making the below modification:
The code works well.
I did not have further investigation, e.g. checking dependencies, other models, etc; but I think supporting python 3.7 is possible with minimal changes. I ran with the STFMP model.
The text was updated successfully, but these errors were encountered: