Files
DeOldify/DeFadeVisualization.ipynb
T
2018-11-22 09:33:00 -08:00

4.4 KiB

In [ ]:
%matplotlib inline
%reload_ext autoreload
%autoreload 2
In [ ]:
import multiprocessing
import os
from torch import autograd
from fastai.transforms import TfmType
from fasterai.transforms import *
from fastai.conv_learner import *
from fasterai.images import *
from fasterai.dataset import *
from fasterai.visualize import *
from fasterai.callbacks import *
from fasterai.loss import *
from fasterai.modules import *
from fasterai.training import *
from fasterai.generators import *
from fasterai.filters import *
from fastai.torch_imports import *
from pathlib import Path
from itertools import repeat
import tensorboardX
torch.cuda.set_device(3)
plt.style.use('dark_background')
torch.backends.cudnn.benchmark=True
In [ ]:
IMAGENET = Path('data/imagenet/ILSVRC/Data/CLS-LOC/train')
defader_path = IMAGENET.parent/('defade_rc_gen_192.h5')

#The higher the render_factor, the more GPU memory will be used and generally images will look better.  
#11GB can take a factor of 42 max.  Performance generally gracefully degrades with lower factors, 
#though you may also find that certain images will actually render better at lower numbers.  
#This tends to be the case with the oldest photos.
render_factor=41
In [ ]:
filters = [DeFader(gpu=3, weights_path=defader_path)]
vis = ModelImageVisualizer(filters, render_factor=render_factor, results_dir='result_images')
In [ ]:
vis.plot_transformed_image("test_images/FadedOvermiller.PNG")
In [ ]:
vis.plot_transformed_image("test_images/FadedSphynx.PNG")
In [ ]:
vis.plot_transformed_image("test_images/FadedRacket.PNG")
In [ ]:
vis.plot_transformed_image("test_images/FadedDutchBabies.PNG")
In [ ]:
vis.plot_transformed_image("test_images/FadedDelores.PNG")
In [ ]:
In [ ]:
In [ ]:
In [ ]: