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

🐞 Can't run the 'getting_started' notebook #1688

Closed
1 task done
Abecadarian opened this issue Jan 28, 2024 · 3 comments · Fixed by #1797
Closed
1 task done

🐞 Can't run the 'getting_started' notebook #1688

Abecadarian opened this issue Jan 28, 2024 · 3 comments · Fixed by #1797
Labels
Bug Something isn't working

Comments

@Abecadarian
Copy link

Describe the bug

I've just started learning how to use anomalib and tried to run the '001_getting_started' notebook. It's completely impossible.

When I try to run it in Colab, I get a bunch of errors:

datamodule = MVTec('sample_data')
datamodule.prepare_data()  # Downloads the dataset if it's not in the specified `root` directory
datamodule.setup()  # Create train/val/test/prediction sets.

i, data = next(enumerate(datamodule.val_dataloader()))
print(data.keys())

mvtec: 5.26GB [04:23, 20.0MB/s]

ValueError Traceback (most recent call last)
in <cell line: 3>()
1 datamodule = MVTec('sample_data')
2 datamodule.prepare_data() # Downloads the dataset if it's not in the specified root directory
----> 3 datamodule.setup() # Create train/val/test/prediction sets.
4
5 i, data = next(enumerate(datamodule.val_dataloader()))

5 frames
/usr/local/lib/python3.10/dist-packages/anomalib/data/utils/path.py in validate_path(path, base_dir, should_exist)
215 if not str(path).startswith(str(base_dir)):
216 msg = "Access denied: Path is outside the allowed directory"
--> 217 raise ValueError(msg)
218
219 # In case path should_exist, the path is valid, and should be

ValueError: Access denied: Path is outside the allowed directory

I tried to run it locally on my computer instead, and that ran into more errors - when I tried to install anomalib using pypi, several of the modules couldn't be found:

ImportError: cannot import name 'ExportType' from 'anomalib.deploy'

And it couldn't load the MVTec dataset:

TypeError: MVTec.init() missing 2 required positional arguments: 'root' and 'category'

When I tried to install anomalib from source, I got this error:

ModuleNotFoundError: No module named 'openvino.tools.mo'

Dataset

MVTec

Model

PADiM

Steps to reproduce the behavior

N/A

OS information

N/A

Expected behavior

N/A

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

No response

Configuration YAML

N/A

Logs

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct
@NilsB98
Copy link

NilsB98 commented Jan 29, 2024

Hi @Abecadarian,

I tried it out myself and indeed there are some complications with running it on colab.

My solution:
Before executing 'Install from source' block, add the following line:
%cd /root

I.e. it should look like this:

%cd /root
!git clone https://github.com/openvinotoolkit/anomalib.git
%cd anomalib
%pip install .

Alternatively the issue should also be solved by setting
datamodule = MVTec(root="/root")

Also it might be helpful to add %pip install GitPython infront of the "verifying the working directory"-block.

I think the reason why the pypy install doesn't work correctly is that the latest version there is still v0.7.
This is then locally and on colab an issue.

Regarding the errors you are getting when you try to install it locally from source I'm not quite sure, maybe you can provide further information about the error-log if this ist still relevant for you.

Best regards.

@samet-akcay
Copy link
Contributor

samet-akcay commented Jan 31, 2024

@NilsB98, you are right! Due to the security scans, we had to add validate_path function to input paths. But the current version fails, when the input path is outside the home directory.

root = validate_path(root)

# Check if the resolved path is within the base directory
if not str(path).startswith(str(base_dir)):
msg = "Access denied: Path is outside the allowed directory"
raise ValueError(msg)
# In case path ``should_exist``, the path is valid, and should be
# checked for read and execute permissions.
if should_exist:
# Check if the path exists
if not path.exists():
msg = f"Path does not exist: {path}"
raise FileNotFoundError(msg)
# Check the read and execute permissions
if not (os.access(path, os.R_OK) or os.access(path, os.X_OK)):
msg = f"Read or execute permissions denied for the path: {path}"
raise PermissionError(msg)

This may not be the best approach though since the data can be on a mount. I'll see how we can ease this security check.

@samet-akcay samet-akcay added the Bug Something isn't working label Feb 9, 2024
@samet-akcay samet-akcay changed the title [Bug]: Can't run the 'getting_started' notebook 🐞 Can't run the 'getting_started' notebook Feb 9, 2024
@Issa-Bqain
Copy link

@samet-akcay I am running the notebook on my C drive and getting the same issue - Has there been a resolution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants