Update env.py
Browse files
env.py
CHANGED
|
@@ -154,11 +154,27 @@ class RoboCasaEnv(RoboCasaGymEnv):
|
|
| 154 |
frame = super().render()
|
| 155 |
if frame is None:
|
| 156 |
return frame
|
| 157 |
-
import
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
|
| 164 |
def _make_env_fns(task_name: str, n_envs: int, camera_names: list[str], gym_kwargs: Mapping[str, Any]):
|
|
|
|
| 154 |
frame = super().render()
|
| 155 |
if frame is None:
|
| 156 |
return frame
|
| 157 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 158 |
+
import textwrap
|
| 159 |
+
|
| 160 |
+
text = self._task_description or self.task
|
| 161 |
+
w = frame.shape[1]
|
| 162 |
+
|
| 163 |
+
try:
|
| 164 |
+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 165 |
+
except Exception:
|
| 166 |
+
font = ImageFont.load_default()
|
| 167 |
+
|
| 168 |
+
lines = textwrap.wrap(text, width=55)
|
| 169 |
+
line_h = 18
|
| 170 |
+
bar_h = len(lines) * line_h + 10
|
| 171 |
+
|
| 172 |
+
bar = Image.new("RGB", (w, bar_h), color=(30, 30, 30))
|
| 173 |
+
draw = ImageDraw.Draw(bar)
|
| 174 |
+
for i, line in enumerate(lines):
|
| 175 |
+
draw.text((8, 5 + i * line_h), line, font=font, fill=(220, 220, 220))
|
| 176 |
+
|
| 177 |
+
return np.concatenate([frame, np.array(bar)], axis=0)
|
| 178 |
|
| 179 |
|
| 180 |
def _make_env_fns(task_name: str, n_envs: int, camera_names: list[str], gym_kwargs: Mapping[str, Any]):
|