-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISR.py
34 lines (25 loc) · 829 Bytes
/
ISR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#Installation
#pip install ISR
#pip install 'h5py==2.10.0' --force-reinstall
import numpy as np
from PIL import Image
img = Image.open('data/input/test_images/ISRtest.png')
# Uncomment if using local repo
# import sys
# sys.path.append('..')
from ISR.models import RDN, RRDN
#model = RDN(weights='noise-cancel')
#model = RRDN(weights='gans')
#model = RDN(weights='psnr-small')
model = RDN(weights='psnr-large')
#Create Baseline
# img.size[0]*2 : int here tells us zoom factor
# resample: allows us to choose other mathematicl functions
bicubic_img=img.resize(size=(img.size[0]*2, img.size[1]*2), resample=Image.BICUBIC)
#Save
#bicubic_img = Image.fromarray(bicubic_img)
bicubic_img.save('2_bicubic.png')
#Prediction
sr_img = model.predict(np.array(img))
isr_img=Image.fromarray(sr_img)
isr_img.save('2_psnr_large.png')