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

Support Kaggle and Colab Environments #130

Closed
innat opened this issue Mar 4, 2022 · 13 comments · Fixed by #163 or #165
Closed

Support Kaggle and Colab Environments #130

innat opened this issue Mar 4, 2022 · 13 comments · Fixed by #163 or #165

Comments

@innat
Copy link
Contributor

innat commented Mar 4, 2022

Is your feature request related to a problem? Please describe.

  • Kaggle and Colab are free and great resources to do quick experiments. Currently, I've found that it's not possible to run anomalib on these environments. I guess, when the PIP packages get ready, it would be possible. Supporting these environments would be a great opportunity for the end-user for sure.
@alexriedel1
Copy link
Contributor

Whats exactly your problem on Colab?
I've had no problem using anomalib

@innat
Copy link
Contributor Author

innat commented Mar 7, 2022

I actually tried on kaggle, couldn't install it with pip. Maybe due to some torch / Cuda version issue. Have you checked on kaggle env?

@alexriedel1
Copy link
Contributor

I can only guess if you're not posting the actual error. But my guess is, that Kaggle and Colab are running python 3.7 so you have to change this line in anomalib

python_requires=">=3.8",

@innat
Copy link
Contributor Author

innat commented Mar 7, 2022

On kaggle env, I did

!git clone https://github.com/openvinotoolkit/anomalib.git
%cd anomalib
%pip install -e .
Collecting torchvision==0.9.1
  Downloading torchvision-0.9.1-cp37-cp37m-manylinux1_x86_64.whl (17.4 MB)
     |████████████████████████████████| 17.4 MB 35.3 MB/s            
ERROR: Package 'anomalib' requires a different Python: 3.7.12 not in '>=3.8'
Note: you may need to restart the kernel to use updated packages.

Next,

!python tools/train.py

Traceback (most recent call last):
  File "tools/train.py", line 26, in <module>
    from anomalib.config import get_configurable_parameters
ModuleNotFoundError: No module named 'anomalib'

@alexriedel1
Copy link
Contributor

After moving to the anomalib dir, run the following, then install via pip

import fileinput
import sys

for line in fileinput.input("setup.py", inplace=1):
    line = line.replace(">=3.8", ">=3.7")
    sys.stdout.write(line)

@samet-akcay
Copy link
Contributor

Hi both, if this solves the issue, we could create a PR to be able to work on Python3.7?
https://github.com/openvinotoolkit/anomalib/blob/development/setup.py#L97

@innat
Copy link
Contributor Author

innat commented Mar 13, 2022

@alexriedel1 (cc. @samet-akcay )
I just tried your tips, but unfortunately couldn't make it run. Could you please take a look at this FILE for reference? I surely have missed something.

@alexriedel1
Copy link
Contributor

alexriedel1 commented Mar 13, 2022

you need the correct torchtext version for pytorch 1.8.1, which is 0.9.1 (pip install torchtext==0.9.1)
On Kaggle, you'll run into a openvino import error (as openvino is not installed). You can patch this by not importing openvino in the respective init files.

@bth5
Copy link

bth5 commented Mar 22, 2022

It would really help if there would be a proof of concept working colab available to test the functionality of the library. I'm also struggling to get up and running. I think it would be a good stepping stone to use these amazing resources.

@alexriedel1
Copy link
Contributor

alexriedel1 commented Mar 24, 2022

Hello,
this notebook contains all the necessary steps to get anomalib running on Google Colab
https://colab.research.google.com/drive/1yFtIJP7OkE4-zF8S3kg9lQnqS53Nh95H?usp=sharing

Anyways, you will run into an import error for OpenVino. Just patch that by commenting out the OpenVino in the respective file.

I guess some things should be done in order to make this easier:

  1. install the matching torchtext version in the requirements
  2. install the right open-cv version in the requirements (check which one is actually necessary)
  3. figure out the issue with the folder names. if you import anomalib on colab and it's inside a dir called anomalib, it will be imported from there and not the installed version. thats why you have to clone into a differently named dir...
  4. offer a version that doesnt import openvino

@samet-akcay
Copy link
Contributor

Hi all, we've recently merged #163. You could have a look and let us know if you encounter any issues.

@innat
Copy link
Contributor Author

innat commented Mar 25, 2022

@samet-akcay Thanks.
Could you please add torchtext==0.9.1 in the set up / requirement file. It's the only issue to run anomalib in colab and kaggle.

@samet-akcay
Copy link
Contributor

Done:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants