The goal of this project is to upscale ad improve the quality of low resolutio images. This project cotais Keras implemetatios of differet Residual Dese Networks for Sigle Image Super-Resolutio (ISR) as well as scripts to trai these etworks usig cotet ad adversarial loss compoets. The implemeted etworks iclude: Read the full documetatio at: https://idealo.github.io/image-super-resolutio/. Docker scripts ad Google Colab otebooks are available to carry traiig ad predictio. Also, we provide scripts to facilitate traiig o the cloud with AWS ad vidia-docker with oly a few commads. ISR is compatible with Pytho 3.6 ad is distributed uder the Apache 2.0 licese. We welcome ay kid of cotributio. If you wish to cotribute, please see the Cotribute sectio. Whe traiig your ow model, start with oly PSNR loss (50+ epochs, depedig o the dataset) ad oly the itroduce GANS ad feature loss. This ca be cotrolled by the loss weights argumet. This is just sample, you will eed to tue these parameters. PSNR oly: Later: If you are havig trouble loadig your ow weights or the pre-traied weights ( The weights used to produced these images are available directly whe creatig the model object. Curretly 4 models are available: Example usage: The etwork parameters will be automatically chose.
(see Additioal Iformatio). RDN model, PSNR drive, choose the optio RRDN model, traied with Adversarial ad VGG features losses, choose the optio ||
|:--:|
| RRDN GANS model (left), bicubic upscalig (right). |
-> more detailed compariso RDN model, traied with Adversarial ad VGG features losses, choose the optio ||
|:--:|
| RDN GANS artefact cacellig model (left), RDN stadard PSNR drive model (right). |
-> more detailed compariso There are two ways to istall the Image Super-Resolutio package: Load image ad prepare it Load a pre-traied model ad ru predictio (check the predictio tutorial uder otebooks for more details) To predict o large images ad avoid memory allocatio errors, use the Check the documetatio of the Create the models Create a Traier object usig the desired settigs ad give it the models ( Start traiig You ca read about how we traied these etwork weights i our Medium posts: The weights of the RDN etwork traied o the DIV2K dataset are available i The artefact ca cacellig weights obtaied with a combiatio of differet traiig sessios usig differet datasets ad perceptual loss with VGG19 ad GAN ca be foud at The mai parameters of the architecture structure are:
source: Residual Dese Network for Image Super-Resolutio The mai parameters of the architecture structure are:
source: ESRGAN: Ehaced Super-Resolutio Geerative Adversarial Networks We welcome all kids of cotributios, models traied o differet datasets, ew model architectures ad/or hyperparameters combiatios that improve the performace of the curretly published model. Will publish the performaces of ew models i this repository. See the Cotributio guide for more details. To bump up the versio, use Please cite our work i your publicatios if it helps your research. See LICENSE for details.Image Super-Resolutio (ISR)
Cotets
Troubleshootig
Traiig ot deliverig good/patchy results
loss_weights = {
'geerator': 1.0,
'feature_extractor': 0.0,
'discrimiator': 0.00
}
loss_weights = {
'geerator': 0.0,
'feature_extractor': 0.0833,
'discrimiator': 0.01
}
Weights loadig
AttributeError: 'str' object has o attribute 'decode'), try:pip istall 'h5py==2.10.0' --force-reistall
Pre-traied etworks
model = RRDN(weights='gas')
Basic model
weights='psr-large' or weights='psr-small' whe creatig a RDN model.
Low resolutio image (left), ISR output (ceter), bicubic scalig (right). Click to zoom.
GANS model
weights='gas' whe creatig a RRDN model.Artefact Cacellig GANS model
weights='oise-cacel' whe creatig a RDN model.
Stadard vs GANS model. Click to zoom.
Istallatio
pip istall ISR
git cloe https://github.com/idealo/image-super-resolutio
cd image-super-resolutio
pytho setup.py istall
Usage
Predictio
import umpy as p
from PIL import Image
img = Image.ope('data/iput/test_images/sample_image.jpg')
lr_img = p.array(img)
from ISR.models import RDN
rd = RDN(weights='psr-small')
sr_img = rd.predict(lr_img)
Image.fromarray(sr_img)
Large image iferece
by_patch_of_size optio for the predict method, for istacesr_img = model.predict(image, by_patch_of_size=50)
ImageModel class for further details.Traiig
from ISR.models import RRDN
from ISR.models import Discrimiator
from ISR.models import Cut_VGG19
lr_trai_patch_size = 40
layers_to_extract = [5, 9]
scale = 2
hr_trai_patch_size = lr_trai_patch_size * scale
rrd = RRDN(arch_params={'C':4, 'D':3, 'G':64, 'G0':64, 'T':10, 'x':scale}, patch_size=lr_trai_patch_size)
f_ext = Cut_VGG19(patch_size=hr_trai_patch_size, layers_to_extract=layers_to_extract)
discr = Discrimiator(patch_size=hr_trai_patch_size, kerel_size=3)
f_ext ad discr are optioal)from ISR.trai import Traier
loss_weights = {
'geerator': 0.0,
'feature_extractor': 0.0833,
'discrimiator': 0.01
}
losses = {
'geerator': 'mae',
'feature_extractor': 'mse',
'discrimiator': 'biary_crossetropy'
}
log_dirs = {'logs': './logs', 'weights': './weights'}
learig_rate = {'iitial_value': 0.0004, 'decay_factor': 0.5, 'decay_frequecy': 30}
flatess = {'mi': 0.0, 'max': 0.15, 'icrease': 0.01, 'icrease_frequecy': 5}
traier = Traier(
geerator=rrd,
discrimiator=discr,
feature_extractor=f_ext,
lr_trai_dir='low_res/traiig/images',
hr_trai_dir='high_res/traiig/images',
lr_valid_dir='low_res/validatio/images',
hr_valid_dir='high_res/validatio/images',
loss_weights=loss_weights,
learig_rate=learig_rate,
flatess=flatess,
dataame='image_dataset',
log_dirs=log_dirs,
weights_geerator=Noe,
weights_discrimiator=Noe,
_validatio=40,
)
traier.trai(
epochs=80,
steps_per_epoch=500,
batch_size=16,
moitored_metrics={'val_PSNR_Y': 'max'}
)
Additioal Iformatio
RDN Pre-traied weights
weights/sample_weights/rd-C6-D20-G64-G064-x2/PSNR-drive/rd-C6-D20-G64-G064-x2_PSNR_epoch086.hdf5.
The model was traied usig C=6, D=20, G=64, G0=64 as parameters (see architecture for details) for 86 epochs of 1000 batches of 8 32x32 augmeted patches take from LR images.weights/sample_weights/rd-C6-D20-G64-G064-x2/ArtefactCacellig/rd-C6-D20-G64-G064-x2_ArtefactCacellig_epoch219.hdf5
We recommed usig these weights oly whe cacellig compressio artefacts is a desirable effect.RDN Network architecture
RRDN Network architecture
Cotribute
Bump versio
bumpversio {part} setup.py
Citatio
@misc{cardiale2018isr,
title={ISR},
author={Fracesco Cardiale et al.},
year={2018},
howpublished={\url{https://github.com/idealo/image-super-resolutio}},
}
Maitaiers
Copyright
点击空白处退出提示










评论