From 552958fa744646e3f2367dded5f16f71d52a1cfc Mon Sep 17 00:00:00 2001 From: Jason Antic Date: Tue, 16 Apr 2019 19:27:07 -0700 Subject: [PATCH] Adding embedding of video --- VideoColorizerColab.ipynb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/VideoColorizerColab.ipynb b/VideoColorizerColab.ipynb index 11b1f80..e9c5354 100644 --- a/VideoColorizerColab.ipynb +++ b/VideoColorizerColab.ipynb @@ -138,6 +138,8 @@ "import fastai\n", "from fasterai.visualize import *\n", "from pathlib import Path\n", + "import base64\n", + "from IPython import display as ipythondisplay\n", "torch.backends.cudnn.benchmark=True" ] }, @@ -186,6 +188,21 @@ "colorizer = get_video_colorizer()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def show_video():\n", + " video = io.open(dest_path, 'r+b').read()\n", + " encoded = base64.b64encode(video)\n", + " ipythondisplay.display(HTML(data=''''''.format(encoded.decode('ascii'))))" + ] + }, { "cell_type": "markdown", "metadata": { @@ -220,6 +237,7 @@ "\n", "if source_url is not None and source_url !='':\n", " colorizer.colorize_from_url(source_url, file_name, render_factor)\n", + " show_video()\n", "else:\n", " print('Provide a video url and try again.')" ]