Fix: cv2.imshow hanging on Ubuntu
What this does
Fixes cv2.imshow from hanging on Ubuntu. The code makes sure to initialize the opencv UI before torchvision gets imported. torchvision is dependant on PyAV, which seems to be the root cause of the issue. If av gets imported before cv2, it clashes with the opencv UI and creates the hanging effect. torchvision imports av.
More information here: https://github.com/pytorch/vision/issues/5940
How it was tested
After the code change, no more freezing for me. I'm running Ubuntu 22.04.4 LTS
Also worth noting that the root cause of this issue is ffmpeg versions being mismatched from what pypi's pyav is expecting. The fix for this is to have the correct ffmpeg dependencies, as demonstrated in this docker environment I put together and tested for lerobot.
https://github.com/huggingface/lerobot/pull/519
This would be a great fix. I had to reinstall the whole opencv stack and nvda dependencies as a workaround.
Related to https://github.com/huggingface/lerobot/issues/679
This simple fix works like magic
Just confirming this works for me too! Thanks !
Hello @JacoCronje, thanks for your contribution. I'm closing this PR as this was addressed in: https://github.com/huggingface/lerobot/pull/903