{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "663IVxfrpIAb"
},
"source": [
"#◢ DeOldify - Colorize your own videos!\n",
"\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",
"####**Credits:**\n",
"\n",
"Big special thanks to:\n",
"\n",
"Robert Bell for all his work on the video Colab notebook, and paving the way to video in DeOldify!\n",
"\n",
"Dana Kelley for doing things, breaking stuff & having an opinion on everything."
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "ZjPqTBNoohK9"
},
"source": [
"\n",
"\n",
"---\n",
"\n",
"\n",
"#◢ Verify Correct Runtime Settings\n",
"\n",
"** IMPORTANT **\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 \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "00_GcC_trpdE"
},
"outputs": [],
"source": [
"from os import path\n",
"import torch"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "gaEJBGDlptEo"
},
"source": [
"#◢ Git clone and install DeOldify"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "-T-svuHytJ-8"
},
"outputs": [],
"source": [
"!git clone -b FastAIv1 --single-branch https://github.com/jantic/DeOldify.git DeOldify\n",
"#!git clone https://github.com/jantic/DeOldify.git DeOldify"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cd DeOldify"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "BDFjbNxaadNJ"
},
"source": [
"#◢ Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "Lsx7xCXNSVt6"
},
"outputs": [],
"source": [
"!pip install -r requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "MsJa69CMwj3l"
},
"outputs": [],
"source": [
"import fastai\n",
"from fasterai.visualize import *\n",
"from pathlib import Path\n",
"torch.backends.cudnn.benchmark=True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!mkdir 'models'\n",
"!wget https://www.dropbox.com/s/336vn9y4qwyg9yz/ColorizeVideo_gen.pth?dl=0 -O ./models/ColorizeVideo_gen.pth"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "tzHVnegp21hC"
},
"outputs": [],
"source": [
"colorizer = get_video_colorizer()"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "sUQrbSYipiJn"
},
"source": [
"#◢ Colorize!!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Instructions\n",
"\n",
"#### source_url\n",
"YouTube, Imgur, Twitter, Reddit, Vimeo, etc. Many sources work! GIFs also work. Full list here: https://ytdl-org.github.io/youtube-dl/supportedsites.html NOTE: If you want to use your own video, upload it first to a site like YouTube. \n",
"\n",
"#### render_factor\n",
"The default value of 21 has been carefully chosen and should work -ok- for most scenarios (but probably won't be the -best-). This determines resolution at which video is rendered. Lower resolution will render faster, and colors also tend to look more vibrant. Older and lower quality film in particular will generally benefit by lowering the render factor. Higher render factors are often better for higher quality videos and inconsistencies (flashy render) will generally be reduced, but the colors may get slightly washed out. \n",
"\n",
"#### How to Download a Copy\n",
"Simply right click on the displayed video and click \"Save video as...\"!\n",
"\n",
"#### Pro Tips\n",
"1. If a video takes a long time to render and you're wondering how well the frames are being colorized, you can preview these colorized frames by going to the menu on the left, clicking \"Files\", and go to /DeOldify/video/colorframes/video. You can then simply double click on the images and get a preview in the browser.\n",
"2. If videos are taking way too much time for your liking, running the Jupyter notebook VideoColorizer.ipynb on your own machine (with DeOldify installed) will generally be much faster (as long as you have the hardware for it). \n",
"\n",
"#### Troubleshooting\n",
"The video player may wind up not showing up, in which case- make sure to wait for the Jupyter cell to complete processing first (the play button will stop spinning). Then follow these alternative download instructions\n",
"\n",
"1. In the menu to the left, click Files\n",
"2. If you don't see the 'DeOldify' folder, click \"Refresh\"\n",
"3. By default, rendered video will be in /DeOldify/video/result/\n",
"\n",
"If a video you downloaded doesn't play, it's probably because the cell didn't complete processing and the video is in a half-finished state."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"source_url = '' #@param {type:\"string\"}\n",
"render_factor = 21 #@param {type: \"slider\", min: 7, max: 46}\n",
"\n",
"if source_url is not None and source_url !='':\n",
" video_path = colorizer.colorize_from_url(source_url, 'video.mp4', render_factor)\n",
" show_video_in_notebook(video_path)\n",
"else:\n",
" print('Provide a video url and try again.')"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "X7Ycv_Y9xAHp"
},
"source": [
"---\n",
"#⚙ Recommended video and gif sources \n",
"* [/r/Nickelodeons/](https://www.reddit.com/r/Nickelodeons/)\n",
"* [r/silentmoviegifs](https://www.reddit.com/r/silentmoviegifs/)\n",
"* https://twitter.com/silentmoviegifs "
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [],
"name": "VideoColorizerColab.ipynb",
"provenance": [],
"toc_visible": true,
"version": "0.3.2"
},
"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.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}