supervision icon indicating copy to clipboard operation
supervision copied to clipboard

opencv-headless requirement breaks existing installation

Open adrianboguszewski opened this issue 2 years ago • 19 comments

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!

adrianboguszewski avatar Sep 04 '23 15:09 adrianboguszewski

Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.

github-actions[bot] avatar Sep 04 '23 15:09 github-actions[bot]

@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.

onuralpszr avatar Sep 04 '23 16:09 onuralpszr

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]

adrianboguszewski avatar Sep 05 '23 09:09 adrianboguszewski

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.

onuralpszr avatar Sep 05 '23 09:09 onuralpszr

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.

onuralpszr avatar Sep 05 '23 10:09 onuralpszr

@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.

onuralpszr avatar Sep 05 '23 10:09 onuralpszr

@hardikdava could you please put your input as well ? I am thinking about 2 ways but I wanna talk through as well.

onuralpszr avatar Sep 05 '23 17:09 onuralpszr

@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).

hardikdava avatar Sep 05 '23 17:09 hardikdava

that is the current but problem is they need to delete headless opencv if they started like that*

onuralpszr avatar Sep 05 '23 17:09 onuralpszr

@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

dennis-ciancoders avatar Sep 20 '23 09:09 dennis-ciancoders

@onuralpszr is that problem still active?

SkalskiP avatar Oct 18 '23 19:10 SkalskiP

@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?

Buckler89 avatar Jul 31 '24 13:07 Buckler89

@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.

onuralpszr avatar Jul 31 '24 13:07 onuralpszr

Hi @onuralpszr 👋🏻 Do we have any ideas on how to improve desktop / headless installs? If not, I suggest we close this issue.

SkalskiP avatar Aug 06 '24 09:08 SkalskiP

Hi @onuralpszr 👋🏻 Do we have any ideas on how to improve desktop / headless installs? 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?

onuralpszr avatar Aug 06 '24 10:08 onuralpszr

Sounds good. Would you like to work on this PR?

SkalskiP avatar Aug 07 '24 11:08 SkalskiP

Sounds good. Would you like to work on this PR?

Sure let me write based on option one then ?

onuralpszr avatar Aug 07 '24 11:08 onuralpszr