Commit c18c4eb6 authored by mashun1's avatar mashun1
Browse files

diffbir

parent 7bd56758
......@@ -9,3 +9,4 @@ __pycache__
/temp
/results
.ipynb_checkpoints/
*checkpoints
FROM image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py39-latest
COPY . /tmp/
WORKDIR /tmp
RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
<p align="center">
<img src="assets/logo.png" width="400">
</p>
# DiffBIR
## DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior
## 论文
[Paper](https://arxiv.org/abs/2308.15070) | [Project Page](https://0x3f3f3f3fun.github.io/projects/diffbir/)
**DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior**
![visitors](https://visitor-badge.laobi.icu/badge?page_id=XPixelGroup/DiffBIR) [![Open in OpenXLab](https://cdn-static.openxlab.org.cn/app-center/openxlab_app.svg)](https://openxlab.org.cn/apps/detail/linxinqi/DiffBIR-official) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/DiffBIR-colab/blob/main/DiffBIR_colab.ipynb)
* https://arxiv.org/abs/2308.15070
[Xinqi Lin](https://0x3f3f3f3fun.github.io/)<sup>1,\*</sup>, [Jingwen He](https://github.com/hejingwenhejingwen)<sup>2,\*</sup>, [Ziyan Chen](https://orcid.org/0000-0001-6277-5635)<sup>2</sup>, [Zhaoyang Lyu](https://scholar.google.com.tw/citations?user=gkXFhbwAAAAJ&hl=en)<sup>2</sup>, [Ben Fei](https://scholar.google.com/citations?user=skQROj8AAAAJ&hl=zh-CN&oi=ao)<sup>2</sup>, [Bo Dai](http://daibo.info/)<sup>2</sup>, [Wanli Ouyang](https://wlouyang.github.io/)<sup>2</sup>, [Yu Qiao](http://mmlab.siat.ac.cn/yuqiao)<sup>2</sup>, [Chao Dong](http://xpixel.group/2010/01/20/chaodong.html)<sup>1,2</sup>
## 模型结构
<sup>1</sup>Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences<br><sup>2</sup>Shanghai AI Laboratory
第一阶段模型使用8个Swin Transformer blocks(RSTB),每个RSTB中包含6个Swin Transformer Layers(STL),其中head数为6,window size为8.
<p align="center">
<img src="assets/architecture.png" style="border-radius: 15px">
</p>
第二阶段模型基于Stable Diffusioin 2.1-base,创建了一个与Unet中encoder block与middle block相同的网络。
:star:If DiffBIR is helpful for you, please help star this repo. Thanks!:hugs:
![Alt text](images/image.png)
## :book:Table Of Contents
## 算法原理
- [Visual Results On Real-world Images](#visual_results)
- [Update](#update)
- [TODO](#todo)
- [Installation](#installation)
- [Pretrained Models](#pretrained_models)
- [Quick Start (gradio demo)](#quick_start)
- [Inference](#inference)
- [Train](#train)
用途:该算法为两阶段算法,可以提升图像的分辨率。
## <a name="visual_results"></a>:eyes:Visual Results On Real-world Images
第一阶段使用复原模块,从具有未知和复杂降质的低质量(LQ)图像中恢复清晰图像;
<!-- <details close>
<summary>General Image Restoration</summary> -->
### General Image Restoration
第二阶段使用生成模块来重新生成丢失的信息。
[<img src="assets/visual_results/general6.png" height="223px"/>](https://imgsli.com/MTk5ODI3) [<img src="assets/visual_results/general7.png" height="223px"/>](https://imgsli.com/MTk5ODI4) [<img src="assets/visual_results/general4.png" height="223px"/>](https://imgsli.com/MTk5ODI1)
## 环境配置
[<img src="assets/visual_results/general1.png" height="223px"/>](https://imgsli.com/MTk5ODIy) [<img src="assets/visual_results/general2.png" height="223px"/>](https://imgsli.com/MTk5ODIz)
[<img src="assets/visual_results/general3.png" height="223px"/>](https://imgsli.com/MTk5ODI0) [<img src="assets/visual_results/general5.png" height="223px"/>](https://imgsli.com/MjAxMjM0)
### Docker(方法一)
<!-- </details> -->
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py39-latest
docker run --shm-size 10g --network=host --name=diffbir --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home/ -it <your IMAGE ID> bash
pip install -r requirements.txt
<!-- <details close> -->
<!-- <summary>Face Image Restoration</summary> -->
### Face Image Restoration
[<img src="assets/visual_results/face1.png" height="223px"/>](https://imgsli.com/MTk5ODI5) [<img src="assets/visual_results/face2.png" height="223px"/>](https://imgsli.com/MTk5ODMw) [<img src="assets/visual_results/face4.png" height="223px"/>](https://imgsli.com/MTk5ODM0)
### Docker(方法二)
[<img src="assets/visual_results/whole_image1.png" height="370"/>](https://imgsli.com/MjA2MTU0)
[<img src="assets/visual_results/whole_image2.png" height="370"/>](https://imgsli.com/MjA2MTQ4)
<!-- [<img src="assets/visual_results/whole_image3.png" height="268"/>](https://imgsli.com/MjA1OTY2) -->
<!-- [<img src="assets/visual_results/face3.png" height="223px"/>](https://imgsli.com/MTk5ODMy) -->
<!-- [<img src="assets/visual_results/face5.png" height="223px"/>](https://imgsli.com/MTk5ODM1) -->
# 需要在对应的目录下
docker build -t <IMAGE_NAME>:<TAG> .
# <your IMAGE ID>用以上拉取的docker的镜像ID替换
docker run -it --shm-size 10g --network=host --name=diffbir --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined <your IMAGE ID> bash
<!-- [<img src="assets/visual_results/whole_image1.png" height="410"/>](https://imgsli.com/MjA1OTU5) -->
### Anaconda (方法三)
1、关于本项目DCU显卡所需的特殊深度学习库可从光合开发者社区下载安装:
https://developer.hpccube.com/tool/
:star: Face and the background enhanced by DiffBIR.
DTK驱动:dtk23.04.1
python:python3.9
torch:1.13.1
torchvision:0.14.1
torchaudio:0.13.1
deepspeed:0.9.2
apex:0.1
<!-- </details> -->
Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应
## <a name="update"></a>:new:Update
2、其它非特殊库参照requirements.txt安装
- **2023.09.19**: ✅ Add support for Apple Silicon! Check [installation_xOS.md](assets/docs/installation_xOS.md) to work with **CPU/CUDA/MPS** device!
- **2023.09.14**: ✅ Integrate a patch-based sampling strategy ([mixture-of-diffusers](https://github.com/albarji/mixture-of-diffusers)). [**Try it!**](#general_image_inference) Here is an [example](https://imgsli.com/MjA2MDA1) 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](https://github.com/xinntao/Real-ESRGAN)) in face enhancement! :rocket: [**Try it!**](#unaligned_face_inference)
- **2023.09.13**: :rocket: Provide online demo (DiffBIR-official) in [OpenXLab](https://openxlab.org.cn/apps/detail/linxinqi/DiffBIR-official), which integrates both general model and face model. Please have a try! [camenduru](https://github.com/camenduru) also implements an online demo, thanks for his work.:hugs:
- **2023.09.12**: ✅ Upload inference code of latent image guidance and release [real47](inputs/real47) testset.
- **2023.09.08**: ✅ Add support for restoring unaligned faces.
- **2023.09.06**: :rocket: Update [colab demo](https://colab.research.google.com/github/camenduru/DiffBIR-colab/blob/main/DiffBIR_colab.ipynb). Thanks to [camenduru](https://github.com/camenduru)!:hugs:
- **2023.08.30**: This repo is released.
<!-- - [**History Updates** >]() -->
pip install -r requirements.txt
## <a name="todo"></a>: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.
下载地址(训练+测试集):https://www.image-net.org/ (imagenet1k)
## <a name="installation"></a>:gear:Installation
<!-- - **Python** >= 3.9
- **CUDA** >= 11.3
- **PyTorch** >= 1.12.1
- **xformers** == 0.0.16 -->
datasets
|- train
|- n01440764
|- xxx.JPEG
```shell
# 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](assets/docs/installation_xOS.md).
### 阶段一
<!-- ```shell
# clone this repo
git clone https://github.com/XPixelGroup/DiffBIR.git
cd DiffBIR
# create a conda environment with python >= 3.9
conda create -n diffbir python=3.9
conda activate diffbir
conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.3 -c pytorch
conda install xformers==0.0.16 -c xformers
# other dependencies
pip install -r requirements.txt
``` -->
## <a name="pretrained_models"></a>:dna:Pretrained Models
| Model Name | Description | HuggingFace | BaiduNetdisk | OpenXLab |
| :--------- | :---------- | :---------- | :---------- | :---------- |
| general_swinir_v1.ckpt | Stage1 model (SwinIR) for general image restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) | [download](https://pan.baidu.com/s/1uvSvJgcoL_Knj0h22-9TvA?pwd=v3v6) (pwd: v3v6) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_general_swinir_v1) |
| general_full_v1.ckpt | Full model for general image restoration. "Full" means it contains both the stage1 and stage2 model. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) | [download](https://pan.baidu.com/s/1gLvW1nvkJStdVAKROqaYaA?pwd=86zi) (pwd: 86zi) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_general_full_v1) |
| face_swinir_v1.ckpt | Stage1 model (SwinIR) for face restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_swinir_v1.ckpt) | [download](https://pan.baidu.com/s/1cnBBC8437BJiM3q6suaK8g?pwd=xk5u) (pwd: xk5u) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_face_swinir_v1) |
| face_full_v1.ckpt | Full model for face restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) | [download](https://pan.baidu.com/s/1pc04xvQybkynRfzK5Y8K0Q?pwd=ov8i) (pwd: ov8i) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_face_full_v1) |
## <a name="quick_start"></a>:flight_departure:Quick Start
Download [general_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) and [general_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) to `weights/`, then run the following command to interact with the gradio website.
```shell
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">
<kbd><img src="assets/gradio.png"></img></kbd>
</div>
## <a name="inference"></a>:crossed_swords:Inference
### Full Pipeline (Remove Degradations & Refine Details)
<a name="general_image_inference"></a>
#### General Image
Download [general_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) and [general_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) to `weights/` and run the following command.
```shell
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](#degradation-details).
#### Face Image
<!-- Download [face_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) to `weights/` and run the following command. -->
The [face_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) will be downloaded from HuggingFace automatically.
```shell
# 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
```
<a name="unaligned_face_inference"></a>
```shell
# 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:
```shell
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](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt), [face_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_swinir_v1.ckpt) for general, face image respectively, and run the following command.
```shell
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.
```shell
# 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
```
## <a name="train"></a>: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](https://github.com/zsyOAOA/DifFace/blob/master/configs/training/swinir_ffhq512.yaml) 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] \
1、数据准备:该操作用于生成训练以及验证数据路径列表
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.
2、修改配置文件
修改 `configs/dataset`中相应的yaml配置文件
For general image restoration, fill in the following configuration files with appropriate values.
修改 `configs/train_swinir.yaml`配置文件
- [training set](configs/dataset/general_deg_codeformer_train.yaml) and [validation set](configs/dataset/general_deg_codeformer_val.yaml) for **CodeFormer** degradation.
- [training set](configs/dataset/general_deg_realesrgan_train.yaml) and [validation set](configs/dataset/general_deg_realesrgan_val.yaml) for **Real-ESRGAN** degradation.
3、训练
python train.py --config [training_config_path]
For face image restoration, fill in the face [training set](configs/dataset/face_train.yaml) and [validation set](configs/dataset/face_val.yaml) configuration files with appropriate values.
注意:该阶段训练得到的模型将用于第二阶段的训练。
### Train Stage1 Model
### 阶段二
1. Configure training-related information.
1、模型准备(Stable Diffusion v2.1): https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.ckpt
Fill in the configuration file of [training](configs/train_swinir.yaml) with appropriate values.
2. Start training.
2、初始化模型参数
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] # 初始化模型保存地址
3、修改配置文件
修改`configs/train_cldm.yaml`配置文件
4、训练
```shell
python train.py --config [training_config_path]
```
:bulb::Checkpoints of SwinIR will be used in training stage2 model.
## 推理
### Train Stage2 Model
### general Image
1. Download pretrained [Stable Diffusion v2.1](https://huggingface.co/stabilityai/stable-diffusion-2-1-base) to provide generative capabilities.
模型下载地址:
* https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt
```shell
wget https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.ckpt --no-check-certificate
```
* https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt
2. Create the initial model weights.
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]
```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](assets/init_weight_outputs.txt) which show the weight initialization.
### Face Image
3. Configure training-related information.
模型下载地址:
Fill in the configuration file of [training](configs/train_cldm.yaml) with appropriate values.
* https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt
4. Start training.
for aligned face inputs
```shell
python train.py --config [training_config_path]
```
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
## result
恢复后的图像
![Alt text](images/samples_step-004900_e-000008_b-001203.png)
低质量图像
![Alt text](images/lq_step-004900_e-000008_b-001203.png)
### 精度
## 应用场景
## 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](LICENSE).
## 源码仓库及问题反馈
## Acknowledgement
This project is based on [ControlNet](https://github.com/lllyasviel/ControlNet) and [BasicSR](https://github.com/XPixelGroup/BasicSR). Thanks for their awesome work.
## Contact
## 参考
If you have any questions, please feel free to contact with me at linxinqi@tju.edu.cn.
* https://github.com/XPixelGroup/DiffBIR
* https://github.com/XPixelGroup/DiffBIR/issues/55
\ No newline at end of file
<p align="center">
<img src="assets/logo.png" width="400">
</p>
## DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior
[Paper](https://arxiv.org/abs/2308.15070) | [Project Page](https://0x3f3f3f3fun.github.io/projects/diffbir/)
![visitors](https://visitor-badge.laobi.icu/badge?page_id=XPixelGroup/DiffBIR) [![Open in OpenXLab](https://cdn-static.openxlab.org.cn/app-center/openxlab_app.svg)](https://openxlab.org.cn/apps/detail/linxinqi/DiffBIR-official) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/DiffBIR-colab/blob/main/DiffBIR_colab.ipynb)
[Xinqi Lin](https://0x3f3f3f3fun.github.io/)<sup>1,\*</sup>, [Jingwen He](https://github.com/hejingwenhejingwen)<sup>2,\*</sup>, [Ziyan Chen](https://orcid.org/0000-0001-6277-5635)<sup>2</sup>, [Zhaoyang Lyu](https://scholar.google.com.tw/citations?user=gkXFhbwAAAAJ&hl=en)<sup>2</sup>, [Ben Fei](https://scholar.google.com/citations?user=skQROj8AAAAJ&hl=zh-CN&oi=ao)<sup>2</sup>, [Bo Dai](http://daibo.info/)<sup>2</sup>, [Wanli Ouyang](https://wlouyang.github.io/)<sup>2</sup>, [Yu Qiao](http://mmlab.siat.ac.cn/yuqiao)<sup>2</sup>, [Chao Dong](http://xpixel.group/2010/01/20/chaodong.html)<sup>1,2</sup>
<sup>1</sup>Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences<br><sup>2</sup>Shanghai AI Laboratory
<p align="center">
<img src="assets/architecture.png" style="border-radius: 15px">
</p>
:star:If DiffBIR is helpful for you, please help star this repo. Thanks!:hugs:
## :book:Table Of Contents
- [Visual Results On Real-world Images](#visual_results)
- [Update](#update)
- [TODO](#todo)
- [Installation](#installation)
- [Pretrained Models](#pretrained_models)
- [Quick Start (gradio demo)](#quick_start)
- [Inference](#inference)
- [Train](#train)
## <a name="visual_results"></a>:eyes:Visual Results On Real-world Images
<!-- <details close>
<summary>General Image Restoration</summary> -->
### General Image Restoration
[<img src="assets/visual_results/general6.png" height="223px"/>](https://imgsli.com/MTk5ODI3) [<img src="assets/visual_results/general7.png" height="223px"/>](https://imgsli.com/MTk5ODI4) [<img src="assets/visual_results/general4.png" height="223px"/>](https://imgsli.com/MTk5ODI1)
[<img src="assets/visual_results/general1.png" height="223px"/>](https://imgsli.com/MTk5ODIy) [<img src="assets/visual_results/general2.png" height="223px"/>](https://imgsli.com/MTk5ODIz)
[<img src="assets/visual_results/general3.png" height="223px"/>](https://imgsli.com/MTk5ODI0) [<img src="assets/visual_results/general5.png" height="223px"/>](https://imgsli.com/MjAxMjM0)
<!-- </details> -->
<!-- <details close> -->
<!-- <summary>Face Image Restoration</summary> -->
### Face Image Restoration
[<img src="assets/visual_results/face1.png" height="223px"/>](https://imgsli.com/MTk5ODI5) [<img src="assets/visual_results/face2.png" height="223px"/>](https://imgsli.com/MTk5ODMw) [<img src="assets/visual_results/face4.png" height="223px"/>](https://imgsli.com/MTk5ODM0)
[<img src="assets/visual_results/whole_image1.png" height="370"/>](https://imgsli.com/MjA2MTU0)
[<img src="assets/visual_results/whole_image2.png" height="370"/>](https://imgsli.com/MjA2MTQ4)
<!-- [<img src="assets/visual_results/whole_image3.png" height="268"/>](https://imgsli.com/MjA1OTY2) -->
<!-- [<img src="assets/visual_results/face3.png" height="223px"/>](https://imgsli.com/MTk5ODMy) -->
<!-- [<img src="assets/visual_results/face5.png" height="223px"/>](https://imgsli.com/MTk5ODM1) -->
<!-- [<img src="assets/visual_results/whole_image1.png" height="410"/>](https://imgsli.com/MjA1OTU5) -->
:star: Face and the background enhanced by DiffBIR.
<!-- </details> -->
## <a name="update"></a>:new:Update
- **2023.09.19**: ✅ Add support for Apple Silicon! Check [installation_xOS.md](assets/docs/installation_xOS.md) to work with **CPU/CUDA/MPS** device!
- **2023.09.14**: ✅ Integrate a patch-based sampling strategy ([mixture-of-diffusers](https://github.com/albarji/mixture-of-diffusers)). [**Try it!**](#general_image_inference) Here is an [example](https://imgsli.com/MjA2MDA1) 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](https://github.com/xinntao/Real-ESRGAN)) in face enhancement! :rocket: [**Try it!**](#unaligned_face_inference)
- **2023.09.13**: :rocket: Provide online demo (DiffBIR-official) in [OpenXLab](https://openxlab.org.cn/apps/detail/linxinqi/DiffBIR-official), which integrates both general model and face model. Please have a try! [camenduru](https://github.com/camenduru) also implements an online demo, thanks for his work.:hugs:
- **2023.09.12**: ✅ Upload inference code of latent image guidance and release [real47](inputs/real47) testset.
- **2023.09.08**: ✅ Add support for restoring unaligned faces.
- **2023.09.06**: :rocket: Update [colab demo](https://colab.research.google.com/github/camenduru/DiffBIR-colab/blob/main/DiffBIR_colab.ipynb). Thanks to [camenduru](https://github.com/camenduru)!:hugs:
- **2023.08.30**: This repo is released.
<!-- - [**History Updates** >]() -->
## <a name="todo"></a>: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.
## <a name="installation"></a>:gear:Installation
<!-- - **Python** >= 3.9
- **CUDA** >= 11.3
- **PyTorch** >= 1.12.1
- **xformers** == 0.0.16 -->
```shell
# 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](assets/docs/installation_xOS.md).
<!-- ```shell
# clone this repo
git clone https://github.com/XPixelGroup/DiffBIR.git
cd DiffBIR
# create a conda environment with python >= 3.9
conda create -n diffbir python=3.9
conda activate diffbir
conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.3 -c pytorch
conda install xformers==0.0.16 -c xformers
# other dependencies
pip install -r requirements.txt
``` -->
## <a name="pretrained_models"></a>:dna:Pretrained Models
| Model Name | Description | HuggingFace | BaiduNetdisk | OpenXLab |
| :--------- | :---------- | :---------- | :---------- | :---------- |
| general_swinir_v1.ckpt | Stage1 model (SwinIR) for general image restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) | [download](https://pan.baidu.com/s/1uvSvJgcoL_Knj0h22-9TvA?pwd=v3v6) (pwd: v3v6) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_general_swinir_v1) |
| general_full_v1.ckpt | Full model for general image restoration. "Full" means it contains both the stage1 and stage2 model. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) | [download](https://pan.baidu.com/s/1gLvW1nvkJStdVAKROqaYaA?pwd=86zi) (pwd: 86zi) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_general_full_v1) |
| face_swinir_v1.ckpt | Stage1 model (SwinIR) for face restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_swinir_v1.ckpt) | [download](https://pan.baidu.com/s/1cnBBC8437BJiM3q6suaK8g?pwd=xk5u) (pwd: xk5u) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_face_swinir_v1) |
| face_full_v1.ckpt | Full model for face restoration. | [download](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) | [download](https://pan.baidu.com/s/1pc04xvQybkynRfzK5Y8K0Q?pwd=ov8i) (pwd: ov8i) | [download](https://download.openxlab.org.cn/models/linxinqi/DiffBIR/weight//diffbir_face_full_v1) |
## <a name="quick_start"></a>:flight_departure:Quick Start
Download [general_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) and [general_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) to `weights/`, then run the following command to interact with the gradio website.
```shell
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">
<kbd><img src="assets/gradio.png"></img></kbd>
</div>
## <a name="inference"></a>:crossed_swords:Inference
### Full Pipeline (Remove Degradations & Refine Details)
<a name="general_image_inference"></a>
#### General Image
Download [general_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt) and [general_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt) to `weights/` and run the following command.
```shell
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](#degradation-details).
#### Face Image
<!-- Download [face_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) to `weights/` and run the following command. -->
The [face_full_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_full_v1.ckpt) will be downloaded from HuggingFace automatically.
```shell
# 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
```
<a name="unaligned_face_inference"></a>
```shell
# 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:
```shell
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](https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt), [face_swinir_v1.ckpt](https://huggingface.co/lxq007/DiffBIR/resolve/main/face_swinir_v1.ckpt) for general, face image respectively, and run the following command.
```shell
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.
```shell
# 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
```
## <a name="train"></a>: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](https://github.com/zsyOAOA/DifFace/blob/master/configs/training/swinir_ffhq512.yaml) 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.
- [training set](configs/dataset/general_deg_codeformer_train.yaml) and [validation set](configs/dataset/general_deg_codeformer_val.yaml) for **CodeFormer** degradation.
- [training set](configs/dataset/general_deg_realesrgan_train.yaml) and [validation set](configs/dataset/general_deg_realesrgan_val.yaml) for **Real-ESRGAN** degradation.
For face image restoration, fill in the face [training set](configs/dataset/face_train.yaml) and [validation set](configs/dataset/face_val.yaml) configuration files with appropriate values.
### Train Stage1 Model
1. Configure training-related information.
Fill in the configuration file of [training](configs/train_swinir.yaml) 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](https://huggingface.co/stabilityai/stable-diffusion-2-1-base) 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](assets/init_weight_outputs.txt) which show the weight initialization.
3. Configure training-related information.
Fill in the configuration file of [training](configs/train_cldm.yaml) 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](LICENSE).
## Acknowledgement
This project is based on [ControlNet](https://github.com/lllyasviel/ControlNet) and [BasicSR](https://github.com/XPixelGroup/BasicSR). Thanks for their awesome work.
## Contact
If you have any questions, please feel free to contact with me at linxinqi@tju.edu.cn.
......@@ -2,7 +2,7 @@ dataset:
target: dataset.realesrgan.RealESRGANDataset
params:
# Path to the file list.
file_list:
file_list: train_data_path/train.list
out_size: 512
crop_type: center
......@@ -28,9 +28,9 @@ dataset:
final_sinc_prob: 0.8
data_loader:
batch_size: 32
batch_size: 1
shuffle: true
num_workers: 16
num_workers: 2
prefetch_factor: 2
drop_last: true
......@@ -40,7 +40,7 @@ batch_transform:
use_sharpener: false
resize_hq: false
# Queue size of training pool, this should be multiples of batch_size.
queue_size: 256
queue_size: 128
# the first degradation process
resize_prob: [0.2, 0.7, 0.1] # up, down, keep
resize_range: [0.15, 1.5]
......
......@@ -2,7 +2,7 @@ dataset:
target: dataset.realesrgan.RealESRGANDataset
params:
# Path to the file list.
file_list:
file_list: train_data_path/val.list
out_size: 512
crop_type: center
......@@ -28,9 +28,9 @@ dataset:
final_sinc_prob: 0.8
data_loader:
batch_size: 32
batch_size: 1
shuffle: false
num_workers: 16
num_workers: 2
prefetch_factor: 2
drop_last: true
......@@ -40,7 +40,7 @@ batch_transform:
use_sharpener: false
resize_hq: false
# Queue size of training pool, this should be multiples of batch_size.
queue_size: 256
queue_size: 128
# the first degradation process
resize_prob: [0.2, 0.7, 0.1] # up, down, keep
resize_range: [0.15, 1.5]
......
......@@ -2,16 +2,16 @@ data:
target: dataset.data_module.BIRDataModule
params:
# Path to training set configuration file.
train_config:
train_config: configs/dataset/general_deg_realesrgan_train.yaml
# Path to validation set configuration file.
val_config:
val_config: configs/dataset/general_deg_realesrgan_val.yaml
model:
# You can set learning rate in the following configuration file.
config: configs/model/cldm.yaml
# Path to the checkpoints or weights you want to resume. At the begining,
# this should be set to the initial weights created by scripts/make_stage2_init_weight.py.
resume:
resume: weights/init.pth
lightning:
seed: 231
......@@ -20,28 +20,28 @@ lightning:
accelerator: ddp
precision: 32
# Indices of GPUs used for training.
gpus: [0, 1, 2, 3, 4, 5]
gpus: [5,6,7]
# Path to save logs and checkpoints.
default_root_dir:
default_root_dir: stage2_checkpoints
# Max number of training steps (batches).
max_steps: 25001
max_steps: 5000
# Validation frequency in terms of training steps.
val_check_interval: 500
log_every_n_steps: 50
val_check_interval: 100
log_every_n_steps: 500
# Accumulate gradients from multiple batches so as to increase batch size.
accumulate_grad_batches: 1
accumulate_grad_batches: 4
callbacks:
- target: model.callbacks.ImageLogger
params:
# Log frequency of image logger.
log_every_n_steps: 1000
max_images_each_step: 4
log_every_n_steps: 100
max_images_each_step: 2
log_images_kwargs: ~
- target: model.callbacks.ModelCheckpoint
params:
# Frequency of saving checkpoints.
every_n_train_steps: 5000
every_n_train_steps: 500
save_top_k: -1
filename: "{step}"
......@@ -2,9 +2,9 @@ data:
target: dataset.data_module.BIRDataModule
params:
# Path to training set configuration file.
train_config:
train_config: configs/dataset/general_deg_realesrgan_train.yaml
# Path to validation set configuration file.
val_config:
val_config: configs/dataset/general_deg_realesrgan_val.yaml
model:
# You can set learning rate in the following configuration file.
......@@ -19,29 +19,29 @@ lightning:
accelerator: ddp
precision: 32
# Indices of GPUs used for training.
gpus: [0, 1, 2]
gpus: [5,7]
# Path to save logs and checkpoints.
default_root_dir:
default_root_dir: stage1_checkpoints
# Max number of training steps (batches).
max_steps: 150001
max_steps: 10000
# Validation frequency in terms of training steps.
val_check_interval: 500
val_check_interval: 0.25
# Log frequency of tensorboard logger.
log_every_n_steps: 50
log_every_n_steps: 100
# Accumulate gradients from multiple batches so as to increase batch size.
accumulate_grad_batches: 1
accumulate_grad_batches: 2
callbacks:
- target: model.callbacks.ImageLogger
params:
# Log frequency of image logger.
log_every_n_steps: 1000
max_images_each_step: 4
max_images_each_step: 2
log_images_kwargs: ~
- target: model.callbacks.ModelCheckpoint
params:
# Frequency of saving checkpoints.
every_n_train_steps: 10000
every_n_train_steps: 1000
save_top_k: -1
filename: "{step}"
......@@ -6,6 +6,7 @@ from transformers import T5Tokenizer, T5EncoderModel, CLIPTokenizer, CLIPTextMod
import open_clip
from ldm.util import default, count_params
from pathlib import Path
class AbstractEncoder(nn.Module):
......@@ -145,7 +146,11 @@ class FrozenOpenCLIPEmbedder(AbstractEncoder):
freeze=True, layer="last"):
super().__init__()
assert layer in self.LAYERS
model, _, _ = open_clip.create_model_and_transforms(arch, device=torch.device('cpu'), pretrained=version)
# model, _, _ = open_clip.create_model_and_transforms(arch, device=torch.device('cpu'), pretrained=version)
# modify
pretrained = Path(__file__).resolve().parent.parent.parent.parent / "weights" / "open_clip_pytorch_model.bin"
print(str(pretrained))
model, _, _ = open_clip.create_model_and_transforms(arch, device=torch.device('cpu'), pretrained=str(pretrained))
del model.visual
self.model = model
......
......@@ -375,25 +375,20 @@ class ControlLDM(LatentDiffusion):
log["decoded_control"] = (self.decode_first_stage(c_latent) + 1) / 2
log["lq"] = c_lq
log["text"] = (log_txt_as_img((512, 512), batch[self.cond_stage_key], size=16) + 1) / 2
samples = self.sample_log(
# TODO: remove c_concat from cond
cond={"c_concat": [c_cat], "c_crossattn": [c], "c_latent": [c_latent]},
log["samples"] = self.sample_log(
cond_img=c_cat,
steps=sample_steps
)
x_samples = self.decode_first_stage(samples)
log["samples"] = (x_samples + 1) / 2
return log
@torch.no_grad()
def sample_log(self, cond, steps):
def sample_log(self, cond_img, steps):
sampler = SpacedSampler(self)
b, c, h, w = cond["c_concat"][0].shape
b, c, h, w = cond_img.shape
shape = (b, self.channels, h // 8, w // 8)
samples = sampler.sample(
steps, shape, cond, unconditional_guidance_scale=1.0,
unconditional_conditioning=None
steps, shape, cond_img, positive_prompt="", negative_prompt="",
cfg_scale=1.0, color_fix_type="wavelet"
)
return samples
......
......@@ -501,15 +501,14 @@ class SpacedSampler:
steps: int,
shape: Tuple[int],
cond_img: torch.Tensor,
positive_prompt: str,
negative_prompt: str,
positive_prompt: str = '',
negative_prompt: str = '',
x_T: Optional[torch.Tensor]=None,
cfg_scale: float=1.,
cond_fn: Optional[Guidance]=None,
color_fix_type: str="none"
) -> torch.Tensor:
self.make_schedule(num_steps=steps)
device = next(self.model.parameters()).device
b = shape[0]
if x_T is None:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
--extra-index-url https://download.pytorch.org/whl/cu116
torch==1.13.1+cu116
torchvision==0.14.1+cu116
xformers==0.0.16
pytorch_lightning==1.4.2
einops
open-clip-torch
omegaconf
torchmetrics==0.6.0
triton==2.0.0
opencv-python-headless
scipy
matplotlib
......
This source diff could not be displayed because it is too large. You can view the blob instead.
../datasets/images/german_shorthaired_3.jpg
../datasets/images/Sphynx_164.jpg
../datasets/images/english_cocker_spaniel_185.jpg
../datasets/images/english_setter_76.jpg
../datasets/images/chihuahua_75.jpg
../datasets/images/chihuahua_172.jpg
../datasets/images/german_shorthaired_78.jpg
../datasets/images/beagle_52.jpg
../datasets/images/keeshond_165.jpg
../datasets/images/Siamese_173.jpg
../datasets/images/beagle_47.jpg
../datasets/images/boxer_44.jpg
../datasets/images/great_pyrenees_92.jpg
../datasets/images/beagle_99.jpg
../datasets/images/yorkshire_terrier_67.jpg
../datasets/images/american_pit_bull_terrier_118.jpg
../datasets/images/english_setter_186.jpg
../datasets/images/samoyed_130.jpg
../datasets/images/havanese_131.jpg
../datasets/images/pug_89.jpg
../datasets/images/chihuahua_6.jpg
../datasets/images/great_pyrenees_197.jpg
../datasets/images/english_setter_158.jpg
../datasets/images/wheaten_terrier_69.jpg
../datasets/images/boxer_51.jpg
../datasets/images/Bombay_11.jpg
../datasets/images/Persian_185.jpg
../datasets/images/miniature_pinscher_196.jpg
../datasets/images/boxer_131.jpg
../datasets/images/pomeranian_125.jpg
../datasets/images/Birman_114.jpg
../datasets/images/newfoundland_119.jpg
../datasets/images/British_Shorthair_77.jpg
../datasets/images/Bombay_131.jpg
../datasets/images/pomeranian_130.jpg
../datasets/images/english_setter_193.jpg
../datasets/images/miniature_pinscher_19.jpg
../datasets/images/great_pyrenees_59.jpg
../datasets/images/pug_57.jpg
../datasets/images/newfoundland_41.jpg
../datasets/images/great_pyrenees_87.jpg
../datasets/images/Russian_Blue_155.jpg
../datasets/images/Abyssinian_119.jpg
../datasets/images/miniature_pinscher_183.jpg
../datasets/images/samoyed_125.jpg
../datasets/images/beagle_120.jpg
../datasets/images/samoyed_23.jpg
../datasets/images/Sphynx_73.jpg
../datasets/images/leonberger_158.jpg
../datasets/images/Ragdoll_121.jpg
../datasets/images/Siamese_64.jpg
../datasets/images/Siamese_85.jpg
../datasets/images/english_cocker_spaniel_164.jpg
../datasets/images/american_bulldog_207.jpg
../datasets/images/english_setter_63.jpg
../datasets/images/Bombay_213.jpg
../datasets/images/staffordshire_bull_terrier_147.jpg
../datasets/images/Sphynx_59.jpg
../datasets/images/beagle_202.jpg
../datasets/images/english_setter_49.jpg
../datasets/images/wheaten_terrier_56.jpg
../datasets/images/great_pyrenees_149.jpg
../datasets/images/Persian_30.jpg
../datasets/images/english_setter_82.jpg
../datasets/images/german_shorthaired_135.jpg
../datasets/images/great_pyrenees_182.jpg
../datasets/images/havanese_64.jpg
../datasets/images/Bengal_158.jpg
../datasets/images/yorkshire_terrier_142.jpg
../datasets/images/Persian_164.jpg
../datasets/images/Russian_Blue_80.jpg
../datasets/images/Bengal_50.jpg
../datasets/images/keeshond_191.jpg
../datasets/images/Bengal_193.jpg
../datasets/images/Sphynx_92.jpg
../datasets/images/english_cocker_spaniel_37.jpg
../datasets/images/Maine_Coon_238.jpg
../datasets/images/shiba_inu_29.jpg
../datasets/images/samoyed_36.jpg
../datasets/images/Sphynx_246.jpg
../datasets/images/Egyptian_Mau_188.jpg
../datasets/images/miniature_pinscher_177.jpg
../datasets/images/newfoundland_126.jpg
../datasets/images/leonberger_22.jpg
../datasets/images/yorkshire_terrier_157.jpg
../datasets/images/english_cocker_spaniel_22.jpg
../datasets/images/german_shorthaired_99.jpg
../datasets/images/pomeranian_43.jpg
../datasets/images/Abyssinian_126.jpg
../datasets/images/saint_bernard_50.jpg
../datasets/images/Abyssinian_133.jpg
../datasets/images/chihuahua_186.jpg
../datasets/images/pomeranian_88.jpg
../datasets/images/Bengal_167.jpg
../datasets/images/basset_hound_155.jpg
../datasets/images/chihuahua_81.jpg
../datasets/images/keeshond_184.jpg
../datasets/images/Ragdoll_36.jpg
../datasets/images/leonberger_167.jpg
../datasets/images/Russian_Blue_262.jpg
../datasets/images/basset_hound_22.jpg
../datasets/images/chihuahua_158.jpg
../datasets/images/american_bulldog_212.jpg
../datasets/images/Siamese_159.jpg
../datasets/images/beagle_135.jpg
../datasets/images/miniature_pinscher_162.jpg
../datasets/images/staffordshire_bull_terrier_152.jpg
../datasets/images/Egyptian_Mau_85.jpg
../datasets/images/Bengal_45.jpg
../datasets/images/wheaten_terrier_4.jpg
../datasets/images/newfoundland_133.jpg
../datasets/images/British_Shorthair_54.jpg
../datasets/images/havanese_71.jpg
../datasets/images/german_shorthaired_90.jpg
../datasets/images/wheaten_terrier_43.jpg
../datasets/images/american_bulldog_23.jpg
../datasets/images/wheaten_terrier_88.jpg
../datasets/images/japanese_chin_132.jpg
../datasets/images/wheaten_terrier_94.jpg
../datasets/images/beagle_129.jpg
../datasets/images/Sphynx_2.jpg
../datasets/images/english_setter_97.jpg
../datasets/images/keeshond_153.jpg
../datasets/images/British_Shorthair_83.jpg
../datasets/images/pug_127.jpg
../datasets/images/Persian_39.jpg
../datasets/images/Persian_171.jpg
../datasets/images/Abyssinian_33.jpg
../datasets/images/boxer_67.jpg
../datasets/images/keeshond_198.jpg
../datasets/images/British_Shorthair_136.jpg
../datasets/images/japanese_chin_91.jpg
../datasets/images/pug_74.jpg
../datasets/images/yorkshire_terrier_51.jpg
../datasets/images/scottish_terrier_9.jpg
../datasets/images/yorkshire_terrier_86.jpg
../datasets/images/Abyssinian_232.jpg
../datasets/images/Bombay_32.jpg
../datasets/images/Maine_Coon_36.jpg
../datasets/images/Russian_Blue_95.jpg
../datasets/images/havanese_112.jpg
../datasets/images/Russian_Blue_176.jpg
../datasets/images/Siamese_78.jpg
../datasets/images/British_Shorthair_41.jpg
../datasets/images/english_cocker_spaniel_178.jpg
../datasets/images/wheaten_terrier_138.jpg
../datasets/images/pomeranian_106.jpg
../datasets/images/keeshond_146.jpg
../datasets/images/havanese_78.jpg
../datasets/images/wheaten_terrier_81.jpg
../datasets/images/Birman_122.jpg
../datasets/images/german_shorthaired_129.jpg
../datasets/images/scottish_terrier_48.jpg
../datasets/images/english_setter_55.jpg
../datasets/images/pug_61.jpg
../datasets/images/staffordshire_bull_terrier_185.jpg
../datasets/images/scottish_terrier_83.jpg
../datasets/images/staffordshire_bull_terrier_190.jpg
../datasets/images/staffordshire_bull_terrier_22.jpg
../datasets/images/British_Shorthair_123.jpg
../datasets/images/basset_hound_149.jpg
../datasets/images/boxer_107.jpg
../datasets/images/shiba_inu_35.jpg
../datasets/images/havanese_3.jpg
../datasets/images/basset_hound_182.jpg
../datasets/images/japanese_chin_84.jpg
../datasets/images/saint_bernard_107.jpg
../datasets/images/Birman_83.jpg
../datasets/images/Egyptian_Mau_6.jpg
../datasets/images/boxer_86.jpg
../datasets/images/scottish_terrier_77.jpg
../datasets/images/english_cocker_spaniel_14.jpg
../datasets/images/havanese_138.jpg
../datasets/images/scottish_terrier_197.jpg
../datasets/images/german_shorthaired_71.jpg
../datasets/images/leonberger_144.jpg
../datasets/images/basset_hound_14.jpg
../datasets/images/great_pyrenees_140.jpg
../datasets/images/pug_132.jpg
../datasets/images/Bengal_66.jpg
../datasets/images/Bombay_18.jpg
../datasets/images/Sphynx_178.jpg
../datasets/images/Russian_Blue_68.jpg
../datasets/images/american_bulldog_113.jpg
../datasets/images/american_bulldog_139.jpg
../datasets/images/american_bulldog_224.jpg
../datasets/images/newfoundland_48.jpg
../datasets/images/Egyptian_Mau_160.jpg
../datasets/images/pug_80.jpg
../datasets/images/chihuahua_69.jpg
../datasets/images/wheaten_terrier_75.jpg
../datasets/images/Abyssinian_110.jpg
../datasets/images/english_setter_144.jpg
../datasets/images/Egyptian_Mau_175.jpg
../datasets/images/Birman_62.jpg
../datasets/images/newfoundland_83.jpg
../datasets/images/Maine_Coon_231.jpg
../datasets/images/Birman_108.jpg
../datasets/images/american_pit_bull_terrier_104.jpg
../datasets/images/Bengal_144.jpg
../datasets/images/leonberger_14.jpg
../datasets/images/Abyssinian_105.jpg
../datasets/images/great_pyrenees_50.jpg
../datasets/images/Persian_147.jpg
../datasets/images/basset_hound_176.jpg
../datasets/images/Sphynx_45.jpg
../datasets/images/Abyssinian_19.jpg
../datasets/images/samoyed_139.jpg
../datasets/images/boxer_93.jpg
../datasets/images/leonberger_151.jpg
../datasets/images/pomeranian_60.jpg
../datasets/images/Maine_Coon_106.jpg
../datasets/images/boxer_58.jpg
../datasets/images/great_pyrenees_155.jpg
../datasets/images/english_cocker_spaniel_147.jpg
../datasets/images/beagle_103.jpg
../datasets/images/scottish_terrier_62.jpg
../datasets/images/yorkshire_terrier_174.jpg
../datasets/images/beagle_64.jpg
../datasets/images/Siamese_47.jpg
../datasets/images/basset_hound_113.jpg
../datasets/images/american_pit_bull_terrier_111.jpg
../datasets/images/pug_168.jpg
../datasets/images/Abyssinian_175.jpg
../datasets/images/Abyssinian_4.jpg
../datasets/images/Maine_Coon_149.jpg
../datasets/images/boxer_196.jpg
../datasets/images/great_pyrenees_9.jpg
../datasets/images/Birman_12.jpg
../datasets/images/samoyed_149.jpg
../datasets/images/pomeranian_10.jpg
../datasets/images/miniature_pinscher_124.jpg
../datasets/images/scottish_terrier_139.jpg
../datasets/images/Egyptian_Mau_218.jpg
../datasets/images/leonberger_134.jpg
../datasets/images/yorkshire_terrier_104.jpg
../datasets/images/wheaten_terrier_10.jpg
../datasets/images/Maine_Coon_182.jpg
../datasets/images/basset_hound_64.jpg
../datasets/images/keeshond_24.jpg
../datasets/images/Persian_63.jpg
../datasets/images/beagle_173.jpg
../datasets/images/german_shorthaired_14.jpg
../datasets/images/american_pit_bull_terrier_174.jpg
../datasets/images/Persian_76.jpg
../datasets/images/great_pyrenees_20.jpg
../datasets/images/pomeranian_197.jpg
../datasets/images/Egyptian_Mau_110.jpg
../datasets/images/Birman_1.jpg
../datasets/images/japanese_chin_15.jpg
../datasets/images/Birman_178.jpg
../datasets/images/basset_hound_71.jpg
../datasets/images/Siamese_202.jpg
../datasets/images/havanese_183.jpg
../datasets/images/samoyed_197.jpg
../datasets/images/leonberger_64.jpg
../datasets/images/great_pyrenees_125.jpg
../datasets/images/shiba_inu_175.jpg
../datasets/images/Ragdoll_5.jpg
../datasets/images/Egyptian_Mau_105.jpg
../datasets/images/Russian_Blue_139.jpg
../datasets/images/Abyssinian_69.jpg
../datasets/images/Bombay_148.jpg
../datasets/images/keeshond_7.jpg
../datasets/images/havanese_37.jpg
../datasets/images/staffordshire_bull_terrier_114.jpg
../datasets/images/boxer_148.jpg
../datasets/images/leonberger_121.jpg
../datasets/images/american_bulldog_79.jpg
../datasets/images/yorkshire_terrier_111.jpg
../datasets/images/Bengal_121.jpg
../datasets/images/Bombay_68.jpg
../datasets/images/staffordshire_bull_terrier_78.jpg
../datasets/images/Bombay_183.jpg
../datasets/images/Sphynx_20.jpg
../datasets/images/miniature_pinscher_60.jpg
../datasets/images/basset_hound_106.jpg
../datasets/images/saint_bernard_16.jpg
../datasets/images/keeshond_31.jpg
../datasets/images/chihuahua_19.jpg
../datasets/images/english_cocker_spaniel_137.jpg
../datasets/images/Siamese_37.jpg
../datasets/images/beagle_4.jpg
../datasets/images/great_pyrenees_130.jpg
../datasets/images/german_shorthaired_166.jpg
../datasets/images/Russian_Blue_18.jpg
../datasets/images/Persian_137.jpg
../datasets/images/Maine_Coon_46.jpg
../datasets/images/saint_bernard_162.jpg
../datasets/images/Ragdoll_193.jpg
../datasets/images/Sphynx_137.jpg
../datasets/images/american_bulldog_176.jpg
../datasets/images/english_setter_30.jpg
../datasets/images/beagle_14.jpg
../datasets/images/Abyssinian_181.jpg
../datasets/images/chihuahua_121.jpg
../datasets/images/Ragdoll_158.jpg
../datasets/images/japanese_chin_142.jpg
../datasets/images/Egyptian_Mau_22.jpg
../datasets/images/Birman_147.jpg
../datasets/images/american_pit_bull_terrier_180.jpg
../datasets/images/Bombay_177.jpg
../datasets/images/Bombay_42.jpg
../datasets/images/beagle_192.jpg
../datasets/images/pug_157.jpg
../datasets/images/Persian_97.jpg
../datasets/images/havanese_177.jpg
../datasets/images/Maine_Coon_53.jpg
../datasets/images/basset_hound_139.jpg
../datasets/images/Bombay_57.jpg
../datasets/images/Maine_Coon_98.jpg
../datasets/images/Bombay_89.jpg
../datasets/images/Birman_152.jpg
../datasets/images/newfoundland_181.jpg
../datasets/images/Siamese_120.jpg
../datasets/images/samoyed_163.jpg
../datasets/images/Abyssinian_56.jpg
../datasets/images/boxer_17.jpg
../datasets/images/Persian_49.jpg
../datasets/images/basset_hound_90.jpg
../datasets/images/pomeranian_163.jpg
../datasets/images/Russian_Blue_32.jpg
../datasets/images/Russian_Blue_113.jpg
../datasets/images/Bengal_9.jpg
../datasets/images/pomeranian_176.jpg
../datasets/images/beagle_187.jpg
../datasets/images/boxer_162.jpg
../datasets/images/chihuahua_33.jpg
../datasets/images/english_setter_4.jpg
../datasets/images/Maine_Coon_176.jpg
../datasets/images/american_pit_bull_terrier_189.jpg
../datasets/images/Ragdoll_259.jpg
../datasets/images/shiba_inu_4.jpg
../datasets/images/english_cocker_spaniel_90.jpg
../datasets/images/yorkshire_terrier_34.jpg
../datasets/images/shiba_inu_181.jpg
../datasets/images/Birman_38.jpg
../datasets/images/miniature_pinscher_3.jpg
../datasets/images/Russian_Blue_27.jpg
../datasets/images/american_pit_bull_terrier_45.jpg
../datasets/images/leonberger_47.jpg
../datasets/images/Abyssinian_81.jpg
../datasets/images/scottish_terrier_38.jpg
../datasets/images/British_Shorthair_198.jpg
../datasets/images/basset_hound_125.jpg
../datasets/images/Ragdoll_84.jpg
../datasets/images/great_pyrenees_16.jpg
../datasets/images/english_setter_25.jpg
../datasets/images/pug_195.jpg
../datasets/images/newfoundland_156.jpg
../datasets/images/samoyed_84.jpg
../datasets/images/english_cocker_spaniel_114.jpg
../datasets/images/staffordshire_bull_terrier_47.jpg
../datasets/images/miniature_pinscher_112.jpg
../datasets/images/english_cocker_spaniel_200.jpg
../datasets/images/beagle_150.jpg
../datasets/images/japanese_chin_157.jpg
../datasets/images/american_bulldog_46.jpg
../datasets/images/wheaten_terrier_148.jpg
../datasets/images/Persian_40.jpg
../datasets/images/shiba_inu_45.jpg
../datasets/images/Siamese_228.jpg
../datasets/images/Maine_Coon_84.jpg
../datasets/images/american_pit_bull_terrier_142.jpg
../datasets/images/shiba_inu_156.jpg
../datasets/images/newfoundland_188.jpg
../datasets/images/shiba_inu_87.jpg
../datasets/images/staffordshire_bull_terrier_90.jpg
../datasets/images/great_pyrenees_113.jpg
../datasets/images/British_Shorthair_184.jpg
../datasets/images/Birman_31.jpg
../datasets/images/pug_18.jpg
../datasets/images/British_Shorthair_38.jpg
../datasets/images/saint_bernard_20.jpg
../datasets/images/basset_hound_52.jpg
../datasets/images/Birman_24.jpg
../datasets/images/american_pit_bull_terrier_157.jpg
../datasets/images/american_pit_bull_terrier_87.jpg
../datasets/images/leonberger_52.jpg
../datasets/images/staffordshire_bull_terrier_137.jpg
../datasets/images/yorkshire_terrier_127.jpg
../datasets/images/Siamese_129.jpg
../datasets/images/leonberger_99.jpg
../datasets/images/Sphynx_236.jpg
../datasets/images/leonberger_102.jpg
../datasets/images/Maine_Coon_91.jpg
../datasets/images/Abyssinian_94.jpg
../datasets/images/staffordshire_bull_terrier_85.jpg
../datasets/images/Persian_101.jpg
../datasets/images/wheaten_terrier_26.jpg
../datasets/images/pomeranian_33.jpg
../datasets/images/japanese_chin_180.jpg
../datasets/images/newfoundland_169.jpg
../datasets/images/shiba_inu_143.jpg
../datasets/images/japanese_chin_195.jpg
../datasets/images/Sphynx_223.jpg
../datasets/images/Siamese_234.jpg
../datasets/images/wheaten_terrier_33.jpg
../datasets/images/Bengal_117.jpg
../datasets/images/american_bulldog_84.jpg
../datasets/images/newfoundland_143.jpg
../datasets/images/english_cocker_spaniel_99.jpg
../datasets/images/chihuahua_117.jpg
../datasets/images/german_shorthaired_145.jpg
../datasets/images/yorkshire_terrier_28.jpg
../datasets/images/havanese_141.jpg
../datasets/images/Egyptian_Mau_133.jpg
../datasets/images/german_shorthaired_37.jpg
../datasets/images/shiba_inu_59.jpg
../datasets/images/Birman_164.jpg
../datasets/images/Egyptian_Mau_119.jpg
../datasets/images/keeshond_38.jpg
../datasets/images/boxer_141.jpg
../datasets/images/Maine_Coon_140.jpg
../datasets/images/american_bulldog_70.jpg
../datasets/images/wheaten_terrier_18.jpg
../datasets/images/beagle_37.jpg
../datasets/images/beagle_22.jpg
../datasets/images/Sphynx_29.jpg
../datasets/images/great_pyrenees_29.jpg
../datasets/images/keeshond_115.jpg
../datasets/images/english_setter_128.jpg
../datasets/images/Abyssinian_169.jpg
../datasets/images/Birman_171.jpg
../datasets/images/japanese_chin_175.jpg
../datasets/images/staffordshire_bull_terrier_108.jpg
../datasets/images/samoyed_140.jpg
../datasets/images/scottish_terrier_125.jpg
../datasets/images/yorkshire_terrier_2.jpg
../datasets/images/pug_27.jpg
../datasets/images/basset_hound_78.jpg
../datasets/images/yorkshire_terrier_17.jpg
../datasets/images/Maine_Coon_70.jpg
../datasets/images/pomeranian_140.jpg
../datasets/images/British_Shorthair_165.jpg
../datasets/images/Ragdoll_79.jpg
../datasets/images/Bombay_154.jpg
../datasets/images/pug_174.jpg
../datasets/images/pomeranian_18.jpg
../datasets/images/Birman_8.jpg
../datasets/images/american_pit_bull_terrier_168.jpg
../datasets/images/pomeranian_155.jpg
../datasets/images/newfoundland_24.jpg
../datasets/images/saint_bernard_9.jpg
../datasets/images/Abyssinian_75.jpg
../datasets/images/Siamese_116.jpg
../datasets/images/Bombay_61.jpg
../datasets/images/chihuahua_102.jpg
../datasets/images/newfoundland_31.jpg
../datasets/images/Siamese_103.jpg
../datasets/images/pug_32.jpg
../datasets/images/shiba_inu_67.jpg
../datasets/images/english_setter_129.jpg
../datasets/images/boxer_154.jpg
../datasets/images/leonberger_128.jpg
../datasets/images/english_setter_13.jpg
../datasets/images/Russian_Blue_124.jpg
../datasets/images/Bombay_74.jpg
../datasets/images/newfoundland_168.jpg
../datasets/images/boxer_155.jpg
../datasets/images/havanese_140.jpg
../datasets/images/beagle_36.jpg
../datasets/images/staffordshire_bull_terrier_201.jpg
../datasets/images/great_pyrenees_28.jpg
../datasets/images/american_bulldog_71.jpg
../datasets/images/Bombay_155.jpg
../datasets/images/pug_26.jpg
../datasets/images/Bombay_75.jpg
../datasets/images/Maine_Coon_141.jpg
../datasets/images/Abyssinian_61.jpg
../datasets/images/Maine_Coon_154.jpg
../datasets/images/Bombay_140.jpg
../datasets/images/pomeranian_154.jpg
../datasets/images/yorkshire_terrier_16.jpg
../datasets/images/american_pit_bull_terrier_169.jpg
../datasets/images/newfoundland_25.jpg
../datasets/images/newfoundland_30.jpg
../datasets/images/keeshond_114.jpg
../datasets/images/basset_hound_2.jpg
../datasets/images/Birman_170.jpg
../datasets/images/Bombay_60.jpg
../datasets/images/basset_hound_79.jpg
../datasets/images/great_pyrenees_1.jpg
../datasets/images/chihuahua_116.jpg
../datasets/images/saint_bernard_155.jpg
../datasets/images/keeshond_101.jpg
../datasets/images/samoyed_154.jpg
../datasets/images/Abyssinian_74.jpg
../datasets/images/boxer_35.jpg
../datasets/images/pug_160.jpg
../datasets/images/american_bulldog_141.jpg
../datasets/images/yorkshire_terrier_3.jpg
../datasets/images/Sphynx_222.jpg
../datasets/images/american_pit_bull_terrier_93.jpg
../datasets/images/shiba_inu_157.jpg
../datasets/images/chihuahua_11.jpg
../datasets/images/boxer_140.jpg
../datasets/images/havanese_155.jpg
../datasets/images/japanese_chin_181.jpg
../datasets/images/yorkshire_terrier_29.jpg
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment