PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
42.4k stars 7.65k forks source link

Won't opencv-python and opencv-contrib-python conflict with each other? They are both in requirements! #11555

Open sisrfeng opened 7 months ago

sisrfeng commented 7 months ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

我们提供了AceIssueSolver来帮助你解答问题,你是否想要它来解答(请填写yes/no)?/We provide AceIssueSolver to solve issues, do you want it? (Please write yes/no):no

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

From google's Bard

You're absolutely right! Having both opencv-python and opencv-contrib-python listed in the requirements.txt of the PaddleOCR GitHub repository can indeed lead to conflicts. Here's why:

  1. Redundancy: opencv-contrib-python is essentially an extension of opencv-python, containing additional modules and algorithms. Installing both packages installs many of the same files, potentially causing version clashes and unexpected behavior.
  2. Version Mismatch: If the specified versions of opencv-python and opencv-contrib-python differ, pip might not be able to resolve the conflict, leading to installation errors or missing functionalities.
  3. Dependency Issues: Other dependencies in the project might have specific requirements for either opencv-python or opencv-contrib-python. Having both listed could lead to unexpected dependency conflicts for those libraries.

Solutions:

There are a couple of ways to address this redundancy and potential conflict:

It's generally recommended to avoid having both packages listed unless absolutely necessary. Choosing the appropriate approach depends on your specific requirements and the functionalities you need in your project.

I hope this explanation clarifies the potential conflict and provides helpful solutions!

sisrfeng commented 7 months ago

I guess this is relevant: https://github.com/aleju/imgaug/issues/473

TingquanGao commented 7 months ago

Thanks~ Could you please provide the steps for reproducing the conflicts? We would like to check and fix.

michaelconan commented 1 month ago

This is clearly stated on OpenCV's PyPI page:

There are four different packages (see options 1, 2, 3 and 4 below) and you should SELECT ONLY ONE OF THEM. Do not install multiple different packages in the same environment. There is no plugin architecture: all the packages use the same namespace (cv2). If you installed multiple different packages in the same environment, uninstall them all with pip uninstall and reinstall only one package. a. Packages for standard desktop environments (Windows, macOS, almost any GNU/Linux distribution) Option 1 - Main modules package: pip install opencv-python Option 2 - Full package (contains both main modules and contrib/extra modules): pip install opencv-contrib-python (check contrib/extra modules listing from OpenCV documentation)

I don't believe there should be any need to install both and as mentioned, it causes issues.

We're currently seeing: AttributeError: module 'cv2.ximgproc' has no attribute 'niBlackThreshold'. Going to try to change versions to fix for now.