zsxkib / diffbir

✨DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior

replicate.com
Total runs: 132.7K
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Github
Model's Last Updated: October 12 2023

Introduction of diffbir

Model Details of diffbir

Readme

DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior

Paper | Project Page

visitors Open in OpenXLab Open In Colab Replicate

Xinqi Lin <sup>1,*</sup>, Jingwen He <sup>2,*</sup>, Ziyan Chen <sup>2</sup>, Zhaoyang Lyu <sup>2</sup>, Ben Fei <sup>2</sup>, Bo Dai <sup>2</sup>, Wanli Ouyang <sup>2</sup>, Yu Qiao <sup>2</sup>, Chao Dong <sup>1,2</sup>

<sup>1</sup>Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences
<sup>2</sup>Shanghai AI Laboratory

:star:If DiffBIR is helpful for you, please help star this repo. Thanks!:hugs:

:book:Table Of Contents
:eyes:Visual Results On Real-world Images
General Image Restoration

Face Image Restoration

:star: Face and the background enhanced by DiffBIR.

:new:Update
  • 2023.09.19 : ✅ Add support for Apple Silicon! Check installation_xOS.md to work with CPU/CUDA/MPS device!
  • 2023.09.14 : ✅ Integrate a patch-based sampling strategy ( mixture-of-diffusers ). Try it! Here is an example with a resolution of 2396 x 1596. GPU memory usage will continue to be optimized in the future and we are looking forward to your pull requests!
  • 2023.09.14 : ✅ Add support for background upsampler(DiffBIR/ RealESRGAN ) in face enhancement! :rocket: Try it!
  • 2023.09.13 : :rocket: Provide online demo (DiffBIR-official) in OpenXLab , which integrates both general model and face model. Please have a try! camenduru also implements an online demo, thanks for his work.:hugs:
  • 2023.09.12 : ✅ Upload inference code of latent image guidance and release real47 testset.
  • 2023.09.08 : ✅ Add support for restoring unaligned faces.
  • 2023.09.06 : :rocket: Update colab demo . Thanks to camenduru !:hugs:
  • 2023.08.30 : This repo is released.
:climbing:TODO
  • [x] Release code and pretrained models:computer:.
  • [x] Update links to paper and project page:link:.
  • [x] Release real47 testset:minidisc:.
  • [ ] Provide webui and reduce the memory usage of DiffBIR:fire::fire::fire:.
  • [ ] Provide HuggingFace demo:notebook::fire::fire::fire:.
  • [x] Add a patch-based sampling schedule:mag:.
  • [x] Upload inference code of latent image guidance:page_facing_up:.
  • [ ] Improve the performance:superhero:.
  • [x] Support MPS acceleration for MacOS users.
:gear:Installation
# clone this repo
git clone https://github.com/XPixelGroup/DiffBIR.git
cd DiffBIR

# create an environment with python >= 3.9
conda create -n diffbir python=3.9
conda activate diffbir
pip install -r requirements.txt

Note the installation is only compatible with Linux users. If you are working on different platforms, please check xOS Installation .

:dna:Pretrained Models
Model Name Description HuggingFace BaiduNetdisk OpenXLab
general_swinir_v1.ckpt Stage1 model (SwinIR) for general image restoration. download download (pwd: v3v6) download
general_full_v1.ckpt Full model for general image restoration. “Full” means it contains both the stage1 and stage2 model. download download (pwd: 86zi) download
face_swinir_v1.ckpt Stage1 model (SwinIR) for face restoration. download download (pwd: xk5u) download
face_full_v1.ckpt Full model for face restoration. download download (pwd: ov8i) download
:flight_departure:Quick Start

Download general_full_v1.ckpt and general_swinir_v1.ckpt to weights/ , then run the following command to interact with the gradio website.

python gradio_diffbir.py \
--ckpt weights/general_full_v1.ckpt \
--config configs/model/cldm.yaml \
--reload_swinir \
--swinir_ckpt weights/general_swinir_v1.ckpt \
--device cuda
<div align="center"> </div>
:crossed_swords:Inference
Full Pipeline (Remove Degradations & Refine Details)

