OSCR

MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration.

Code ↔ Paper

2 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 2 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
  1. [1] § Experiment Details and More Experiments › Data-driven Baseline Details ↔ predict.py, lines 15–147 · score 0.93 · gan pth, realSR_BSRGAN_DFO_s64w8_SwinIR, training patch, super resolution, pretrained, SSIM
  2. [2] § Experiment Details and More Experiments › Data-driven Baseline Details ↔ download-weights.sh, the whole file · a weak match · score 0.87 · bsrgan dfo s64w8, JingyunLiang, real sr, SwinIR, pretrained, pth

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 159 lines · 7.8 KB · Apache-2.0 · 1 match

  1. import cog
  2. import tempfile
  3. from pathlib import Path
  4. import argparse
  5. import shutil
  6. import os
  7. import cv2
  8. import glob
  9. import torch
  10. from collections import OrderedDict
  11. import numpy as np
  12. from main_test_swinir import define_model, setup, get_image_pair
  13. class Predictor(cog.Predictor):
  14. def setup(self):
  15. model_dir = 'experiments/pretrained_models'
  16. self.model_zoo = {
  17. 'real_sr': {
  18. 4: os.path.join(model_dir, '003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth')
  19. },
  20. 'gray_dn': {
  21. 15: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise15.pth'),
  22. 25: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise25.pth'),
  23. 50: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise50.pth')
  24. },
  25. 'color_dn': {
  26. 15: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise15.pth'),
  27. 25: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise25.pth'),
  28. 50: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise50.pth')
  29. },
  30. 'jpeg_car': {
  31. 10: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg10.pth'),
  32. 20: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg20.pth'),
  33. 30: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg30.pth'),
  34. 40: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg40.pth')
  35. }
  36. }
  37. parser = argparse.ArgumentParser()
  38. parser.add_argument('--task', type=str, default='real_sr', help='classical_sr, lightweight_sr, real_sr, '
  39. 'gray_dn, color_dn, jpeg_car')
  40. parser.add_argument('--scale', type=int, default=1, help='scale factor: 1, 2, 3, 4, 8') # 1 for dn and jpeg car
  41. parser.add_argument('--noise', type=int, default=15, help='noise level: 15, 25, 50')
  42. parser.add_argument('--jpeg', type=int, default=40, help='scale factor: 10, 20, 30, 40')
  43. parser.add_argument('--training_patch_size', type=int, default=128, help='patch size used in training SwinIR. '
  44. 'Just used to differentiate two different settings in Table 2 of the paper. '
  45. 'Images are NOT tested patch by patch.')
  46. parser.add_argument('--large_model', action='store_true',
  47. help='use large model, only provided for real image sr')
  48. parser.add_argument('--model_path', type=str,
  49. default=self.model_zoo['real_sr'][4])
  50. parser.add_argument('--folder_lq', type=str, default=None, help='input low-quality test image folder')
  51. parser.add_argument('--folder_gt', type=str, default=None, help='input ground-truth test image folder')
  52. self.args = parser.parse_args('')
  53. self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
  54. self.tasks = {
  55. 'Real-World Image Super-Resolution': 'real_sr',
  56. 'Grayscale Image Denoising': 'gray_dn',
  57. 'Color Image Denoising': 'color_dn',
  58. 'JPEG Compression Artifact Reduction': 'jpeg_car'
  59. }
  60. @cog.input("image", type=Path, help="input image")
  61. @cog.input("task_type", type=str, default='Real-World Image Super-Resolution',
  62. options=['Real-World Image Super-Resolution', 'Grayscale Image Denoising', 'Color Image Denoising',
  63. 'JPEG Compression Artifact Reduction'],
  64. help="image restoration task type")
  65. @cog.input("noise", type=int, default=15, options=[15, 25, 50],
  66. help='noise level, activated for Grayscale Image Denoising and Color Image Denoising. '
  67. 'Leave it as default or arbitrary if other tasks are selected')
  68. @cog.input("jpeg", type=int, default=40, options=[10, 20, 30, 40],
  69. help='scale factor, activated for JPEG Compression Artifact Reduction. '
  70. 'Leave it as default or arbitrary if other tasks are selected')
  71. def predict(self, image, task_type='Real-World Image Super-Resolution', jpeg=40, noise=15):
  72. self.args.task = self.tasks[task_type]
  73. self.args.noise = noise
  74. self.args.jpeg = jpeg
  75. # set model path
  76. if self.args.task == 'real_sr':
  77. self.args.scale = 4
  78. self.args.model_path = self.model_zoo[self.args.task][4]
  79. elif self.args.task in ['gray_dn', 'color_dn']:
  80. self.args.model_path = self.model_zoo[self.args.task][noise]
  81. else:
  82. self.args.model_path = self.model_zoo[self.args.task][jpeg]
  83. try:
  84. # set input folder
  85. input_dir = 'input_cog_temp'
  86. os.makedirs(input_dir, exist_ok=True)
  87. input_path = os.path.join(input_dir, os.path.basename(image))
  88. shutil.copy(str(image), input_path)
  89. if self.args.task == 'real_sr':
  90. self.args.folder_lq = input_dir
  91. else:
  92. self.args.folder_gt = input_dir
  93. model = define_model(self.args)
  94. model.eval()
  95. model = model.to(self.device)
  96. # setup folder and path
  97. folder, save_dir, border, window_size = setup(self.args)
  98. os.makedirs(save_dir, exist_ok=True)
  99. test_results = OrderedDict()
  100. test_results['psnr'] = []
  101. test_results['ssim'] = []
  102. test_results['psnr_y'] = []
  103. test_results['ssim_y'] = []
  104. test_results['psnr_b'] = []
  105. # psnr, ssim, psnr_y, ssim_y, psnr_b = 0, 0, 0, 0, 0
  106. out_path = Path(tempfile.mkdtemp()) / "out.png"
  107. for idx, path in enumerate(sorted(glob.glob(os.path.join(folder, '*')))):
  108. # read image
  109. imgname, img_lq, img_gt = get_image_pair(self.args, path) # image to HWC-BGR, float32
  110. img_lq = np.transpose(img_lq if img_lq.shape[2] == 1 else img_lq[:, :, [2, 1, 0]],
  111. (2, 0, 1)) # HCW-BGR to CHW-RGB
  112. img_lq = torch.from_numpy(img_lq).float().unsqueeze(0).to(self.device) # CHW-RGB to NCHW-RGB
  113. # inference
  114. with torch.no_grad():
  115. # pad input image to be a multiple of window_size
  116. _, _, h_old, w_old = img_lq.size()
  117. h_pad = (h_old // window_size + 1) * window_size - h_old
  118. w_pad = (w_old // window_size + 1) * window_size - w_old
  119. img_lq = torch.cat([img_lq, torch.flip(img_lq, [2])], 2)[:, :, :h_old + h_pad, :]
  120. img_lq = torch.cat([img_lq, torch.flip(img_lq, [3])], 3)[:, :, :, :w_old + w_pad]
  121. output = model(img_lq)
  122. output = output[..., :h_old * self.args.scale, :w_old * self.args.scale]
  123. # save image
  124. output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
  125. if output.ndim == 3:
  126. output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0)) # CHW-RGB to HCW-BGR
  127. output = (output * 255.0).round().astype(np.uint8) # float32 to uint8
  128. cv2.imwrite(str(out_path), output)
  129. finally:
  130. clean_folder(input_dir)
  131. return out_path
  132. def clean_folder(folder):
  133. for filename in os.listdir(folder):
  134. file_path = os.path.join(folder, filename)
  135. try:
  136. if os.path.isfile(file_path) or os.path.islink(file_path):
  137. os.unlink(file_path)
  138. elif os.path.isdir(file_path):
  139. shutil.rmtree(file_path)
  140. except Exception as e:
  141. print('Failed to delete %s. Reason: %s' % (file_path, e))

