MCPcopy
hub / github.com/Vchitect/Latte / load_image_from_buffer

Function load_image_from_buffer

tools/utils/dataset.py:457–466  ·  view source on GitHub ↗
(f, use_pyspng: bool=False)

Source from the content-addressed store, hash-verified

455#----------------------------------------------------------------------------
456
457def load_image_from_buffer(f, use_pyspng: bool=False) -> np.ndarray:
458 if use_pyspng:
459 image = pyspng.load(f.read())
460 else:
461 image = np.array(PIL.Image.open(f))
462 if image.ndim == 2:
463 image = image[:, :, np.newaxis] # HW => HWC
464 image = image.transpose(2, 0, 1) # HWC => CHW
465
466 return image
467
468#----------------------------------------------------------------------------
469

Callers 2

_load_raw_imageMethod · 0.85
_load_raw_framesMethod · 0.85

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected