{ "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 fastai.torch_imports import *\n", "from pathlib import Path\n", "from itertools import repeat\n", "import tensorboardX\n", "torch.cuda.set_device(0)\n", "plt.style.use('dark_background')\n", "torch.backends.cudnn.benchmark=True\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "IMAGENET = Path('data/imagenet/ILSVRC/Data/CLS-LOC/train')\n", "IMAGENET_SMALL = IMAGENET/'n01440764'\n", "gpath = IMAGENET.parent/('defade_rc_gen_256.h5')\n", "default_sz=400\n", "torch.backends.cudnn.benchmark=True" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "netG = Unet34(nf_factor=2).cuda()\n", "load_model(netG, gpath)\n", "netG = netG.eval()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x_tfms = []\n", "data_loader = ImageGenDataLoader(sz=256, bs=8, path=IMAGENET_SMALL, random_seed=42, keep_pct=1.0, x_tfms=x_tfms)\n", "md = data_loader.get_model_data()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis = ModelImageVisualizer(default_sz=default_sz)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis.plot_transformed_image(\"test_images/FadedOvermiller.PNG\", netG, md.val_ds, tfms=x_tfms)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis.plot_transformed_image(\"test_images/FadedSphynx.PNG\", netG, md.val_ds, tfms=x_tfms, sz=500)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis.plot_transformed_image(\"test_images/FadedRacket.PNG\", netG, md.val_ds, tfms=x_tfms)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis.plot_transformed_image(\"test_images/FadedDutchBabies.PNG\", netG, md.val_ds, tfms=x_tfms, sz=500)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis.plot_transformed_image(\"test_images/FadedDelores.PNG\", netG, md.val_ds, tfms=x_tfms, sz=500)" ] }, { "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 }