MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / from_bin_stream

Function from_bin_stream

gsplat/compression/entropy_coding_compression.py:570–591  ·  view source on GitHub ↗
(filename: str, tensor_length: int)

Source from the content-addressed store, hash-verified

568 return meta
569
570def from_bin_stream(filename: str, tensor_length: int) -> torch.Tensor:
571 # read binary file
572 with open(filename, 'rb') as f:
573 byte_data = f.read()
574
575 # set up tensor to be saved
576 unsigned_sym = torch.zeros(tensor_length, dtype=torch.int)
577
578 # unpack byte array
579 for i in range(tensor_length):
580 byte_index = i // 8
581 bit_position = i % 8
582
583 # Check if specific bit is 1
584 if byte_index < len(byte_data) and (byte_data[byte_index] & (1 << bit_position)):
585 unsigned_sym[i] = 1
586
587 # Convert 0/1 to -1/+1
588 signed_sym = unsigned_sym * 2 - 1
589 signed_sym = signed_sym.to(dtype=torch.float32)
590
591 return signed_sym
592
593def _decompress_gaussian_ans(
594 compress_dir: str, param_name: str, meta: Dict[str, Any], decoded_means: Tensor,

Callers 1

_decompress_gaussian_ansFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected