zhicao/dreamzero main
PYTHON
Verdict: BENIGN
Local reference
Suspicious dependency
Inferred
| 1 |
""" |
|
| 2 |
Visualizations |
|
| 3 |
""" |
|
| 4 |
|
|
| 5 |
from __future__ import annotations |
|
| 6 |
|
|
| 7 |
import os |
|
| 8 |
import time |
|
| 9 |
from typing import Literal |
|
| 10 |
import warnings |
|
| 11 |
|
|
| 12 |
import cv2 |
|
| 13 |
import imageio |
|
| 14 |
import matplotlib.pyplot as plt |
|
| 15 |
import numpy as np |
Imports the NumPy array library |
| 16 |
import torch |
|
| 17 |
|
|
| 18 |
from .array_tensor_utils import any_describe |
|
| 19 |
from .misc_utils import global_once |
|
| 20 |
from .torch_utils import t… |
|
| 27:6 |
… in "auto" mode, we assume C == 3 |
|
| 28 |
""" |
|
| 29 |
assert channel_order in ["hwc", "chw", "auto"] |
|
| 30 |
if torch.is_tensor(img): |
|
| 31 |
img = img.cpu().numpy() |
|
| 32 |
assert isinstance(img, np.ndarray) |
Module built on the numeric Python stack |
| 33 |
if img.ndim == 4: |
|
| 34 |
assert img.shape[0] == 1 |
|
| 35 |
img = img[0] |
|
| 36 |
assert img.ndim == 3 |
|
| 37 |
if channel_order == "auto": |
|
| 38 |
# use C==3 to detect order |
|
| 39 |
if img.shape[0] == 3… |
|
| 40:13 |
…channel_order = "chw" |
|
| 41 |
else: |
|
| 42 |
assert img.shape[-1] == 3, "image should either have [3,H,W] or [H,W,3]" |
|
| 43 |
channel_order = "hwc" |
|
| 44 |
img = img.astype(np.uint8) |
|
| 45 |
if channel_order == "chw":… |
|
| 52:27 |
…g)) |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
def imsave(img, path): |
|
| 56 |
imageio.imsave(os.path.expanduser(path), to_image(img)) |
|
| 57 |
|
|
| 58 |
|
|
| 59 |
def imread(path, channel_order="chw", format="torch"): |
Raster image loader call |
| 60 |
assert channel_order in ["hwc", "chw"] |
|
| 61 |
assert format in ["numpy", "torch"] |
|
| 62 |
img = imageio.imread(path) |
|
| 63 |
if channel_order == "chw": |
|
| 64 |
img = np.transpose(img, (… |
|
| 126:20 |
…h |
|
| 127 |
|
|
| 128 |
# prevent segfault in IsaacGym |
|
| 129 |
display_var = os.environ.get("DISPLAY", None) |
Python reads an environment variable |
| 130 |
if not display_var: |
|
| 131 |
os.environ["DISPLAY"] = ":0.0" |
|
| 132 |
|
|
| 133 |
if torch.is_tensor(img): |
|
| 134 |
img = img.detach().cpu().numpy() |
|
| 135 |
|
|
| 136 |
… |
|
Micro-behaviors
| 1 |
""" |
|
| 2 |
Visualizations |
|
| 3 |
""" |
|
| 4 |
|
|
| 5 |
from __future__ import annotations |
|
| 6 |
|
|
| 7 |
import os |
|
| 8 |
import time |
|
| 9 |
from typing import Literal |
|
| 10 |
import warnings |
|
| 11 |
|
|
| 12 |
import cv2 |
|
| 13 |
import imageio |
|
| 14 |
import matplotlib.pyplot as plt |
|
| 15 |
import numpy as np |
|
| 16 |
import torch |
|
| 17 |
|
|
| 18 |
from .array_tensor_utils import any_describe |
|
| 19 |
from .misc_utils import global_once |
|
| 20 |
from .torch_utils import t… |
|
| 27:6 |
… in "auto" mode, we assume C == 3 |
|
| 28 |
""" |
|
| 29 |
assert channel_order in ["hwc", "chw", "auto"] |
|
| 30 |
if torch.is_tensor(img): |
|
| 31 |
img = img.cpu().numpy() |
|
| 32 |
assert isinstance(img, np.ndarray) |
|
| 33 |
if img.ndim == 4: |
|
| 34 |
assert img.shape[0] == 1 |
|
| 35 |
img = img[0] |
|
| 36 |
assert img.ndim == 3 |
|
| 37 |
if channel_order == "auto": |
|
| 38 |
# use C==3 to detect order |
|
| 39 |
if img.shape[0] == 3… |
|
| 52:27 |
…g)) |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
def imsave(img, path): |
|
| 56 |
imageio.imsave(os.path.expanduser(path), to_image(img)) |
|
| 57 |
|
|
| 58 |
|
|
| 59 |
def imread(path, channel_order="chw", format="torch"): |
|
| 60 |
assert channel_order in ["hwc", "chw"] |
|
| 61 |
assert format in ["numpy", "torch"] |
|
| 62 |
img = imageio.imread(path) |
|
| 63 |
if channel_order == "chw": |
|
| 64 |
img = np.transpose(img, (… |
|
| 1 |
""" |
|
| 2 |
Visualizations |
|
| 3 |
""" |
|
| 4 |
|
|
| 5 |
from __future__ import annotations |
|
| 6 |
|
|
| 7 |
import os |
|
| 8 |
import time |
|
| 9 |
from typing import Literal |
|
| 10 |
import warnings |
|
| 11 |
|
|
| 12 |
import cv2 |
|
| 13 |
import imageio |
|
| 14 |
import matplotlib.pyplot as plt |
|
| 15 |
import numpy as np |
|
| 16 |
import torch |
|
| 17 |
|
|
| 18 |
from .array_tensor_utils import any_describe |
|
| 19 |
from .misc_utils import global_once |
|
| 20 |
from .torch_utils import t… |
|
| 126:20 |
…h |
|
| 127 |
|
|
| 128 |
# prevent segfault in IsaacGym |
|
| 129 |
display_var = os.environ.get("DISPLAY", None) |
|
| 130 |
if not display_var: |
|
| 131 |
os.environ["DISPLAY"] = ":0.0" |
|
| 132 |
|
|
| 133 |
if torch.is_tensor(img): |
|
| 134 |
img = img.detach().cpu().numpy() |
|
| 135 |
|
|
| 136 |
… |
|
Metadata
| 85:34 |
…hwc, or chw |
|
| 86 |
image_size: None to use the original image size, otherwise resize |
|
| 87 |
step_sleep: sleep for a few seconds |
|
| 88 |
""" |
|
| 89 |
self._window_name = window_name |
|
| 90 |
if isinstance(image_s… |
|
| 193:28 |
…| None = None, |
|
| 194 |
): |
|
| 195 |
""" |
|
| 196 |
Check for resize, and divide by 255 |
|
| 197 |
""" |
|
| 198 |
import kornia |
|
| 199 |
|
|
| 200 |
assert torch.is_tensor(img) |
|
| 201 |
assert img.dim() >… |
|
| 40:13 |
…channel_order = "chw" |
|
| 41 |
else: |
|
| 42 |
assert img.shape[-1] == 3, "image should either have [3,H,W] or [H,W,3]" |
|
| 43 |
channel_order = "hwc" |
|
| 44 |
img = img.astype(np.uint8) |
|
| 45 |
if channel_order == "chw":… |
|
| 157:43 |
… integers, which is wrong for any NN input. |
|
| 158 |
This is a common case if the user forgets to normalize the image first |
|
| 159 |
""" |
|
| 160 |
assert on_error i… |
|
Identity
| SHA-256 |
31e10392dfd2fa518ae75c7e76a30eb1e2caf072ea7a16b354def46fa82d78b0 |
| Filename |
image_utils.py |
| Package |
zhicao/dreamzero |
| Version |
main |
| PURL |
pkg:huggingface/zhicao/dreamzero@main |
Timeline
| First seen |
13 Aug 2026 21:18 UTC |
| First analyzed |
30 Aug 2026 18:08 UTC |
| Last analyzed |
30 Aug 2026 18:08 UTC |
| Last updated |
30 Aug 2026 18:08 UTC |
Labeling
| Label |
unknown |
| Label source |
forager |
| Traits version |
cdf4f |