Skip to content

Commit

Permalink
πŸ› Fix rgb
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed Dec 31, 2024
1 parent 523aeb1 commit 485d9d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int initializeIoSurface(
GL_RGBA,
width,
height,
GL_RGBA,
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
ioSurface,
0
Expand Down
14 changes: 11 additions & 3 deletions src/craftground/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,18 @@ def convert_observation(
):
# already intialized
# drop alpha, flip y axis, and clone
return self.observation_tensors[0].clone()[:, :, :3].flip(0), None
return (
self.observation_tensors[0].clone()[:, :, :[2, 1, 0]].flip(0),
None,
)
else:
if self.observation_tensors[0] is not None:
# already intialized
# drop alpha, flip y axis, and clone
return self.observation_tensors[0].clone()[:, :, :3].flip(0), None
return (
self.observation_tensors[0].clone()[:, :, :[2, 1, 0]].flip(0),
None,
)

from .craftground_native import initialize_from_mach_port # type: ignore
from .craftground_native import mtl_tensor_from_cuda_mem_handle # type: ignore
Expand All @@ -474,7 +480,9 @@ def convert_observation(
# print(image_tensor)
self.observation_tensors[0] = rgb_array_or_tensor
# drop alpha, flip y axis, and clone
rgb_array_or_tensor = rgb_array_or_tensor.clone()[:, :, :3].flip(0)
rgb_array_or_tensor = rgb_array_or_tensor.clone()[
:, :, :[2, 1, 0]
].flip(0)
else:
# TODO: Handle cuda case also
cuda_dl_tensor = mtl_tensor_from_cuda_mem_handle(
Expand Down

0 comments on commit 485d9d0

Please sign in to comment.