From 8a1264da890e922989c3966f513b36d4e5263032 Mon Sep 17 00:00:00 2001 From: jaco-df Date: Thu, 20 Feb 2025 20:56:37 +0200 Subject: [PATCH 1/2] fix: imshow hanging --- lerobot/scripts/control_robot.py | 6 ++++++ lerobot/scripts/control_sim_robot.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lerobot/scripts/control_robot.py b/lerobot/scripts/control_robot.py index 3fdb0acc..dcb505ff 100644 --- a/lerobot/scripts/control_robot.py +++ b/lerobot/scripts/control_robot.py @@ -115,6 +115,12 @@ python lerobot/scripts/control_robot.py \ ``` """ +import cv2 +# Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision +# This solves the hanging issue with cv2.imshow on Ubuntu +cv2.namedWindow("i") +cv2.destroyAllWindows() + import logging import time from dataclasses import asdict diff --git a/lerobot/scripts/control_sim_robot.py b/lerobot/scripts/control_sim_robot.py index 8d69bf31..d32b0546 100644 --- a/lerobot/scripts/control_sim_robot.py +++ b/lerobot/scripts/control_sim_robot.py @@ -75,6 +75,11 @@ import time from pathlib import Path import cv2 +# Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision +# This solves the hanging issue with cv2.imshow on Ubuntu +cv2.namedWindow("i") +cv2.destroyAllWindows() + import gymnasium as gym import numpy as np import torch From bbb2eb729c8c1b374293ed8e2c6cae1a8604f370 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:44:39 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lerobot/scripts/control_robot.py | 3 ++- lerobot/scripts/control_sim_robot.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lerobot/scripts/control_robot.py b/lerobot/scripts/control_robot.py index 267e90a0..b60a6a14 100644 --- a/lerobot/scripts/control_robot.py +++ b/lerobot/scripts/control_robot.py @@ -122,9 +122,10 @@ python lerobot/scripts/control_robot.py \ """ import cv2 + # Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision # This solves the hanging issue with cv2.imshow on Ubuntu -cv2.namedWindow("i") +cv2.namedWindow("i") cv2.destroyAllWindows() import logging diff --git a/lerobot/scripts/control_sim_robot.py b/lerobot/scripts/control_sim_robot.py index f1184fdb..6b73e81b 100644 --- a/lerobot/scripts/control_sim_robot.py +++ b/lerobot/scripts/control_sim_robot.py @@ -75,9 +75,10 @@ import time from pathlib import Path import cv2 + # Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision # This solves the hanging issue with cv2.imshow on Ubuntu -cv2.namedWindow("i") +cv2.namedWindow("i") cv2.destroyAllWindows() import gymnasium as gym