predict.py at commit 6545850, under Apache-2.0 · at the source

Overview

Authors: Jianmin Liao1, Lei Huang2, Ronglong Fang3, Ashley Prater-Bennette4, Lixin Shen1, Yuesheng Xu2
ORCID iDs: Jianmin Liao
  1. Department of Mathematics, Syracuse University, 215 Carnegie Building, Syracuse, NY 13210 USA
  2. Department of Mathematics & Statistics, Old Dominion University, 2300 Engineering & Computational Sciences Building, Norfolk, VA 23529 USA
  3. Department of Medical Physical, Memorial Sloan Kettering Cancer Center, 1250 First Avenue, New York, NY 10065 USA
  4. Air Force Research Laboratory, 525 Brooks Road, Rome, NY 13441 USA
Journal: Journal of mathematical imaging and vision, volume 68, issue 4, article 48
Dates: received 27 January 2026; accepted 21 June 2026; published online 30 July 2026; in print 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1007/s10851-026-01329-2 · PMID 42539614 · PMCID PMC13423958 · OpenAlex W7171775443
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: systems (subfield)
Keywords: Image restoration, Training-data-free, Implicit neural representation, Sparse regularization, Multi-grade deep learning
Topic: Advanced Image Processing Techniques (Computer Vision and Pattern Recognition, Computer Science), according to OpenAlex
Funding: NCI NIH HHS (R21 CA263876); National Institutes of Health (R21CA263876); Division of Mathematical Sciences (2208385)
Citations: not cited yet (Europe PMC); 50 references in the paper

