From 2008dbfa3bb70543b8d071947e3877b01b730308 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Fri, 8 Mar 2019 00:52:58 +0000 Subject: Add ipynb to repo --- computer_vision.ipynb | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 computer_vision.ipynb diff --git a/computer_vision.ipynb b/computer_vision.ipynb new file mode 100644 index 0000000..584b19d --- /dev/null +++ b/computer_vision.ipynb @@ -0,0 +1,311 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "computer_vision.ipynb", + "version": "0.3.2", + "provenance": [], + "collapsed_sections": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "metadata": { + "id": "o8rKg5jPF_aa", + "colab_type": "code", + "outputId": "9569d1de-a4e6-42b0-ab60-713b627ec02d", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 53 + } + }, + "cell_type": "code", + "source": [ + "import os\n", + "import csv\n", + "import numpy as np\n", + "\n", + "repo_location = os.path.join('/content', 'e4-gan')\n", + "print(repo_location)\n", + "if not os.path.exists(repo_location):\n", + " !git clone https://git.skozl.com/e4-gan /content/e4-gan\n", + " \n", + "os.chdir(repo_location)\n", + "!cd /content/e4-gan\n", + "!git pull\n" + ], + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "text": [ + "/content/e4-gan\n", + "Already up to date.\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "Mci7b38-bDjf", + "colab_type": "code", + "outputId": "0ec49551-a260-4469-f656-146b6a3bb226", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 161 + } + }, + "cell_type": "code", + "source": [ + "imgfolder = os.path.join(repo_location, 'images')\n", + "print(imgfolder)\n", + "if not os.path.exists(imgfolder):\n", + " !mkdir images\n", + " print('Make image directory')\n", + " \n", + "from dcgan import DCGAN\n", + "from cgan import CGAN\n", + "from cdcgan import CDCGAN\n", + "from lenet import *\n", + " \n", + "#vbn_dcgan = DCGAN(virtual_batch_normalization=True)\n", + "#utils = os.path.join('/content', 'utils')\n", + "cgan = CGAN()\n", + "cdcgan = CDCGAN()\n", + "\n", + "#dcgan.train(epochs=4000, batch_size=32, save_interval=1000)\n", + "#cgan.train(epochs=20000, batch_size=32, sample_interval=1000, graph=True)" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "/content/e4-gan/images\n" + ], + "name": "stdout" + }, + { + "output_type": "stream", + "text": [ + "Using TensorFlow backend.\n" + ], + "name": "stderr" + }, + { + "output_type": "stream", + "text": [ + "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", + "Instructions for updating:\n", + "Colocations handled automatically by placer.\n", + "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n", + "Instructions for updating:\n", + "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "LcifrT3feO6P", + "colab_type": "code", + "colab": {} + }, + "cell_type": "code", + "source": [ + "#cdcgan.discriminator.save_weights('disc_weights.h5')\n", + "#cdcgan.generator.save_weights('gen_weights.h5')" + ], + "execution_count": 0, + "outputs": [] + }, + { + "metadata": { + "id": "X_-PBBXitdui", + "colab_type": "code", + "outputId": "b49313cf-54b3-44ee-9afb-3dfe1d16906d", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 125 + } + }, + "cell_type": "code", + "source": [ + "cdcgan.train(epochs=10001, batch_size=128, sample_interval=200, graph=True, smooth_real=0.9)" + ], + "execution_count": 0, + "outputs": [ + { + "output_type": "stream", + "text": [ + "\r 0%| | 0/10001 [00:00