Skip to content

Commit

Permalink
Merge pull request AliaksandrSiarohin#445 from graphemecluster/master
Browse files Browse the repository at this point in the history
Update demo.ipynb
  • Loading branch information
AliaksandrSiarohin authored Jun 30, 2021
2 parents 3ffe3f2 + 99f18fc commit ca49071
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"from IPython.display import HTML, Javascript\n",
"from skimage import img_as_ubyte\n",
"warnings.filterwarnings(\"ignore\")\n",
"os.makedirs(\"user\", exist_ok=True)\n",
"\n",
"display(HTML(\"\"\"\n",
"<style>\n",
Expand Down Expand Up @@ -442,13 +443,15 @@
"\tfor name, file_info in upload_input_video_button.value.items():\n",
"\t\tcontent = file_info['content']\n",
"\tif content is not None:\n",
"\t\tselected_video = content\n",
"\t\tpreview = resize(PIL.Image.fromarray(thumbnail(selected_video)).convert(\"RGB\"))\n",
"\t\tselected_video = 'user/' + name\n",
"\t\tpreview = resize(PIL.Image.fromarray(thumbnail(content)).convert(\"RGB\"))\n",
"\t\tinput_video_widget.clear_output(wait=True)\n",
"\t\twith input_video_widget:\n",
"\t\t\tdisplay(preview)\n",
"\t\tinput_video_widget.add_class('uploaded')\n",
"\t\tdisplay(Javascript('deselectVideos()'))\n",
"\t\twith open(selected_video, 'wb') as video:\n",
"\t\t\tvideo.write(content)\n",
"upload_input_video_button.observe(upload_video, names='value')\n",
"\n",
"def change_model(change):\n",
Expand Down Expand Up @@ -480,7 +483,7 @@
"\t\trelative=relative.value,\n",
"\t\tadapt_movement_scale=adapt_movement_scale.value\n",
"\t)\n",
"\tif selected_video == 'demo/videos/0.mp4':\n",
"\tif selected_video.startswith('user/') or selected_video == 'demo/videos/0.mp4':\n",
"\t\timageio.mimsave('temp.mp4', [img_as_ubyte(frame) for frame in predictions], fps=fps)\n",
"\t\tFFmpeg(inputs={'temp.mp4': None, selected_video: None}, outputs={'output.mp4': '-c copy -y'}).run()\n",
"\telse:\n",
Expand All @@ -490,7 +493,7 @@
"\twith output_widget:\n",
"\t\tdisplay(HTML('<video id=\"left\" controls src=\"data:video/mp4;base64,%s\" />' % b64encode(open('output.mp4', 'rb').read()).decode()))\n",
"\twith comparison_widget:\n",
"\t\tdisplay(HTML('<video id=\"right\" src=\"data:video/mp4;base64,%s\" />' % b64encode(open(selected_video, 'rb').read() if type(selected_video) is str else selected_video).decode()))\n",
"\t\tdisplay(HTML('<video id=\"right\" muted src=\"data:video/mp4;base64,%s\" />' % b64encode(open(selected_video, 'rb').read()).decode()))\n",
"\tdisplay(Javascript(\"\"\"\n",
"\t(function(left, right) {\n",
"\t\tleft.addEventListener(\"play\", function() {\n",
Expand Down

0 comments on commit ca49071

Please sign in to comment.