{"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/differentiable-jpeg-the-devil-is-in-the","title":"Differentiable JPEG: The Devil is in the Details","arxiv_id":"2309.06978","date":"2023-09-13","proceeding":null,"authors":["Christoph Reich","Biplob Debnath","Deep Patel","Srimat Chakradhar"],"abstract":"JPEG remains one of the most widespread lossy image coding methods. However, the non-differentiable nature of JPEG restricts the application in deep learning pipelines. Several differentiable approximations of JPEG have recently been proposed to address this issue. This paper conducts a comprehensive review of existing diff. JPEG approaches and identifies critical details that have been missed by previous methods. To this end, we propose a novel diff. JPEG approach, overcoming previous limitations. Our approach is differentiable w.r.t. the input image, the JPEG quality, the quantization tables, and the color conversion parameters. We evaluate the forward and backward performance of our diff. JPEG approach against existing methods. Additionally, extensive ablations are performed to evaluate crucial design choices. Our proposed diff. JPEG resembles the (non-diff.) reference implementation best, significantly surpassing the recent-best diff. approach by $3.47$dB (PSNR) on average. For strong compression rates, we can even improve PSNR by $9.51$dB. Strong adversarial attack results are yielded by our diff. JPEG, demonstrating the effective gradient approximation. Our code is available at https://github.com/necla-ml/Diff-JPEG.","url_abs":"https://arxiv.org/abs/2309.06978v4","url_pdf":"https://arxiv.org/pdf/2309.06978v4.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":"differentiable-jpeg-the-devil-is-in-the","repo_url":"https://github.com/necla-ml/diff-jpeg","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"adversarial-attack","task_name":"Adversarial Attack"},{"task_slug":"quantization","task_name":"Quantization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2309.06978","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2309.06978"}},"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/necla-ml/diff-jpeg","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"ran":9,"unverified":6},"by_repo_kind":{"official":{"samples":15,"ran":9,"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":"07f30b9bb91b2a38","entry":"dct_8x8","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/encode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/encode.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"07f30b9bb91b2a38"}},{"code_sha256_prefix":"e43f4d55023f4eb0","entry":"differentiable_clipping","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/clipping.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/clipping.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"e43f4d55023f4eb0"}},{"code_sha256_prefix":"1f5ed3bb36a1fdd6","entry":"differentiable_polynomial_floor","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/rounding.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/rounding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"1f5ed3bb36a1fdd6"}},{"code_sha256_prefix":"4fa4c275e04771e2","entry":"differentiable_polynomial_rounding","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/rounding.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/rounding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"4fa4c275e04771e2"}},{"code_sha256_prefix":"61c6ccfb962064cd","entry":"idct_8x8","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/decode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/decode.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"61c6ccfb962064cd"}},{"code_sha256_prefix":"11f4bba6d4dea611","entry":"jpeg_coding","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"non_diff_jpeg/opencv.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/non_diff_jpeg/opencv.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"11f4bba6d4dea611"}},{"code_sha256_prefix":"a933ca7ccd13b1f3","entry":"jpeg_quality_to_scale","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/utils.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a933ca7ccd13b1f3"}},{"code_sha256_prefix":"a835ed9ff94efe03","entry":"patchify_8x8","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/encode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/encode.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a835ed9ff94efe03"}},{"code_sha256_prefix":"c0e44f696eaa3430","entry":"unpatchify_8x8","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/decode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/decode.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"c0e44f696eaa3430"}},{"code_sha256_prefix":"ff20a283d1fb0d8d","entry":"chroma_subsampling","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/color.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/color.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"ff20a283d1fb0d8d"}},{"code_sha256_prefix":"e66c126d26b54e6c","entry":"dequantize","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/decode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/decode.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"e66c126d26b54e6c"}},{"code_sha256_prefix":"8cbdd2c6b920595c","entry":"diff_jpeg_coding","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/jpeg.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/jpeg.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"8cbdd2c6b920595c"}},{"code_sha256_prefix":"544144a7ead4418d","entry":"quantize","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/encode.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/encode.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"544144a7ead4418d"}},{"code_sha256_prefix":"665e316c94707984","entry":"rgb_to_ycbcr","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/color.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/color.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"665e316c94707984"}},{"code_sha256_prefix":"d7da9d25c1267dd1","entry":"ycbcr_to_rgb","repo":"necla-ml/diff-jpeg","repo_kind":"official","path":"diff_jpeg/color.py","file_url":"https://github.com/necla-ml/diff-jpeg/blob/HEAD/diff_jpeg/color.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"d7da9d25c1267dd1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}