Skip to content

Commit

Permalink
public-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
INVOKERer committed Jul 25, 2024
1 parent bb69d63 commit 61e5bad
Show file tree
Hide file tree
Showing 545 changed files with 185,516 additions and 643 deletions.
206 changes: 0 additions & 206 deletions FreqLC.py

This file was deleted.

28 changes: 28 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Installation

This repository is built in PyTorch 1.12.0 and tested on Ubuntu 16.04 environment (Python3.7, CUDA10.2, cuDNN7.6).
Follow these intructions

1. Clone our repository
```
git clone https://github.com/INVOKERer/LoFormer.git
cd AdaRevD
```

2. Make conda environment
```
conda create -n pytorch112 python=3.8
conda activate pytorch112
```

3. Install dependencies
```
conda install pytorch=1.12.0 torchvision cudatoolkit=11.3 -c pytorch
pip install matplotlib scikit-learn scikit-image opencv-python yacs joblib natsort h5py tqdm ptflops
pip install seaborn spectral einops kornia timm gdown addict future lmdb numpy pyyaml requests scipy tb-nightly yapf lpips
```

4. Install basicsr
```
python setup.py develop --no_cuda_ext --record install_files.txt
```
29 changes: 29 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## ACADEMIC PUBLIC LICENSE

### Permissions
:heavy_check_mark: Non-Commercial use
:heavy_check_mark: Modification
:heavy_check_mark: Distribution
:heavy_check_mark: Private use

### Limitations
:x: Commercial Use
:x: Liability
:x: Warranty

### Conditions
:information_source: License and copyright notice
:information_source: Same License

LoFormer is free for use in noncommercial settings: at academic institutions for teaching and research use, and at non-profit research organizations.
You can use LoFormer in your research, academic work, non-commercial work, projects and personal work. We only ask you to credit us appropriately.

You have the right to use the software, to distribute copies, to receive source code, to change the software and distribute your modifications or the modified software.
If you distribute verbatim or modified copies of this software, they must be distributed under this license.
This license guarantees that you're safe when using LoFormer in your work, for teaching or research.
This license guarantees that LoFormer will remain available free of charge for nonprofit use.
You can modify LoFormer to your purposes, and you can also share your modifications.

If you would like to use LoFormer in commercial settings, contact us so we can discuss options. Send an email to [email protected]


88 changes: 88 additions & 0 deletions Motion_Deblurring/LPIPS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# coding:utf-8
import lpips
import cv2
import glob
import tqdm

class util_of_lpips():
def __init__(self, net='vgg', use_gpu=False):
'''
Parameters
----------
net: str
抽取特征的网络,['alex', 'vgg']
use_gpu: bool
是否使用GPU,默认不使用
Returns
-------
References
-------
https://github.com/richzhang/PerceptualSimilarity/blob/master/lpips_2imgs.py
'''
## Initializing the model
self.loss_fn = lpips.LPIPS(net=net)
self.use_gpu = use_gpu
if use_gpu:
self.loss_fn.cuda()

def calc_lpips(self, img_p):
'''
Parameters
----------
img1_path : str
图像1的路径.
img2_path : str
图像2的路径.
Returns
-------
dist01 : torch.Tensor
学习的感知图像块相似度(Learned Perceptual Image Patch Similarity, LPIPS).
References
-------
https://github.com/richzhang/PerceptualSimilarity/blob/master/lpips_2imgs.py
'''
img1_path, img2_path = img_p
# Load images
img0 = lpips.im2tensor(lpips.load_image(img1_path)) # RGB image from [-1,1]
img1 = lpips.im2tensor(lpips.load_image(img2_path))

if self.use_gpu:
img0 = img0.cuda()
img1 = img1.cuda()

dist01 = self.loss_fn.forward(img0, img1).item()
del img0
del img1
return dist01


if __name__ == '__main__':
real_way = '/home/ubuntu/106-48t/personal_data/mxt/Datasets/Deblur/GoPro/test/sharp'
fake_Way = '/home/ubuntu/106-48t/personal_data/mxt/exp_results/images_deblur/Deblurring_WNAFNet_32_3stage2b_ffc3gelusin_freqloss/GoPro'
img_list_A = glob.glob(real_way + '/*')
# img_list_B = glob.glob(fake_Way + '/*')
img_list_A.sort()
# img_list_B.sort()
lpips_list = []
# ssim_list = []
LPIPS_Mec = util_of_lpips(use_gpu=True)
for i in tqdm.tqdm(range(len(img_list_A))):

# print(img_list_A[i].split('/')[-1], img_list_B[i].split('/')[-1])
img_list_B_way = fake_Way + '/' + img_list_A[i].split('/')[-1]
# img_list_B_way = glob.glob(fake_Way + '/' + img_list_A[i].split('/')[-1].split('.')[0]+'_*.png')[0]
# realim = cv2.imread(img_list_A[i])
# fakeim = cv2.imread(img_list_B_way)
# iou_s = diceCoeff_score(outim, gtim)
# print([img_list_A[i], img_list_B_way])
lpips_value = LPIPS_Mec.calc_lpips([img_list_A[i], img_list_B_way])
lpips_list.append(lpips_value)
# ssim_list.append(ssim)
lpips_avr = sum(lpips_list)/len(lpips_list)

print('lpips_avr')
# print(psnr_list)
print(lpips_avr)
Loading

0 comments on commit 61e5bad

Please sign in to comment.