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

Alternatives to opencv (cv2) #532

Open
jklaise opened this issue Jun 8, 2022 · 2 comments · May be fixed by #853
Open

Alternatives to opencv (cv2) #532

jklaise opened this issue Jun 8, 2022 · 2 comments · May be fixed by #853

Comments

@jklaise
Copy link
Member

jklaise commented Jun 8, 2022

opencv is a fairly heavy dependency and requires building (see recent CI failures), but we only use it in one place for making image perturbations (https://github.com/SeldonIO/alibi-detect/blob/master/alibi_detect/utils/perturbation.py). We should either explore replacing it with another library that's lighter (potentially scikit-image) or make it an optional dependency.

@kkwekkeboom
Copy link

Another suggestion is to not make it a required dependency and start recommending opencv-python-headless as alternative for opencv-python. Much better in docker images.

Dilip-Jain added a commit to Dilip-Jain/alibi-detect that referenced this issue Oct 1, 2023
@Dilip-Jain Dilip-Jain linked a pull request Oct 1, 2023 that will close this issue
@Dilip-Jain
Copy link

Pull Request #853
Just created a pull request to solve this issue.

  1. Replaced OpenCV's GaussianBlur and filter2D with their counterparts from SciPy.
  2. Substituted OpenCV's affineTransform and warp functions with the corresponding functionalities from scikit-image.
  3. OpenCV is now an optional library with cv2 import dynamically handled within perturbations.py (for future-proofing and people (system/environment) with OpenCV can leverage its functionality too).

PS: I implemented every alternative (known to me) using scipy, scikit-image, custom numpy convolution, etc., and compared the results using Mean Squared Error (MSE) and Structural Similarity Index (SSI). If anyone is interested in those comparisons, let me know I'll put the notebook somewhere online.

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

Successfully merging a pull request may close this issue.

4 participants