MG-SpaIR: Multi-Grade Sparse-Guided Implicit Representation for Training-Data-Free Image Restoration.
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] § 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] § 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
- import cog
- import tempfile
- from pathlib import Path
- import argparse
- import shutil
- import os
- import cv2
- import glob
- import torch
- from collections import OrderedDict
- import numpy as np
- from main_test_swinir import define_model, setup, get_image_pair
- class Predictor(cog.Predictor):
- def setup(self):
- model_dir = 'experiments/pretrained_models'
- self.model_zoo = {
- 'real_sr': {
- 4: os.path.join(model_dir, '003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth')
- },
- 'gray_dn': {
- 15: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise15.pth'),
- 25: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise25.pth'),
- 50: os.path.join(model_dir, '004_grayDN_DFWB_s128w8_SwinIR-M_noise50.pth')
- },
- 'color_dn': {
- 15: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise15.pth'),
- 25: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise25.pth'),
- 50: os.path.join(model_dir, '005_colorDN_DFWB_s128w8_SwinIR-M_noise50.pth')
- },
- 'jpeg_car': {
- 10: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg10.pth'),
- 20: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg20.pth'),
- 30: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg30.pth'),
- 40: os.path.join(model_dir, '006_CAR_DFWB_s126w7_SwinIR-M_jpeg40.pth')
- }
- }
- parser = argparse.ArgumentParser()
- parser.add_argument('--task', type=str, default='real_sr', help='classical_sr, lightweight_sr, real_sr, '
- 'gray_dn, color_dn, jpeg_car')
- parser.add_argument('--scale', type=int, default=1, help='scale factor: 1, 2, 3, 4, 8') # 1 for dn and jpeg car
- parser.add_argument('--noise', type=int, default=15, help='noise level: 15, 25, 50')
- parser.add_argument('--jpeg', type=int, default=40, help='scale factor: 10, 20, 30, 40')
- parser.add_argument('--training_patch_size', type=int, default=128, help='patch size used in training SwinIR. '
- 'Just used to differentiate two different settings in Table 2 of the paper. '
- 'Images are NOT tested patch by patch.')
- parser.add_argument('--large_model', action='store_true',
- help='use large model, only provided for real image sr')
- parser.add_argument('--model_path', type=str,
- default=self.model_zoo['real_sr'][4])
- parser.add_argument('--folder_lq', type=str, default=None, help='input low-quality test image folder')
- parser.add_argument('--folder_gt', type=str, default=None, help='input ground-truth test image folder')
- self.args = parser.parse_args('')
- self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
- self.tasks = {
- 'Real-World Image Super-Resolution': 'real_sr',
- 'Grayscale Image Denoising': 'gray_dn',
- 'Color Image Denoising': 'color_dn',
- 'JPEG Compression Artifact Reduction': 'jpeg_car'
- }
- @cog.input("image", type=Path, help="input image")
- @cog.input("task_type", type=str, default='Real-World Image Super-Resolution',
- options=['Real-World Image Super-Resolution', 'Grayscale Image Denoising', 'Color Image Denoising',
- 'JPEG Compression Artifact Reduction'],
- help="image restoration task type")
- @cog.input("noise", type=int, default=15, options=[15, 25, 50],
- help='noise level, activated for Grayscale Image Denoising and Color Image Denoising. '
- 'Leave it as default or arbitrary if other tasks are selected')
- @cog.input("jpeg", type=int, default=40, options=[10, 20, 30, 40],
- help='scale factor, activated for JPEG Compression Artifact Reduction. '
- 'Leave it as default or arbitrary if other tasks are selected')
- def predict(self, image, task_type='Real-World Image Super-Resolution', jpeg=40, noise=15):
- self.args.task = self.tasks[task_type]
- self.args.noise = noise
- self.args.jpeg = jpeg
- # set model path
- if self.args.task == 'real_sr':
- self.args.scale = 4
- self.args.model_path = self.model_zoo[self.args.task][4]
- elif self.args.task in ['gray_dn', 'color_dn']:
- self.args.model_path = self.model_zoo[self.args.task][noise]
- else:
- self.args.model_path = self.model_zoo[self.args.task][jpeg]
- try:
- # set input folder
- input_dir = 'input_cog_temp'
- os.makedirs(input_dir, exist_ok=True)
- input_path = os.path.join(input_dir, os.path.basename(image))
- shutil.copy(str(image), input_path)
- if self.args.task == 'real_sr':
- self.args.folder_lq = input_dir
- else:
- self.args.folder_gt = input_dir
- model = define_model(self.args)
- model.eval()
- model = model.to(self.device)
- # setup folder and path
- folder, save_dir, border, window_size = setup(self.args)
- os.makedirs(save_dir, exist_ok=True)
- test_results = OrderedDict()
- test_results['psnr'] = []
- test_results['ssim'] = []
- test_results['psnr_y'] = []
- test_results['ssim_y'] = []
- test_results['psnr_b'] = []
- # psnr, ssim, psnr_y, ssim_y, psnr_b = 0, 0, 0, 0, 0
- out_path = Path(tempfile.mkdtemp()) / "out.png"
- for idx, path in enumerate(sorted(glob.glob(os.path.join(folder, '*')))):
- # read image
- imgname, img_lq, img_gt = get_image_pair(self.args, path) # image to HWC-BGR, float32
- img_lq = np.transpose(img_lq if img_lq.shape[2] == 1 else img_lq[:, :, [2, 1, 0]],
- (2, 0, 1)) # HCW-BGR to CHW-RGB
- img_lq = torch.from_numpy(img_lq).float().unsqueeze(0).to(self.device) # CHW-RGB to NCHW-RGB
- # inference
- with torch.no_grad():
- # pad input image to be a multiple of window_size
- _, _, h_old, w_old = img_lq.size()
- h_pad = (h_old // window_size + 1) * window_size - h_old
- w_pad = (w_old // window_size + 1) * window_size - w_old
- img_lq = torch.cat([img_lq, torch.flip(img_lq, [2])], 2)[:, :, :h_old + h_pad, :]
- img_lq = torch.cat([img_lq, torch.flip(img_lq, [3])], 3)[:, :, :, :w_old + w_pad]
- output = model(img_lq)
- output = output[..., :h_old * self.args.scale, :w_old * self.args.scale]
- # save image
- output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
- if output.ndim == 3:
- output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0)) # CHW-RGB to HCW-BGR
- output = (output * 255.0).round().astype(np.uint8) # float32 to uint8
- cv2.imwrite(str(out_path), output)
- finally:
- clean_folder(input_dir)
- return out_path
- def clean_folder(folder):
- for filename in os.listdir(folder):
- file_path = os.path.join(folder, filename)
- try:
- if os.path.isfile(file_path) or os.path.islink(file_path):
- os.unlink(file_path)
- elif os.path.isdir(file_path):
- shutil.rmtree(file_path)
- except Exception as e:
- print('Failed to delete %s. Reason: %s' % (file_path, e))
predict.py at commit 6545850, under Apache-2.0 · at the source
Overview
- Department of Mathematics, Syracuse University, 215 Carnegie Building, Syracuse, NY 13210 USA
- Department of Mathematics & Statistics, Old Dominion University, 2300 Engineering & Computational Sciences Building, Norfolk, VA 23529 USA
- Department of Medical Physical, Memorial Sloan Kettering Cancer Center, 1250 First Avenue, New York, NY 10065 USA
- Air Force Research Laboratory, 525 Brooks Road, Rome, NY 13441 USA
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
6545850fbf8df298df73d81f3e8cba638787c8bd, 4 December 2022Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
7 files
- download-weights.sh — Shell, 13 lines, 1 match
- main_test_swinir.py — Python, 309 lines
- models/
network_swinir.py — Python, 867 lines - predict.py — Python, 159 lines, 1 match
- utils/
util_calculate_psnr_ssim — Python, 346 lines.py - LICENSE — License, 201 lines
- README.md — Text, 254 lines
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
- kaggle.com/
datasets/ — at Kaggle; found in “Data Availability”daehoyang - kaggle.com/
datasets/ — at Kaggle; found in “Data Availability”ll01dm
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://
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://
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/
url = {https://
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/
VL - 68
IS - 4
SP - 48
SN - 0924-9907
PB - Springer Science+Business Media
DO - 10.1007/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1007/
"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":
"volume": "68",
"issue": "4",
"page": "48",
"DOI": "10.1007/
"PMID": "42539614",
"PMCID": "PMC13423958",
"ISSN": "0924-9907",
"publisher": "Springer Science+Business Media",
"URL": "https://
"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: iScienceIn 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 neuroscienceIn 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 communicationsIn 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: iScienceIn 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: iScienceIn 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 biologyIn 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 biologyIn 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 communicationsIn 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 neuroscienceIn common: OpenCV, PyTorch, NumPy, systems
- [10] doi:10.1007/s00429-026-03166-w [code]
- Autoencoders for unsupervised analysis of rat myeloarchitecture.Journal: Brain structure & functionIn 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 5 scripts, and 2 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:95aeadc42b5bd965…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
