{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/image-and-video-tokenization-with-binary","title":"Image and Video Tokenization with Binary Spherical Quantization","arxiv_id":"2406.07548","date":"2024-06-11","proceeding":null,"authors":["Yue Zhao","Yuanjun Xiong","Philipp Krähenbühl"],"abstract":"We propose a new transformer-based image and video tokenizer with Binary Spherical Quantization (BSQ). BSQ projects the high-dimensional visual embedding to a lower-dimensional hypersphere and then applies binary quantization. BSQ is (1) parameter-efficient without an explicit codebook, (2) scalable to arbitrary token dimensions, and (3) compact: compressing visual data by up to 100$\\times$ with minimal distortion. Our tokenizer uses a transformer encoder and decoder with simple block-wise causal masking to support variable-length videos as input. The resulting BSQ-ViT achieves state-of-the-art visual reconstruction quality on image and video reconstruction benchmarks with 2.4$\\times$ throughput compared to the best prior methods. Furthermore, by learning an autoregressive prior for adaptive arithmetic coding, BSQ-ViT achieves comparable results on video compression with state-of-the-art video compression standards. BSQ-ViT also enables masked language models to achieve competitive image synthesis quality to GAN- and diffusion-based methods.","url_abs":"https://arxiv.org/abs/2406.07548v1","url_pdf":"https://arxiv.org/pdf/2406.07548v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"image-and-video-tokenization-with-binary","repo_url":"https://github.com/zhaoyue-zephyrus/bsq-vit","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"image-and-video-tokenization-with-binary","repo_url":"https://github.com/lucidrains/vector-quantize-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"quantization","task_name":"Quantization"},{"task_slug":"video-compression","task_name":"Video Compression"},{"task_slug":"video-reconstruction","task_name":"Video Reconstruction"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2406.07548","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.07548"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhaoyue-zephyrus/bsq-vit","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lucidrains/vector-quantize-pytorch","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":8,"ran_draft_wrong":3,"unverified":3},"by_repo_kind":{"official":{"samples":14,"ran":11,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"82547443813db80a","entry":"codebook_entropy","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/models/quantizer/bsq.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/models/quantizer/bsq.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"82547443813db80a"}},{"code_sha256_prefix":"476d0c33c781d232","entry":"compute_fvd_score","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/fvd/fvd_score.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/fvd/fvd_score.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"476d0c33c781d232"}},{"code_sha256_prefix":"4d85e9c25e578ed4","entry":"compute_stats","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/fvd/fvd_score.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/fvd/fvd_score.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4d85e9c25e578ed4"}},{"code_sha256_prefix":"d8ca8331fdf571f8","entry":"get_attention_mask","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/models/attention_mask.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/models/attention_mask.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d8ca8331fdf571f8"}},{"code_sha256_prefix":"726780cba749fec2","entry":"get_ckpt_path","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/lpips.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/lpips.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"726780cba749fec2"}},{"code_sha256_prefix":"898e597a6eb684c2","entry":"get_inception_score","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/inception_score.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/inception_score.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"898e597a6eb684c2"}},{"code_sha256_prefix":"18eb88ffa0fbed03","entry":"get_psnr","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/psnr.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/psnr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"18eb88ffa0fbed03"}},{"code_sha256_prefix":"22a83df891d750c6","entry":"hinge_d_loss","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/vqperceptual.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/vqperceptual.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"22a83df891d750c6"}},{"code_sha256_prefix":"39168ca3aac0a4d7","entry":"hinge_g_loss","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/vqperceptual.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/vqperceptual.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"39168ca3aac0a4d7"}},{"code_sha256_prefix":"7257fdf155f5ef45","entry":"normalize_tensor","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/lpips.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/lpips.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7257fdf155f5ef45"}},{"code_sha256_prefix":"263c54290c553ddd","entry":"vanilla_d_loss","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/vqperceptual.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/vqperceptual.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"263c54290c553ddd"}},{"code_sha256_prefix":"0def50a351111624","entry":"calculate_frechet_distance","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/fid/fid_score.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/fid/fid_score.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0def50a351111624"}},{"code_sha256_prefix":"f50362598da489ee","entry":"get_lpips","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/evaluations/lpips.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/evaluations/lpips.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f50362598da489ee"}},{"code_sha256_prefix":"c8d9d38b144e401f","entry":"md5_hash","repo":"zhaoyue-zephyrus/bsq-vit","repo_kind":"official","path":"transcoder/losses/lpips.py","file_url":"https://github.com/zhaoyue-zephyrus/bsq-vit/blob/HEAD/transcoder/losses/lpips.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c8d9d38b144e401f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}