General Image

Download general_full_v1.ckpt and general_swinir_v1.ckpt to weights/ and run the following command.

python inference.py \
--input inputs/demo/general \
--config configs/model/cldm.yaml \
--ckpt weights/general_full_v1.ckpt \
--reload_swinir --swinir_ckpt weights/general_swinir_v1.ckpt \
--steps 50 \
--sr_scale 4 \
--color_fix_type wavelet \
--output results/demo/general \
--device cuda [--tiled --tile_size 512 --tile_stride 256]

Remove the brackets to enable tiled sampling. If you are confused about where the reload_swinir option came from, please refer to the degradation details .

Face Image

The face_full_v1.ckpt will be downloaded from HuggingFace automatically.

# for aligned face inputs
python inference_face.py \
--input inputs/demo/face/aligned \
--sr_scale 1 \
--output results/demo/face/aligned \
--has_aligned \
--device cuda

# for unaligned face inputs
python inference_face.py \
--input inputs/demo/face/whole_img \
--sr_scale 2 \
--output results/demo/face/whole_img \
--bg_upsampler DiffBIR \
--device cuda
Latent Image Guidance (Quality-fidelity trade-off)

Latent image guidance is used to achieve a trade-off bwtween quality and fidelity. We default to closing it since we prefer quality rather than fidelity. Here is an example:

python inference.py \
--input inputs/demo/general \
--config configs/model/cldm.yaml \
--ckpt weights/general_full_v1.ckpt \
--reload_swinir --swinir_ckpt weights/general_swinir_v1.ckpt \
--steps 50 \
--sr_scale 4 \
--color_fix_type wavelet \
--output results/demo/general \
--device cuda \
--use_guidance --g_scale 400 --g_t_start 200

You will see that the results become more smooth.

Only Stage1 Model (Remove Degradations)

Download general_swinir_v1.ckpt , face_swinir_v1.ckpt for general, face image respectively, and run the following command.

python scripts/inference_stage1.py \
--config configs/model/swinir.yaml \
--ckpt [swinir_ckpt_path] \
--input [lq_dir] \
--sr_scale 1 --image_size 512 \
--output [output_dir_path]
Only Stage2 Model (Refine Details)

Since the proposed two-stage pipeline is very flexible, you can utilize other awesome models to remove degradations instead of SwinIR and then leverage the Stable Diffusion to refine details.

# step1: Use other models to remove degradations and save results in [img_dir_path].

# step2: Refine details of step1 outputs.
python inference.py \
--config configs/model/cldm.yaml \
--ckpt [full_ckpt_path] \
--steps 50 --sr_scale 1 \
--input [img_dir_path] \
--color_fix_type wavelet \
--output [output_dir_path] \
--disable_preprocess_model \
--device cuda
:stars:Train
Degradation Details

For general image restoration, we first train both the stage1 and stage2 model under codeformer degradation to enhance the generative capacity of the stage2 model. In order to improve the ability for degradation removal, we train another stage1 model under Real-ESRGAN degradation and utilize it during inference.

For face image restoration, we adopt the degradation model used in DifFace for training and directly utilize the SwinIR model released by them as our stage1 model.

Data Preparation
  1. Generate file list of training set and validation set.

    shell python scripts/ make_file_list.py \ --img_folder [hq_dir_path] \ --val_size [validation_set_size] \ --save_folder [save_dir_path] \ --follow_links

    This script will collect all image files in img_folder and split them into training set and validation set automatically. You will get two file lists in save_folder , each line in a file list contains an absolute path of an image file:

    save_folder ├── train.list # training file list └── val.list # validation file list

  2. Configure training set and validation set.

    For general image restoration, fill in the following configuration files with appropriate values.

    For face image restoration, fill in the face training set and validation set configuration files with appropriate values.

Train Stage1 Model
  1. Configure training-related information.

    Fill in the configuration file of training with appropriate values.

  2. Start training.

    shell python train.py --config [training_config_path]

    :bulb::Checkpoints of SwinIR will be used in training stage2 model.

Train Stage2 Model
  1. Download pretrained Stable Diffusion v2.1 to provide generative capabilities.

    shell wget https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.ckpt --no-check-certificate

  2. Create the initial model weights.

    shell python scripts/ make_stage2_init_weight.py \ --cldm_config configs/model/cldm.yaml \ --sd_weight [sd_v2.1_ckpt_path] \ --swinir_weight [swinir_ckpt_path] \ --output [init_weight_output_path]

    You will see some outputs which show the weight initialization.

  3. Configure training-related information.

    Fill in the configuration file of training with appropriate values.

  4. Start training.

    shell python train.py --config [training_config_path]

Citation

Please cite us if our work is useful for your research.

@article{2023diffbir,
  author    = {Xinqi Lin, Jingwen He, Ziyan Chen, Zhaoyang Lyu, Ben Fei, Bo Dai, Wanli Ouyang, Yu Qiao, Chao Dong},
  title     = {DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior},
  journal   = {arxiv},
  year      = {2023},
}
License

This project is released under the Apache 2.0 license .

Acknowledgement

This project is based on ControlNet and BasicSR . Thanks for their awesome work.

Contact

If you have any questions, please feel free to contact with me at [email protected].

Pricing of diffbir replicate.com

Run time and cost

This model costs approximately $0.23 to run on Replicate, or 4 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker .

This model runs on Nvidia A40 (Large) GPU hardware . Predictions typically complete within 6 minutes. The predict time for this model varies significantly based on the inputs.

Runs of zsxkib diffbir on replicate.com

132.7K
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About diffbir replicate.com Model

diffbir replicate.com

diffbir replicate.com is an AI model on replicate.com that provides diffbir's model effect (✨DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior), which can be used instantly with this zsxkib diffbir model. replicate.com supports a free trial of the diffbir model, and also provides paid use of the diffbir. Support call diffbir model through api, including Node.js, Python, http.

zsxkib diffbir online free

diffbir replicate.com is an online trial and call api platform, which integrates diffbir's modeling effects, including api services, and provides a free online trial of diffbir, you can try diffbir online for free by clicking the link below.

zsxkib diffbir online free url in replicate.com:

https://replicate.com/zsxkib/diffbir

diffbir install

diffbir is an open source model from GitHub that offers a free installation service, and any user can find diffbir on GitHub to install. At the same time, replicate.com provides the effect of diffbir install, users can directly use diffbir installed effect in replicate.com for debugging and trial. It also supports api for free installation.

diffbir install url in replicate.com:

https://replicate.com/zsxkib/diffbir

diffbir install url in github:

https://github.com/XPixelGroup/DiffBIR

Url of diffbir

Provider of diffbir replicate.com

Other API from zsxkib

replicate

Blip 3 / XGen-MM, Answers questions about images ({blip3,xgen-mm}-phi3-mini-base-r-v1)

Total runs: 1.2M
Run Growth: 0
Growth Rate: 0.00%
Updated:May 13 2024
replicate

📖 PuLID: Pure and Lightning ID Customization via Contrastive Alignment

Total runs: 1.2M
Run Growth: 0
Growth Rate: 0.00%
Updated:May 16 2024
replicate

Make realistic images of real people instantly

Total runs: 848.9K
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

Create song covers with any RVC v2 trained AI voice from audio files.

Total runs: 637.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 16 2023
replicate

⚡️FLUX PuLID: FLUX-dev based Pure and Lightning ID Customization via Contrastive Alignment🎭

Total runs: 601.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 16 2024
replicate

🎨 Fill in masked parts of images with FLUX.1-dev 🖌️

Total runs: 349.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 20 2024
replicate

Add sound to video using the MMAudio V2 model. An advanced AI model that synthesizes high-quality audio from video content, enabling seamless video-to-audio transformation.

Total runs: 283.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

✍️✨Prompts to auto-magically relights your images

Total runs: 207.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:May 21 2024
replicate

Age prediction using CLIP - Patched version of `https://replicate.com/andreasjansson/clip-age-predictor` that works with the new version of cog!

Total runs: 189.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 07 2023
replicate

allenai/Molmo-7B-D-0924, Answers questions and caption about images

Total runs: 88.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 27 2024
replicate

Jina-CLIP v2: 0.9B multimodal embedding model with 89-language multilingual support, 512x512 image resolution, and Matryoshka representations

Total runs: 76.0K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 28 2024
replicate

🎨 AnimateDiff (w/ MotionLoRAs for Panning, Zooming, etc): Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning

Total runs: 56.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 06 2023
replicate

📽️ Increase Framerate 🎬 ST-MFNet: A Spatio-Temporal Multi-Flow Network for Frame Interpolation

Total runs: 51.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 09 2023
replicate

Hunyuan-Video LoRA Explorer + Trainer

Total runs: 31.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:January 25 2025
replicate

Monster Labs' Controlnet QR Code Monster v2 For SD-1.5 on top of AnimateDiff Prompt Travel (Motion Module SD 1.5 v2)

Total runs: 10.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 01 2023
replicate

🖼️✨Background images + prompts to auto-magically relights your images (+normal maps🗺️)

Total runs: 10.0K
Run Growth: 0
Growth Rate: 0.00%
Updated:May 21 2024
replicate

Real-Time Open-Vocabulary Object Detection

Total runs: 9.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:February 12 2024
replicate

AuraSR v2: Second-gen GAN-based Super-Resolution for real-world applications

Total runs: 9.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 01 2024
replicate

Create your own Realistic Voice Cloning (RVC v2) dataset using a YouTube link

Total runs: 8.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 21 2023
replicate

Text-to-Video + Image-to-Video: Pyramid Flow Autoregressive Video Generation method based on Flow Matching

Total runs: 8.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 11 2024
replicate

🎨 Fill in masked parts of images with FLUX.1-schnell 🖌️

Total runs: 6.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 16 2024
replicate

🎨AnimateDiff Prompt Travel🧭 Seamlessly Navigate and Animate Between Text-to-Image Prompts for Dynamic Visual Narratives

Total runs: 5.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 19 2023
replicate

FlashFace: Human Image Personalization with High-fidelity Identity Preservation

Total runs: 4.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 23 2024
replicate

Make realistic images of real people instantly (w/ ip-adapter-plus-face_sdxl_vit-h)

Total runs: 3.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:July 15 2024
replicate

Upscale videos + images with BSRGAN

Total runs: 2.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:January 29 2025
replicate

Transform your portrait photos into any style or setting while preserving your facial identity

Total runs: 2.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 03 2025
replicate

MimicMotion: High-quality human motion video generation with pose-guided control

Total runs: 2.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:July 16 2024
replicate

AuraSR: GAN-based Super-Resolution for real-world

Total runs: 2.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 28 2024
replicate

🖼️ Super fast 1.5B Image Captioning/VQA Multimodal LLM (Image-to-Text) 🖋️

Total runs: 2.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:February 02 2024
replicate

Idefics3-8B-Llama3, Answers questions and caption about images

Total runs: 2.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 15 2024
replicate

Qwen 2: A 7 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 1.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 26 2024
replicate

A state-of-the-art text-to-video generation model capable of creating high-quality videos with realistic motion from text descriptions

Total runs: 1.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

Cubiq's ComfyUI InstantID node running `instantid_basic.json` example

Total runs: 1.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 20 2024
replicate

🎼FluxMusic Text-to-Music Generation with Rectified Flow Transformer🎶

Total runs: 1.3K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 26 2024
replicate

✨Stable Diffusion 3 w/ ⚡InstantX's Canny, Pose, and Tile ControlNets🖼️

Total runs: 1.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 22 2024
replicate

Image tagger fine-tuned on WaifuDiffusion w/ (SwinV2, SwinV2, ConvNext, and ViT)

Total runs: 1000
Run Growth: 0
Growth Rate: 0.00%
Updated:May 22 2024
replicate

🫦 Realistic facial expression manipulation (lip-syncing) using audio or video

Total runs: 1000
Run Growth: 0
Growth Rate: 0.00%
Updated:June 12 2024
replicate

