supervision
supervision copied to clipboard
opencv-headless requirement breaks existing installation
Search before asking
- [X] I have searched the Supervision issues and found no similar bug report.
Bug
Supervision >= 0.12.0 requires opencv-headless. If I use opencv-python in my application and then install supervision, my opencv is broken (overwritten by the headless package). It would be nice to configure it somehow not to install opencv-headless if any opencv package already installed.
Environment
This happens for supervision >= 0.12.0 Ubuntu 22.04 Python 3.10
Minimal Reproducible Example
pip install opencv-python pip install supervision==0.14.0
import cv2 import numpy as np arr = np.zeros((10, 10), dtype=np.uint8) cv2.imshow("img", arr)
Additional
No response
Are you willing to submit a PR?
- [ ] Yes I'd like to help by submitting a PR!
Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.
@adrianboguszewski for workaround you can delete headless and reinstall full and use with full version and that would work. I can make them explicitly separated and ask install one of them but if you just install supervision it won't have any opencv so we can change our install to force either let's say "headless" and "full" like "pip install supervision[full]" but If you also try to install headless it will skip supervision but install headless in the of the day. So in the end of the day user also has to choose one of them and make sure not have both or delete one them.
Yeah, that's what I did as a workaround. But also, I'm thinking about the mature solution. I don't know if there is any way to check opencv has been already installed so more research is needed.
I think your proposition isn't bad. Let's say the default version is headless and if the user wants to have full opencv they must go with pip install supervision[full]
I think your proposition isn't bad. Let's say the default version is headless and if the user wants to have full opencv they must go with pip install supervision[full]
That is the default right now. But problem is full bring headless too.
Also related : https://github.com/python-poetry/poetry/issues/6419 and not exist yet. So most possible option I see separate both and install one but user has to delete if there is both and we need to as a warning sign as well.
@SkalskiP I know how we do it. So I think we should document at least for conflict problem between headless and full and maybe we can reconsider separate but warning is clear (just install "pip install supervision" won't be enough anymore.
@hardikdava could you please put your input as well ? I am thinking about 2 ways but I wanna talk through as well.
@onuralpszr I would suggest to do as following:
Install supervision with normal opencv package:
pip install supervision
Install supervision with opencv-headless
pip install supervision[headless]
Main reason is that most of the uses uses supervision for dataset conversion and annotators which requires GUI (from normal opencv package).
that is the current but problem is they need to delete headless opencv if they started like that*
@adrianboguszewski for workaround you can delete headless and reinstall full and use with full version and that would work.
The thing is that's not possible when using Poetry instead of pip:
poetry remove opencv-python-headless
The following packages were not found: opencv-python-headless
When using Poetry the workaround is to uninstall opencv-python-headless after installing supervision using pip... wich will "fix" the problem but totally not a good solution.
poetry install "supervision[desktop]"
poetry shell
pip uninstall opencv-python-headless
@onuralpszr is that problem still active?
@onuralpszr is that problem still active?
yes. For me the solution suggested by @dennis-ciancoders broke imshow and waitKey methods of opencv.
Someoneelse is encountering the same issue?
@onuralpszr is that problem still active?
yes. For me the solution suggested by @dennis-ciancoders broke imshow and waitKey methods of opencv.
Someoneelse is encountering the same issue?
Quick workaround
pip install supervision
pip uninstall opencv-python-headless
pip install opencv-python
This should work. You uninstall headless and install full one and you can make it work. Make sure you delete headless and install opencv-python, If somehow you have both installed then delete both and install "opencv-python" should work. Let me know how is it go.
Hi @onuralpszr 👋🏻 Do we have any ideas on how to improve desktop / headless installs? If not, I suggest we close this issue.
Hi @onuralpszr 👋🏻 Do we have any ideas on how to improve
desktop/headlessinstalls? If not, I suggest we close this issue.
@SkalskiP hello 👋
2 suggestions, I will explicit documentation how to manage properly those cases and not do change on toml, second I will remove headless and put desktop package and I will wrote documentation again to how to switch between them and explain how to manage desktop and headless, based on these I can create pr and we can put marl as complete?
Sounds good. Would you like to work on this PR?
Sounds good. Would you like to work on this PR?
Sure let me write based on option one then ?