← Open Source
ohayonguy

PMRF

[ICLR 2025] Official implementation of Posterior-Mean Rectified Flow: Towards Minimum MSE Photo-Realistic Image Restoration.

Model DevelopmentArchitecturePython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
754
Stars
42
Forks
+0
This week
1
Contributors
Created 2024-09-30 · Updated 2026-10-08 · #14188 today
Top developers
ohayonguy

ohayonguy/PMRF is ranked 14,188 with 754 stars.

Same-category comparison

ohayonguy/PMRF is ranked 14,188 among these 8 peers; nnsvs/nnsvs is ranked 14,187.

Same-category comparison
NameRankMetrics
ZikangZhou/HiVT14,179
Language:
Python
Stars:
754
Forks:
128
Description:
[CVPR 2022] HiVT: Hierarchical Vector Transformer for Multi-Agent Motion Prediction.
bytedance/res-adapter14,181
Language:
Python
Stars:
754
Forks:
27
Description:
[AAAI 2025] Official codes of "ResAdapter: Domain Consistent Resolution Adapter for Diffusion Models".
facebookresearch/InterHand2.6M14,183
Language:
Python
Stars:
754
Forks:
91
Description:
Official PyTorch implementation of "InterHand2.6M: A Dataset and Baseline for 3D Interacting Hand Pose Estimation from a Single RGB Image", ECCV 2020.
nnsvs/nnsvs14,187
Language:
Python
Stars:
754
Forks:
84
Description:
Neural network-based singing voice synthesis library for research.
open-mmlab/mmfewshot14,189
Language:
Python
Stars:
754
Forks:
126
Description:
OpenMMLab FewShot Learning Toolbox and Benchmark.
snap-research/GRID14,192
Language:
Python
Stars:
754
Forks:
132
Description:
GRID: Generative Recommendation with Semantic IDs.
taki0112/SENet-Tensorflow14,193
Language:
Python
Stars:
754
Forks:
265
Description:
Simple Tensorflow implementation of "Squeeze and Excitation Networks" using Cifar10 (ResNeXt, Inception-v4, Inception-resnet-v2).
hfawaz/InceptionTime14,199
Language:
Python
Stars:
753
Forks:
161
Description:
InceptionTime: Finding AlexNet for Time Series Classification.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryArchitecture
KeywordsImage production
Stars754
Forks42
Contributors1
Created date2024-09-30
Updated date2026-10-08
Stars in 1 day0
Stars in 7 days0
Rank14,188
Previous rank14,053
Rank change-135
7-day stars rank14,341
Previous 7-day stars rank14,354
7-day stars rank change13
Total stars rank14,019
Previous total stars rank13,992
Total stars rank change-27
CountryUSA
README summary

It (provably) approximates the **optimal** estimator that minimizes the Mean Squared Error (MSE) under a perfect perceptual quality constraint. WIDER-Test visual comparison WebPhoto-Test visual comparison ⚙️ Installation **Note for Windows users:** *It appears that several Windows users have been unable to install the package, which is required in order to use the HDiT model architecture in PMRF. A solution that worked for several people is suggested here. If you couldn't solve this issue, you may train PMRF using a

different architecture (e. * We created a conda environment by running the following commands, exactly in the given order (these are given in the file): 1. Note that the package is required for the HDiT architecture used by PMRF. Make sure to replace with the correct CUDA version installed on your system. We installed because otherwise got hanging for some reason. may work in your system without this package. In any case, if you wish to do so, you may simply

skip this package and/or remove all the lines from our code. Due to a compatibility issue in , you will need to modify one of the files in this package. Open , where is the path where your conda installed the environment. Then, change the line to ⬇️ Downloads 🌐 Model checkpoints We provide our blind face image restoration model checkpoint in Hugging Face and in Google Drive. 2 in the paper (the controlled experiments) can be downloaded from Google Drive. Please keep

the same folder structure as provided in Google Drive: To evaluate the landmark distance (LMD in the paper) and the identity metric (Deg in the paper), you will also need to download the and checkpoints from the Google Drive of VQFR. 🌐 Test data sets for blind face image restoration 1. Download WebPhoto-Test, LFW-Test, and CelebA-Test (HQ and LQ) from 2. Put these data sets wherever you want in your system. 🧑 Blind face image restoration (section 5. 1

in the paper) ⚡ Quick inference To quickly use our model, we provide a Hugging Face checkpoint which is automatically downloaded. Simply run Please alter as you wish (this is the hyper-parameter in our paper) You may also provide a local model checkpoint (e. , if you train your own PMRF model, or if you wish to use our Google Drive checkpoint instead of the Hugging Face one). Simply run Importantly, note that our blind face image restoration model is trained

to handle square and aligned face images. To restore general content face images (e. , where there is more than one face in the image), you may use our Hugging Face demo. We downloaded the and checkpoints from the Google Drive of VQFR, and put these in the folder . To evaluate the results on CelebA-Test, run: To evaluate the results on the real-world data sets, run: The argument is optional, and allows you to compute IndRMSE, as an indicator

of the true RMSE for real-world degraded images. Note that the MMSE reconstructions are saved automatically when you run

Frequently asked questions

How many stars and forks are recorded?

ohayonguy/PMRF has 754 stars and 42 forks.

What is the repository rank?

ohayonguy/PMRF is ranked 14,188.

What language and category are recorded?

ohayonguy/PMRF has 754 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

ohayonguy/PMRF is compared with nnsvs/nnsvs, ranked 14,187 with 754 stars.

README

Posterior-Mean Rectified Flow:

Towards Minimum MSE Photo-Realistic Image Restoration
(ICLR 2025)

[Paper] [Project Page] [Demo]

Guy Ohayon, Tomer Michaeli, Michael Elad

Technion—Israel Institute of Technology

PMRF is a novel photo-realistic image restoration algorithm. It (provably) approximates the optimal estimator that minimizes the Mean Squared Error (MSE) under a perfect perceptual quality constraint.

 ![](assets/flow.png) 

📈 Some results from our paper

CelebA-Test quantitative comparison

Red, blue and green indicate the best, the second best and the third best scores, respectively.

WIDER-Test visual comparison

WebPhoto-Test visual comparison

⚙️ Installation

Note for Windows users: It appears that several Windows users have been unable to install the natten package, which is required in order to use the HDiT model architecture in PMRF. A solution that worked for several people is suggested here. If you couldn't solve this issue, you may train PMRF using a different architecture (e.g. UNet) and avoid using the natten package.

We created a conda environment by running the following commands, exactly in the given order (these are given in the install.sh file):

conda create -n pmrf python=3.10
conda activate pmrf
conda install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 pytorch-cuda=11.8 -c pytorch -c nvidia
conda install lightning==2.3.3 -c conda-forge
pip install opencv-python==4.10.0.84 timm==1.0.8 wandb==0.17.5 lovely-tensors==0.1.16 torch-fidelity==0.3.0 einops==0.8.0 dctorch==0.1.2 torch-ema==0.3
pip install natten==0.17.1+torch230cu118 -f https://shi-labs.com/natten/wheels
pip install nvidia-cuda-nvcc-cu11
pip install basicsr==1.4.2
pip install git+https://github.com/toshas/torch-fidelity.git
pip install lpips==0.1.4
pip install piq==0.8.0
pip install huggingface_hub==0.24.5
  1. Note that the package natten is required for the HDiT architecture used by PMRF. Make sure to replace natten==0.17.1+torch230cu118 with the correct CUDA version installed on your system. Check out https://shi-labs.com/natten/ for the available versions.
  2. We installed nvidia-cuda-nvcc-cu11 because otherwise torch.compile got hanging for some reason. torch.compile may work in your system without this package. In any case, if you wish to do so, you may simply skip this package and/or remove all the torch.compile lines from our code.
  3. Due to a compatibility issue in basicsr, you will need to modify one of the files in this package. Open /path/to/env/pmrf/lib/python3.10/site-packages/basicsr/data/degradations.py, where /path/to/env is the path where your conda installed the pmrf environment. Then, change the line
from torchvision.transforms.functional_tensor import rgb_to_grayscale

to

from torchvision.transforms.functional import rgb_to_grayscale

⬇️ Downloads

🌐 Model checkpoints

We provide our blind face image restoration model checkpoint in Hugging Face and in Google Drive. The checkpoints for section 5.2 in the paper (the controlled experiments) can be downloaded from Google Drive. Please keep the same folder structure as provided in Google Drive:

checkpoints/
├── blind_face_restoration_pmrf.ckpt    # Checkpoint of our blind face image restoration model.
├── swinir_restoration512_L1.pth    # Checkpoint of the SwinIR model trained by DifFace
├── controlled_experiments/     # Checkpoints for the controlled experiments
│   ├── colorization_gaussian_noise_025/
│   │   ├── pmrf/
│   │   │   └── epoch=999-step=273000.ckpt
│   │   ├── mmse/
│   │   │   └── epoch=999-step=273000.ckpt
.   .   .
.   .   .
.   .   .

To evaluate the landmark distance (LMD in the paper) and the identity metric (Deg in the paper), you will also need to download the resnet18_110.pth and alignment_WFLW_4HG.pth checkpoints from the Google Drive of VQFR. Place these checkpoints in the evaluation/metrics_ckpt/ folder.

🌐 Test data sets for blind face image restoration

  1. Download WebPhoto-Test, LFW-Test, and CelebA-Test (HQ and LQ) from https://xinntao.github.io/projects/gfpgan.
  2. Download WIDER-Test from https://shangchenzhou.com/projects/CodeFormer/.
  3. Put these data sets wherever you want in your system.

🧑 Blind face image restoration (section 5.1 in the paper)

⚡ Quick inference

To quickly use our model, we provide a Hugging Face checkpoint which is automatically downloaded. Simply run

python inference.py \
--ckpt_path ohayonguy/PMRF_blind_face_image_restoration \
--ckpt_path_is_huggingface \
--lq_data_path /path/to/lq/images \
--output_dir /path/to/results/dir \
--batch_size 64 \
--num_flow_steps 25

Please alter --num_flow_steps as you wish (this is the hyper-parameter K in our paper)

You may also provide a local model checkpoint (e.g., if you train your own PMRF model, or if you wish to use our Google Drive checkpoint instead of the Hugging Face one). Simply run

python inference.py \
--ckpt_path ./checkpoints/blind_face_restoration_pmrf.ckpt \
--lq_data_path /path/to/lq/images \
--output_dir /path/to/results/dir \
--batch_size 64 \
--num_flow_steps 25

Importantly, note that our blind face image restoration model is trained to handle square and aligned face images. To restore general content face images (e.g., where there is more than one face in the image), you may use our Hugging Face demo.

🔬 Evaluation

  1. We downloaded the resnet18_110.pth and alignment_WFLW_4HG.pth checkpoints from the Google Drive of VQFR, and put these in the folder evaluation/metrics_ckpt/. To evaluate the results on CelebA-Test, run:
cd evaluation
python compute_metrics_blind.py \
--parent_ffhq_512_path /path/to/parent/of/ffhq512 \
--rec_path /path/to/celeba-512-test/restored/images \
--gt_path /path/to/celeba-512-test/ground-truth/images

To evaluate the results on the real-world data sets, run:

cd evaluation
python compute_metrics_blind.py \
--parent_ffhq_512_path /path/to/parent/of/ffhq512 \
--rec_path /path/to/real-world/restored/images \
--mmse_rec_path /path/to/mmse/restored/images

The --mmse_rec_path argument is optional, and allows you to compute IndRMSE, as an indicator of the true RMSE for real-world degraded images. Note that the MMSE reconstructions are saved automatically when you run inference.py, since the MMSE model is also in the PMRF checkpoint.

💻 Training

In the folder scripts/ we provide the training scripts we used for blind face image restoration and for training the baseline models as well. If you want to run a script, you need to execute it in the root folder (where train.py is located). To train the model, you will need the FFHQ data set. We downloaded the original FFHQ 1024x1024 data set and down-sampled the images to size 512x512 using bi-cubic down-sampling.

  1. Copy the train_pmrf.sh file (located in scripts/train/blind_face_restoration) to the root folder.
  2. Adjust the arguments --train_data_root and --val_data_root according to the location of the training and validation data in your system.
  3. The SwinIR model which was trained by DifFace is provided in the checkpoints/ folder. We downloaded it via
wget https://github.com/zsyOAOA/DifFace/releases/download/V1.0/swinir_restoration512_L1.pth
  1. Adjust the argument --mmse_model_ckpt_path to the path of the SwinIR model.
  2. Adjust the arguments --num_gpus and --num_workers according to your system.
  3. Run the script train_pmrf.sh to train our model.

👩‍🔬 Controlled experiments (section 5.2 in the paper)

We provide training and evaluation codes for the controlled experiments in our paper, where we compare PMRF with the following baseline methods:

  1. Flow conditioned on Y: A rectified flow model which is conditioned on the input measurement, and learns to flow from pure noise to the ground-truth data distribution.
  2. Flow conditioned on the posterior mean predictor: A rectified flow model which is conditioned on the posterior mean prediction, and learns to flow from pure noise to the ground-truth data distribution.
  3. Flow from Y: A rectified flow model which flows from the degraded measurement to the ground-truth data distribution.
  4. Posterior mean predictor: A model which is trained to minimize the MSE loss.

🔬 Evaluation

We provide checkpoints for quick evaluation of PMRF and all the baseline methods.

  1. The evaluation is conducted on CelebA-Test images of size 256x256. To acquire such images, we downloaded the CelebA-Test (HQ) images from GFPGAN, and down-sampled them to 256x256 using bi-cubic down-sampling.
  2. Adjust --test_data_root in test.sh to the path of the CelebA-Test 256x256 images, and adjust --degradation and --ckpt_path to the type of degradation you wish to assess and the corresponding model checkpoint.
  3. Run test.sh.

We automatically save the reconstructed outputs, the degraded measurements, as well as the samples from the source distribution (the images from which the ODE solver begins). After running test.sh, you may evaluate the results via :

cd evaluation
python compute_metrics_controlled_experiments.py \
--parent_ffhq_256_path /path/to/parent/of/ffhq256 \
--rec_path /path/to/restored/images \
--gt_path /path/to/celeba-256-test/ground-truth/images

💻 Training

  • We trained our models on FFHQ 256x256. To acquire such images, with down-sampled the original FFHQ 1024x1024 images using bi-cubic down-sampling.
  • The training scripts of PMRF and each of these baseline models are provided in the scripts/train/controlled_experiments/ folder.
  • To run each of these scripts, you need to copy it to the root folder where train.py is located. All you need to do is adjust the --degradation, --source_noise_std, --train_data_root and --val_data_root arguments in each script. For denoising, we used --source_noise_std 0.025, and for the rest of the tasks we used --source_noise_std 0.1.
  • To run the train_pmrf.sh and train_posterior_conditioned_on_mmse_model.sh scripts, you first need to train the MMSE model via train_mmse.sh. Then, adjust the --mmse_model_ckpt_path argument according to the path of the MMSE model final checkpoint.

📝 Citation

@inproceedings{
    ohayon2025posteriormean,
    title={Posterior-Mean Rectified Flow: Towards Minimum {MSE} Photo-Realistic Image Restoration},
    author={Guy Ohayon and Tomer Michaeli and Michael Elad},
    booktitle={The Thirteenth International Conference on Learning Representations},
    year={2025},
    url={https://openreview.net/forum?id=hPOt3yUXii}
}

📋 License and acknowledgements

This project is released under the MIT license.

We borrow codes from BasicSR, VQFR, DifFace, k-diffusion, and SwinIR. We thank the authors of these repositories for their useful implementations.

📧 Contact

If you have any questions or inquiries, please feel free to contact me.

Nearby in the ranking
Similar items