Serialization and compression

Serialization and compression#

JSON serialization of trained bases (byte-compatible with the Julia package) and top-k lossy compression of images in a learned basis.

Serialization (JSON) and lossy compression of trained bases.

Contents

save_basis

Write basis to a JSON file.

load_basis

Read basis from a JSON file.

basis_to_dict

Serialize a QFTBasis to a plain Python dict (JSON-ready).

dict_to_basis

Inverse of basis_to_dict.

basis_hash

SHA256 of a canonical string form, matching Julia's basis_hash(QFTBasis).

format_float_julia_like

Format a Python float the way Julia's string(x::Float64) does.

compress

Compress image under basis, keeping top (1 - ratio) fraction.

compress_with_k

Compress keeping exactly k coefficients.

recover

Reconstruct real-valued image from a compressed representation.

CompressedImage

Sparse frequency-domain representation of an image.

compression_stats

Summary of compression ratio + kept coefficients.

save_compressed

Write a CompressedImage to path as JSON; returns the path.

load_compressed

Read a CompressedImage written by save_compressed.

compressed_to_dict

Convert to the JSON-ready dict form (schema version _VERSION).

dict_to_compressed

Inverse of compressed_to_dict.