Unofficial Re-Trained AnimateAnyone (Image + DWPose Video → Animated Video of Image)

Total runs: 853
Run Growth: 0
Growth Rate: 0.00%
Updated:January 19 2024
replicate

🎙️Hololive text-to-speech and voice-to-voice (Japanese🇯🇵 + English🇬🇧)

Total runs: 850
Run Growth: 0
Growth Rate: 0.00%
Updated:June 04 2024
replicate

MEMO is a state-of-the-art open-weight model for audio-driven talking video generation.

Total runs: 678
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

🐲 DragGAN 🐉 - "Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold"

Total runs: 583
Run Growth: 0
Growth Rate: 0.00%
Updated:July 07 2023
replicate

Easily create video datasets with auto-captioning for Hunyuan-Video LoRA finetuning

Total runs: 532
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

Surrealist digital art featuring whimsical, anthropomorphic characters with exaggerated textures and vibrant color blocking

Total runs: 480
Run Growth: 0
Growth Rate: 0.00%
Updated:October 09 2024
replicate

Transform your text into a beautiful two-tone color gradient that represents your emotions.

Total runs: 417
Run Growth: 0
Growth Rate: 0.00%
Updated:June 06 2023
replicate

STAR Video Upscaler: Spatial-Temporal Augmentation with Text-to-Video Models for Real-World Video Super-Resolution

Total runs: 382
Run Growth: 0
Growth Rate: 0.00%
Updated:February 01 2025
replicate

Super High Quality Depth Maps 🗺️: An End-to-End Tile-Based Framework 🏗️ for High-Resolution Monocular Metric Depth Estimation 🔍📏

Total runs: 362
Run Growth: 0
Growth Rate: 0.00%
Updated:December 27 2023
replicate

Qwen 2: A 1.5 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 207
Run Growth: 0
Growth Rate: 0.00%
Updated:June 26 2024
replicate

Qwen 2: A 0.5 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 198
Run Growth: 0
Growth Rate: 0.00%
Updated:June 25 2024
replicate

Generates realistic talking face animations from a portrait image and audio using the CVPR 2025 Sonic model

Total runs: 148
Run Growth: 0
Growth Rate: 0.00%
Updated:April 03 2025
replicate

Powerful text-to-video model that generates high-quality videos up to 6 seconds at 15 FPS and 720p resolution from simple text prompt

Total runs: 128
Run Growth: 0
Growth Rate: 0.00%
Updated:October 23 2024
replicate

Convert speech in audio to text w/ `tiny`, `small`, `base`, and `large-v3` models

Total runs: 126
Run Growth: 0
Growth Rate: 0.00%
Updated:July 02 2024
replicate

SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory

Total runs: 100
Run Growth: 0
Growth Rate: 0.00%
Updated:November 28 2024
replicate

Generate high-quality videos from text prompts using StepVideo

Total runs: 93
Run Growth: 0
Growth Rate: 0.00%
Updated:February 25 2025
replicate

🗣️ TalkNet-ASD: Detect who is speaking in a video

Total runs: 92
Run Growth: 0
Growth Rate: 0.00%
Updated:May 02 2024
replicate

A "Hello World" model for me to get to grips with `cog` and Replicate

Total runs: 44
Run Growth: 0
Growth Rate: 0.00%
Updated:June 06 2023
replicate

Cost-optimized MMAudio V2 (T4 GPU): Add sound to video using this version running on T4 hardware for lower cost. Synthesizes high-quality audio from video content.

Total runs: 21
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

SAM 2: Segment Anything v2 (for in Images + Videos)

Total runs: 19
Run Growth: 0
Growth Rate: 0.00%
Updated:July 31 2024
replicate

Hibiki: High-Fidelity Simultaneous Speech-To-Speech Translation

Total runs: 12
Run Growth: 0
Growth Rate: 0.00%
Updated:February 11 2025
replicate

Remove background from images using BRIA-RMBG-2.0

Total runs: 2
Run Growth: 0
Growth Rate: 0.00%
Updated:November 25 2024