Instructions to use hugaagg/IR_expeiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use hugaagg/IR_expeiment with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("hugaagg/IR_expeiment", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Download PART2/Restormer/Defocus_Deblurring/utils.py from hugaagg/IR_expeiment: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/hugaagg/IR_expeiment/resolve/main/PART2/Restormer/Defocus_Deblurring/utils.py
- Command line
-
hf download hf://hugaagg/IR_expeiment/PART2/Restormer/Defocus_Deblurring/utils.py
-
curl -L -o utils.py https://huggingface.co/hugaagg/IR_expeiment/resolve/main/PART2/Restormer/Defocus_Deblurring/utils.py
1.32 kB
| ## Restormer: Efficient Transformer for High-Resolution Image Restoration | |
| ## Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang | |
| ## https://arxiv.org/abs/2111.09881 | |
| import numpy as np | |
| import os | |
| import cv2 | |
| import math | |
| from skimage import metrics | |
| from sklearn.metrics import mean_absolute_error | |
| def MAE(img1, img2): | |
| mae_0=mean_absolute_error(img1[:,:,0], img2[:,:,0], | |
| multioutput='uniform_average') | |
| mae_1=mean_absolute_error(img1[:,:,1], img2[:,:,1], | |
| multioutput='uniform_average') | |
| mae_2=mean_absolute_error(img1[:,:,2], img2[:,:,2], | |
| multioutput='uniform_average') | |
| return np.mean([mae_0,mae_1,mae_2]) | |
| def PSNR(img1, img2): | |
| mse_ = np.mean( (img1 - img2) ** 2 ) | |
| if mse_ == 0: | |
| return 100 | |
| return 10 * math.log10(1 / mse_) | |
| def SSIM(img1, img2): | |
| return metrics.structural_similarity(img1, img2, data_range=1, multichannel=True) | |
| def load_img(filepath): | |
| return cv2.cvtColor(cv2.imread(filepath), cv2.COLOR_BGR2RGB) | |
| def load_img16(filepath): | |
| return cv2.cvtColor(cv2.imread(filepath, -1), cv2.COLOR_BGR2RGB) | |
| def save_img(filepath, img): | |
| cv2.imwrite(filepath,cv2.cvtColor(img, cv2.COLOR_RGB2BGR)) | |