lerobot icon indicating copy to clipboard operation
lerobot copied to clipboard

Fix: cv2.imshow hanging on Ubuntu

Open JacoCronje opened this issue 10 months ago • 5 comments

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

JacoCronje avatar Feb 20 '25 19:02 JacoCronje

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

apockill avatar Feb 20 '25 22:02 apockill

This would be a great fix. I had to reinstall the whole opencv stack and nvda dependencies as a workaround.

ivelin avatar Feb 26 '25 16:02 ivelin

Related to https://github.com/huggingface/lerobot/issues/679

imstevenpmwork avatar Mar 04 '25 16:03 imstevenpmwork

This simple fix works like magic

Ke-Wang1017 avatar Mar 04 '25 17:03 Ke-Wang1017

Just confirming this works for me too! Thanks !

frk2 avatar Mar 21 '25 00:03 frk2

Hello @JacoCronje, thanks for your contribution. I'm closing this PR as this was addressed in: https://github.com/huggingface/lerobot/pull/903

imstevenpmwork avatar Apr 17 '25 14:04 imstevenpmwork