diff --git a/demo.ipynb b/demo.ipynb index 7720140..1d5fd02 100644 --- a/demo.ipynb +++ b/demo.ipynb @@ -1,28 +1,9 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "demo.ipynb", - "provenance": [], - "authorship_tag": "ABX9TyNSylbAA8rEY4SPEXcQH+18", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - }, - "accelerator": "GPU" - }, "cells": [ { "cell_type": "markdown", "metadata": { - "id": "view-in-github", - "colab_type": "text" + "id": "view-in-github" }, "source": [ "\"Open" @@ -36,102 +17,104 @@ "source": [ "\n", "# Demo for paper \"Motion Representations for Articulated Animation\"\n", - "**Clone repository. First install git lfs. Pulling all checkpoints may take a while**\n" + "**Clone repository. First install git lfs. Pulling all checkpoints may take a while. \n", + "\n", + "If git lfs fails to download the checkpoint files, see cells below.**\n" ] }, { "cell_type": "code", + "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "2LoHDHBHyzzZ", - "outputId": "43840da9-0105-48d6-efc6-5977ff106cb2" + "id": "2LoHDHBHyzzZ" }, + "outputs": [], "source": [ "!curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash\n", "!sudo apt-get install git-lfs\n", "!git lfs install\n", "!git clone https://github.com/snap-research/articulated-animation/" - ], - "execution_count": 1, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Detected operating system as Ubuntu/bionic.\n", - "Checking for curl...\n", - "Detected curl...\n", - "Checking for gpg...\n", - "Detected gpg...\n", - "Running apt-get update... done.\n", - "Installing apt-transport-https... done.\n", - "Installing /etc/apt/sources.list.d/github_git-lfs.list...done.\n", - "Importing packagecloud gpg key... done.\n", - "Running apt-get update... done.\n", - "\n", - "The repository is setup! You can now install packages.\n", - "Reading package lists... Done\n", - "Building dependency tree \n", - "Reading state information... Done\n", - "The following package was automatically installed and is no longer required:\n", - " libnvidia-common-460\n", - "Use 'sudo apt autoremove' to remove it.\n", - "The following NEW packages will be installed:\n", - " git-lfs\n", - "0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded.\n", - "Need to get 6,229 kB of archives.\n", - "After this operation, 14.5 MB of additional disk space will be used.\n", - "Get:1 https://packagecloud.io/github/git-lfs/ubuntu bionic/main amd64 git-lfs amd64 2.13.3 [6,229 kB]\n", - "Fetched 6,229 kB in 1s (12.1 MB/s)\n", - "debconf: unable to initialize frontend: Dialog\n", - "debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 1.)\n", - "debconf: falling back to frontend: Readline\n", - "debconf: unable to initialize frontend: Readline\n", - "debconf: (This frontend requires a controlling tty.)\n", - "debconf: falling back to frontend: Teletype\n", - "dpkg-preconfigure: unable to re-open stdin: \n", - "Selecting previously unselected package git-lfs.\n", - "(Reading database ... 160694 files and directories currently installed.)\n", - "Preparing to unpack .../git-lfs_2.13.3_amd64.deb ...\n", - "Unpacking git-lfs (2.13.3) ...\n", - "Setting up git-lfs (2.13.3) ...\n", - "Git LFS initialized.\n", - "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n", - "Git LFS initialized.\n", - "Cloning into 'articulated-animation'...\n", - "remote: Enumerating objects: 141, done.\u001b[K\n", - "remote: Counting objects: 100% (141/141), done.\u001b[K\n", - "remote: Compressing objects: 100% (123/123), done.\u001b[K\n", - "remote: Total 141 (delta 14), reused 139 (delta 13), pack-reused 0\u001b[K\n", - "Receiving objects: 100% (141/141), 46.72 MiB | 46.90 MiB/s, done.\n", - "Resolving deltas: 100% (14/14), done.\n", - "Filtering content: 100% (5/5), 1.28 GiB | 35.51 MiB/s, done.\n" - ], - "name": "stdout" - } ] }, { "cell_type": "code", + "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "bCmwKAK4zkGC", - "outputId": "9b57bd21-9d51-4c87-f67e-358ff24ccd35" + "id": "bCmwKAK4zkGC" }, + "outputs": [], "source": [ "cd articulated-animation" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "16FVl4gF2M4-" + }, + "source": [ + "**Download the checkpoints, in case git LFS failed to download them from the GitHub repository. \n", + "The following will work on Colab/Ubuntu, not on on Windows**.\n", + "\n", + "[Source](https://stackoverflow.com/a/66804597)." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true, + "id": "XmKdQZsd2M4-" + }, + "outputs": [], + "source": [ + "%%capture\n", + "%%bash\n", + "\n", + " download_file_i(){\n", + " wget --load-cookies /tmp/cookies.txt \"https://drive.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=$1' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\\n/p')&id=$1\" -O checkpoints/$2.pth && rm -rf /tmp/cookies.txt\n", + " }\n", + "\n", + " a1=('1zt1cbLGiN6pVZi1Wn70lF29l1c2x6--V' '1UXMd2x4G3uFLa-XPA5iGywWlcidXR6Yg' \n", + " '1y_eiItgdKr3Z0Zb7lCsQoCM2GyxAcya_' '1X-BwTTwxTteesAxymrutxOy2qFW_jlWA'\n", + " '1gyU9H7ArRAK9cUp_4rGF582C35B4pNcE')\n", + "a2=(\"mgif256\" \"taichi256\" \"ted-youtube384\" \"ted384\" \"vox256\")\n", + "\n", + "for i in \"${!a1[@]}\"; do\n", + " download_file_i \"${a1[i]}\" \"${a2[i]}\"\n", + "done" + ] + }, + { + "cell_type": "markdown", + "source": [ + "`ffmpeg` is required to read the driving video file. " ], - "execution_count": 2, + "metadata": { + "id": "V6KwH2Y120Ba" + } + }, + { + "cell_type": "code", + "source": [ + "!pip install imageio-ffmpeg" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "89QBoGUb2wh_", + "outputId": "0dcd533a-f060-4a78-cf80-9c00abb07438" + }, + "execution_count": 10, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ - "/content/articulated-animation\n" - ], - "name": "stdout" + "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", + "Requirement already satisfied: imageio-ffmpeg in /usr/local/lib/python3.8/dist-packages (0.4.8)\n" + ] } ] }, @@ -146,14 +129,11 @@ }, { "cell_type": "code", + "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 453 - }, - "id": "CRVOnlASzrhI", - "outputId": "02896e4c-3530-4db2-b415-be4c2ae72066" + "id": "CRVOnlASzrhI" }, + "outputs": [], "source": [ "import imageio\n", "import numpy as np\n", @@ -190,1533 +170,6 @@ " \n", "\n", "HTML(display(source_image, driving_video).to_html5_video())" - ], - "execution_count": 3, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 3 - } ] }, { @@ -1730,17 +183,17 @@ }, { "cell_type": "code", + "execution_count": 8, "metadata": { "id": "n49-tAcEzzeG" }, + "outputs": [], "source": [ "from demo import load_checkpoints\n", "\n", "generator, region_predictor, avd_network = load_checkpoints(config_path='config/ted384.yaml',\n", " checkpoint_path='checkpoints/ted384.pth')" - ], - "execution_count": 4, - "outputs": [] + ] }, { "cell_type": "markdown", @@ -1753,14 +206,11 @@ }, { "cell_type": "code", + "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 471 - }, - "id": "Lcv6u7Bcz27V", - "outputId": "eabd3a58-f0e6-4908-fc9c-b5fbb038e7fa" + "id": "Lcv6u7Bcz27V" }, + "outputs": [], "source": [ "from demo import make_animation\n", "from skimage import img_as_ubyte\n", @@ -1773,2243 +223,32 @@ "#video can be downloaded from /content folder\n", "\n", "HTML(display(source_image, driving_video, predictions).to_html5_video())" - ], - "execution_count": 5, - "outputs": [ - { - "output_type": "stream", - "text": [ - "100%|██████████| 133/133 [00:11<00:00, 11.98it/s]\n" - ], - "name": "stderr" - }, - { - "output_type": "execute_result", - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 5 - } ] } - ] + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 0 } \ No newline at end of file diff --git a/demo.py b/demo.py index b41b8ce..74ddb41 100644 --- a/demo.py +++ b/demo.py @@ -33,7 +33,7 @@ def load_checkpoints(config_path, checkpoint_path, cpu=False): with open(config_path) as f: - config = yaml.load(f) + config = yaml.load(f, Loader=yaml.SafeLoader) generator = Generator(num_regions=config['model_params']['num_regions'], num_channels=config['model_params']['num_channels'],