Skip to content

Instantly share code, notes, and snippets.

@lix19937
Created July 6, 2025 00:53
Show Gist options
  • Select an option

  • Save lix19937/50ced4fb5eab04fb5c4e0de5e382f584 to your computer and use it in GitHub Desktop.

Select an option

Save lix19937/50ced4fb5eab04fb5c4e0de5e382f584 to your computer and use it in GitHub Desktop.
nchw2nhwc.py
import numpy as np
with open('chw888.bin', 'rb') as f:
raw_data = f.read()
array = np.frombuffer(raw_data, dtype=np.uint8)
n=3
h=544
w=960
c=3
array = array.reshape(n, c, h, w)
array = array.transpose(0, 2,3,1)
array.tofile('out.bin')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment