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

190 lines
4.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%reload_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import multiprocessing\n",
"import os\n",
"from torch import autograd\n",
"from fastai.transforms import TfmType\n",
"from fasterai.transforms import *\n",
"from fastai.conv_learner import *\n",
"from fasterai.images import *\n",
"from fasterai.dataset import *\n",
"from fasterai.visualize import *\n",
"from fasterai.callbacks import *\n",
"from fasterai.loss import *\n",
"from fasterai.modules import *\n",
"from fasterai.training import *\n",
"from fasterai.generators import *\n",
"from fasterai.filters import *\n",
"from fastai.torch_imports import *\n",
"from pathlib import Path\n",
"from itertools import repeat\n",
"import tensorboardX\n",
"torch.cuda.set_device(3)\n",
"plt.style.use('dark_background')\n",
"torch.backends.cudnn.benchmark=True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"IMAGENET = Path('data/imagenet/ILSVRC/Data/CLS-LOC/train')\n",
"defader_path = IMAGENET.parent/('defade_rc_gen_192.h5')\n",
"\n",
"#The higher the render_factor, the more GPU memory will be used and generally images will look better. \n",
"#11GB can take a factor of 42 max. Performance generally gracefully degrades with lower factors, \n",
"#though you may also find that certain images will actually render better at lower numbers. \n",
"#This tends to be the case with the oldest photos.\n",
"render_factor=41"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filters = [DeFader(gpu=3, weights_path=defader_path)]\n",
"vis = ModelImageVisualizer(filters, render_factor=render_factor, results_dir='result_images')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis.plot_transformed_image(\"test_images/FadedOvermiller.PNG\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis.plot_transformed_image(\"test_images/FadedSphynx.PNG\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis.plot_transformed_image(\"test_images/FadedRacket.PNG\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis.plot_transformed_image(\"test_images/FadedDutchBabies.PNG\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis.plot_transformed_image(\"test_images/FadedDelores.PNG\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
},
"toc": {
"colors": {
"hover_highlight": "#DAA520",
"navigate_num": "#000000",
"navigate_text": "#333333",
"running_highlight": "#FF0000",
"selected_highlight": "#FFD700",
"sidebar_border": "#EEEEEE",
"wrapper_background": "#FFFFFF"
},
"moveMenuLeft": true,
"nav_menu": {
"height": "67px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false,
"widenNotebook": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}