Przeglądaj źródła

Dana fixed things and made things quite nice!

Jason Antic 6 lat temu
rodzic
commit
ce89f79003
1 zmienionych plików z 54 dodań i 67 usunięć
  1. 54 67
      VideoColorizerColab.ipynb

+ 54 - 67
VideoColorizerColab.ipynb

@@ -17,22 +17,31 @@
     "id": "663IVxfrpIAb"
    },
    "source": [
-    "#◢ <font color='#FF000'>[ </font> DeOldify-video\n",
+    "#◢ DeOldify - Not just for photos!\n",
     "\n",
-    "##This Colab notebook colorizes video in four steps\n",
-    "1. Upload source media or specify media URL - YouTube, Twitter, MySpace, etc.\n",
-    "2. Extract single images from media\n",
-    "3. Process images with [DeOldify](https://github.com/jantic/DeOldify) \n",
-    "4. Rebuild the video from **<font color='#CC0000'>c</font><font color='#CC8800'>o</font><font color='#FFBB00'>l</font><font color='#00DD00'>o</font><font color='#0000FF'>r</font>ized** images\n",
-    "\n",
-    "I'm on twitter [@tradica](https://twitter.com/tradica)\n",
+    "##Use this Colab notebook to colorize black & white videos in three simple steps.\n",
+    "1. Specify media URL - YouTube, Twitter, Imgur, etc.\n",
+    "2. Run DeOldify to extract single images from your video or gif. Behind the scenes, the code does the following:\n",
+    "    * Extracts single images from the specified media file.\n",
+    "    * Processes the images with [DeOldify](https://github.com/jantic/DeOldify).\n",
+    "    * Rebuilds the video from **<font color='#CC0000'>c</font><font color='#CC8800'>o</font><font color='#FFBB00'>l</font><font color='#00DD00'>o</font><font color='#0000FF'>r</font>ized** images.\n",
+    "3. Download the video to your device to view! \n",
     "\n",
+    "_FYI: This notebook is intended as a tool to colorize gifs and short videos, if you are trying to convert longer video you may hit the limit on processing space. Running the Jupyter notebook on your own machine is recommended (and faster) for larger video sizes._\n",
     "\n",
     "---\n",
     "\n",
+    "####**Credits:**\n",
+    "\n",
+    "Use of this tool is thanks to,\n",
+    "\n",
+    "[@citnaj](https://twitter.com/citnaj) for creating DeOldify.\n",
+    "\n",
+    "[@tradica](https://twitter.com/tradica) for initial video and CoLab work.\n",
+    "\n",
+    "Matt Robinson for his [notebook](https://colab.research.google.com/github/jantic/DeOldify/blob/master/DeOldify_colab.ipynb) which helped make DeOldify approachable.\n",
     "\n",
-    "Thanks [@citnaj](https://twitter.com/citnaj) for creating DeOldify and thanks to Matt Robinson for his [notebook](https://colab.research.google.com/github/jantic/DeOldify/blob/master/DeOldify_colab.ipynb). It helped make DeOldify approachable.\n",
-    "\n"
+    "Dana Kelley for doing things, breaking stuff & having an opinion on everything."
    ]
   },
   {
@@ -47,10 +56,13 @@
     "---\n",
     "\n",
     "\n",
-    "#◢ <font color='#FF000'>[ </font> Set Runtime type to Python 3/GPU\n",
-    "In the Runtime menu above be sure:\n",
+    "#◢ Verify Correct Runtime Settings\n",
+    "\n",
+    "**<font color='#FF000'> IMPORTANT </font>**\n",
+    "\n",
+    "In the \"Runtime\" menu for the notebook window, select \"Change runtime type.\" Ensure that the following are selected:\n",
     "* Runtime Type = Python 3\n",
-    "* Hardware Accelerator = GPU **<font color='#FF000'><-------------- IMPORTANT </font>**\n"
+    "* Hardware Accelerator = GPU \n"
    ]
   },
   {
@@ -138,16 +150,9 @@
    },
    "outputs": [],
    "source": [
-    "import os\n",
-    "from pydrive.auth import GoogleAuth\n",
-    "from pydrive.drive import GoogleDrive\n",
-    "from google.colab import auth\n",
-    "from oauth2client.client import GoogleCredentials\n",
-    "from google.colab import drive\n",
     "import fastai\n",
     "from fasterai.visualize import *\n",
     "from pathlib import Path\n",
-    "from itertools import repeat\n",
     "from google.colab import drive\n",
     "from google.colab import files\n",
     "torch.backends.cudnn.benchmark=True"
@@ -157,7 +162,11 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "#◢ Artistic vs Stable Model"
+    "#◢ Stable vs Experimental Model\n",
+    "\n",
+    "For most use cases, stick with the \"Stable\" model. If you are feeling wild, try out the \"Experimental.\" Please note, depending on the source file, it may improve the vibrancy of colors, or it may make everyone look like they just took the Trump Train from LoompaLand.\n",
+    "\n",
+    "_The \"experimental\" model is just that, experimental and prone to unannounced updates. Feedback is sometimes welcome._"
    ]
   },
   {
@@ -166,7 +175,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "artistic = False #@param {type:\"boolean\"}"
+    "stable = True #@param {type:\"boolean\"}"
    ]
   },
   {
@@ -176,24 +185,20 @@
    "outputs": [],
    "source": [
     "!mkdir 'models'\n",
-    "if artistic:\n",
-    "    !wget https://www.dropbox.com/s/9ne9su2mc5t0m38/ColorizeImagesArtistic_gen.pth?dl=0 -O ./models/ColorizeImagesArtistic_gen.pth\n",
+    "if stable:\n",
+    "    !wget https://www.dropbox.com/s/ztgygpaz1z3jkjg/ColorizeImagesStable_gen.pth?dl=0 -O ./models/ColorizeImagesStable_gen.pth\n",
     "else:\n",
-    "    !wget https://www.dropbox.com/s/ztgygpaz1z3jkjg/ColorizeImagesStable_gen.pth?dl=0 -O ./models/ColorizeImagesStable_gen.pth"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "#◢ Render Factor"
+    "    !wget https://www.dropbox.com/s/9ne9su2mc5t0m38/ColorizeImagesArtistic_gen.pth?dl=0 -O ./models/ColorizeImagesArtistic_gen.pth\n",
+    "    "
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Determines resolution at which video is rendered. Higher is generally better (not always however!).  Default is carefully chosen and should work for most scenarios"
+    "#◢ Render Factor\n",
+    "\n",
+    "Default has been carefully chosen and should work for most scenarios. Determines resolution at which video is rendered. Lower resolution tends to be less flashy and complete faster. Higher resolution can be more colorful (not always in a good way!). "
    ]
   },
   {
@@ -202,7 +207,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "render_factor = 36  #@param {type: \"slider\", min: 5, max: 45}"
+    "render_factor = 21  #@param {type: \"slider\", min: 5, max: 45}"
    ]
   },
   {
@@ -212,14 +217,9 @@
     "id": "z5rSDjZbTntY"
    },
    "source": [
-    "#◢ Specify URL"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "YouTube, Imgur, Twitter, MySpace, Reddit ... most work.  NOTE:  If this is ommitted, you can just upload the file later in the workflow"
+    "#◢ Specify URL\n",
+    "\n",
+    "YouTube, Imgur, Twitter, Reddit ... files of type .gif, .gifv and .mp4 work.  NOTE: If you want to use your own source material, upload it first to a site like Imgur. "
    ]
   },
   {
@@ -238,14 +238,9 @@
     "id": "z5rSDjZbTntY"
    },
    "source": [
-    "#◢ Additional Parameters"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "It's not recommended to change the following (not really necessary)"
+    "#◢ Additional Parameters\n",
+    "\n",
+    "It's not necessary to change the following, just run them as-is."
    ]
   },
   {
@@ -277,7 +272,7 @@
     "id": "sUQrbSYipiJn"
    },
    "source": [
-    "#◢ DeOldify / Colorize"
+    "#◢ Run DeOldify"
    ]
   },
   {
@@ -290,7 +285,7 @@
    },
    "outputs": [],
    "source": [
-    "colorizer = get_video_colorizer(render_factor=render_factor, artistic=artistic)"
+    "colorizer = get_video_colorizer(render_factor=render_factor, artistic=!stable)"
    ]
   },
   {
@@ -302,10 +297,7 @@
     "if source_url is not None and source_url !='':\n",
     "    colorizer.colorize_from_url(source_url, file_name)\n",
     "else:\n",
-    "    #UPLOAD File Here\n",
-    "    source_media = files.upload()\n",
-    "    os.system('ln -f -s /content/WORKFOLDER/' + list(source_media.keys())[0] + ' ' + source_path)\n",
-    "    colorizer.colorize_from_file_name(file_name)"
+    "    print('Provide a source url and try again.')"
    ]
   },
   {
@@ -315,16 +307,11 @@
     "id": "A5WMS_GgP4fm"
    },
    "source": [
-    "#◢ Download"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "* In the Menu on the left, click **Files**\n",
-    "* Click refresh button if you don't see the 'DeOldify' folder.\n",
-    "* Rendered video should be in /DeOldify/video/result/"
+    "#◢ Download\n",
+    "\n",
+    "* In the menu to the left, click **Files**\n",
+    "* If you don't see the 'DeOldify' folder, click \"Refresh\"\n",
+    "* By default, rendered video will be in /DeOldify/video/result/"
    ]
   },
   {
@@ -335,7 +322,7 @@
    },
    "source": [
     "---\n",
-    "#⚙ Some great video and gif sources \n",
+    "#⚙ Recommended video and gif sources \n",
     "* [/r/Nickelodeons/](https://www.reddit.com/r/Nickelodeons/)\n",
     "* https://twitter.com/silentmoviegifs "
    ]