Abstract

MG-SpaIR is a training-data-free framework for restoring a clean image from a single observation corrupted by a mixture of blur, downsampling, noise, and missing pixels. Building on implicit neural representations (INRs), we introduce a multi-grade residual hierarchy that progressively refines the reconstruction from low to high spatial frequencies across grades, improving representational fidelity and mitigating spectral limitations. To stabilize reconstruction optimization and suppress INR-induced artifacts, we further propose an explicit sparse proximal regularization (e.g., ℓ0 type) applied directly in the high-resolution image domain, which discourages spurious high-frequency patterns while preserving sharp structures. The resulting optimization is solved efficiently via a multi-grade proximal alternating scheme, and we establish convergence guarantees for the associated updates under standard regularity conditions. Experiments on mixed-degradation benchmarks demonstrate that MG-SpaIR consistently outperforms strong training-data-free baselines such as Deep Image Prior, providing a stable, interpretable, and data-efficient alternative to conventional learning-based restoration methods.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 2 matches between paragraphs and lines of code.

JingyunLiang/SwinIR

License: Apache-2.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 6545850fbf8df298df73d81f3e8cba638787c8bd, 4 December 2022
Languages: Python (4), Shell (1)
Size: 112 files, 5 scripts
Software Heritage: not archived
Found in: the text, “Data-driven Baseline Details”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: PyTorch (4 files), NumPy (3 files), OpenCV (3 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
7 files

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 5 scripts, each with its path and the digest of its content;
  • 2 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data Availability

The datasets analyzed during the current study are publicly available. The Set5 and Set14 datasets are standard benchmarks in the field and are widely available in public repositories (e.g., https://www.kaggle.com/datasets/ll01dm/set-5-14-super-resolution-dataset). The Flickr2K dataset was introduced by Lim et al. and is available for download in public repositories (e.g., https://www.kaggle.com/datasets/daehoyang/flickr2k). Additionally, the specific image “The quick brown fox” used in this study is available on Wikimedia Commons (https://commons.wikimedia.org/wiki/File:The_quick_brown_fox....._(15677707699).jpg).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 2, 28 September 2026

  • Publisher: — → Springer Science+Business Media

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 5 keywords, 3 funders, 6 references.

Cite

This paper

Liao, J., Huang, L., Fang, R., Prater-Bennette, A., Shen, L., & Xu, Y. (2026). MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration. Journal of mathematical imaging and vision, 68(4), 48. https://doi.org/10.1007/s10851-026-01329-2

BibTeX

@article{liao2026mg,
author = {Liao, Jianmin and Huang, Lei and Fang, Ronglong and Prater-Bennette, Ashley and Shen, Lixin and Xu, Yuesheng},
title = {{MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration}},
journal = {Journal of mathematical imaging and vision},
year = {2026},
month = jul,
volume = {68},
number = {4},
pages = {48},
publisher = {Springer Science+Business Media},
issn = {0924-9907},
doi = {10.1007/s10851-026-01329-2},
url = {https://doi.org/10.1007/s10851-026-01329-2},
pmid = {42539614},
pmcid = {PMC13423958}
}

RIS

TY - JOUR
AU - Liao, Jianmin
AU - Huang, Lei
AU - Fang, Ronglong
AU - Prater-Bennette, Ashley
AU - Shen, Lixin
AU - Xu, Yuesheng
TI - MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration
T2 - Journal of mathematical imaging and vision
J2 - J Math Imaging Vis
PY - 2026
DA - 2026/07/30
VL - 68
IS - 4
SP - 48
SN - 0924-9907
PB - Springer Science+Business Media
DO - 10.1007/s10851-026-01329-2
UR - https://doi.org/10.1007/s10851-026-01329-2
LA - en
ER -

CSL-JSON

{
"id": "10.1007/s10851-026-01329-2",
"type": "article-journal",
"title": "MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration",
"container-title": "Journal of mathematical imaging and vision",
"author": [
{
"family": "Liao",
"given": "Jianmin"
},
{
"family": "Huang",
"given": "Lei"
},
{
"family": "Fang",
"given": "Ronglong"
},
{
"family": "Prater-Bennette",
"given": "Ashley"
},
{
"family": "Shen",
"given": "Lixin"
},
{
"family": "Xu",
"given": "Yuesheng"
}
],
"container-title-short": "J Math Imaging Vis",
"volume": "68",
"issue": "4",
"page": "48",
"DOI": "10.1007/s10851-026-01329-2",
"PMID": "42539614",
"PMCID": "PMC13423958",
"ISSN": "0924-9907",
"publisher": "Springer Science+Business Media",
"URL": "https://doi.org/10.1007/s10851-026-01329-2",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
30
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1016/j.isci.2026.117375 [code]
Motor priming is associated with widespread recruitment into neural ensembles and more rapid ensemble transitions.
Journal: iScience
In common: OpenCV, PyTorch, NumPy, systems
[2] doi:10.1038/s41593-026-02388-9 [code]
Hippocampal CA3 connectomics reveals a gradient of mossy fiber inputs and selective feedforward inhibition onto pyramidal cells.
Journal: Nature neuroscience
In common: OpenCV, PyTorch, NumPy, systems
[3] doi:10.1038/s41467-026-76011-7 [code]
Human cortex organizes dynamic co-fluctuations along the sensorimotor-association axis.
Journal: Nature communications
In common: OpenCV, PyTorch, NumPy, systems
[4] doi:10.1016/j.isci.2026.116825 [code]
Social hierarchy shapes behavioral and transcriptional responses to chronic stress and ketamine in male mice.
Journal: iScience
In common: OpenCV, PyTorch, NumPy, systems
[5] doi:10.1016/j.isci.2026.116206 [code]
Gut distension evokes rapid neural dynamics in vagal and hindbrain populations of larval zebrafish.
Journal: iScience
In common: OpenCV, PyTorch, NumPy, systems
[6] doi:10.1371/journal.pbio.3003824 [code]
Flexible goal learning involves coordinated population activity in dCA1 and medial orbitofrontal cortex.
Journal: PLoS biology
In common: OpenCV, PyTorch, NumPy, systems
[7] doi:10.1371/journal.pcbi.1013138 [code]
Hierarchical recurrent temporal prediction as a model of the mammalian dorsal visual pathway.
Journal: PLoS computational biology
In common: OpenCV, PyTorch, NumPy, systems
[8] doi:10.1038/s41467-026-72057-9 [code]
Sex-specific behavioral feedback modulates sensorimotor processing and drives flexible social behavior.
Journal: Nature communications
In common: OpenCV, PyTorch, NumPy, systems
[9] doi:10.1038/s41593-026-02232-0 [code]
Entorhinal cortex represents task-relevant remote locations independently of CA1.
Journal: Nature neuroscience
In common: OpenCV, PyTorch, NumPy, systems
[10] doi:10.1007/s00429-026-03166-w [code]
Autoencoders for unsupervised analysis of rat myeloarchitecture.
Journal: Brain structure & function
In common: OpenCV, PyTorch, NumPy

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.