diff --git a/demo.ipynb b/demo.ipynb
index 799db13..7720140 100644
--- a/demo.ipynb
+++ b/demo.ipynb
@@ -1,4041 +1,4015 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- "
"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "cdO_RxQZLahB"
- },
- "source": [
- "# Demo for paper \"Motion Representations for Articulated Animation\""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "GCDNKsEGLtR6"
- },
- "source": [
- "**Clone repository**"
- ]
+ "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"
},
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
+ "cells": [
{
- "ename": "SyntaxError",
- "evalue": "invalid syntax (, line 1)",
- "output_type": "error",
- "traceback": [
- "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m git clone https://github.com/AliaksandrSiarohin/motion-articulated\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
- ]
- }
- ],
- "source": [
- "git clone https://github.com/AliaksandrSiarohin/motion-articulated"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 34
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
},
- "colab_type": "code",
- "id": "PBp6l_4bBYUL",
- "outputId": "4d5061c1-d609-495e-b505-e94a9005a3ba"
- },
- "outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[Errno 2] No such file or directory: 'motion-articulated'\n",
- "/home/gin/fomm-private2\n"
- ]
- }
- ],
- "source": [
- "cd motion-articulated"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "IcMX7ueZO0Oa"
- },
- "source": [
- "**Mount your Google drive folder on Colab**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 124
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "-FPGt7_2z7fn"
+ },
+ "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"
+ ]
},
- "colab_type": "code",
- "id": "tDbMA8R9OuUo",
- "outputId": "42716933-edfc-4871-a3b2-407b6bdf261a"
- },
- "outputs": [
{
- "ename": "ModuleNotFoundError",
- "evalue": "No module named 'google.colab'",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mgoogle\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolab\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdrive\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mdrive\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmount\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/content/gdrive'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'google.colab'"
- ]
- }
- ],
- "source": [
- "from google.colab import drive\n",
- "drive.mount('/content/gdrive')"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "VsgVK1EURXkd"
- },
- "source": [
- "**Add folder https://drive.google.com/drive/folders/1kZ1gCnpfU0BnpdU47pLM_TQ6RypDDqgw?usp=sharing to your google drive.**"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "rW-ipQXPOWUo"
- },
- "source": [
- "**Load driving video and source image**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 453
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "2LoHDHBHyzzZ",
+ "outputId": "43840da9-0105-48d6-efc6-5977ff106cb2"
+ },
+ "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"
+ }
+ ]
},
- "colab_type": "code",
- "id": "Oxi6-riLOgnm",
- "outputId": "df5ef72c-6133-4607-8684-045613fd81f2"
- },
- "outputs": [
{
- "data": {
- "text/html": [
- ""
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "bCmwKAK4zkGC",
+ "outputId": "9b57bd21-9d51-4c87-f67e-358ff24ccd35"
+ },
+ "source": [
+ "cd articulated-animation"
],
- "text/plain": [
- ""
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "/content/articulated-animation\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "YinzvwYd0MWj"
+ },
+ "source": [
+ "**Load source image and driving video.**"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 453
+ },
+ "id": "CRVOnlASzrhI",
+ "outputId": "02896e4c-3530-4db2-b415-be4c2ae72066"
+ },
+ "source": [
+ "import imageio\n",
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "import matplotlib.animation as animation\n",
+ "from skimage.transform import resize\n",
+ "from IPython.display import HTML\n",
+ "import warnings\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
+ "source_image = imageio.imread('sup-mat/source.png')\n",
+ "driving_video = imageio.mimread('sup-mat/driving.mp4')\n",
+ "\n",
+ "\n",
+ "source_image = resize(source_image, (384, 384))[..., :3]\n",
+ "driving_video = [resize(frame, (384, 384))[..., :3] for frame in driving_video]\n",
+ "\n",
+ "def display(source, driving, generated=None):\n",
+ " fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))\n",
+ "\n",
+ " ims = []\n",
+ " for i in range(len(driving)):\n",
+ " cols = [source]\n",
+ " cols.append(driving[i])\n",
+ " if generated is not None:\n",
+ " cols.append(generated[i])\n",
+ " im = plt.imshow(np.concatenate(cols, axis=1), animated=True)\n",
+ " plt.axis('off')\n",
+ " ims.append([im])\n",
+ "\n",
+ " ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)\n",
+ " plt.close()\n",
+ " return ani\n",
+ " \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
+ }
]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import imageio\n",
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "import matplotlib.animation as animation\n",
- "from skimage.transform import resize\n",
- "from IPython.display import HTML\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\")\n",
- "\n",
- "source_image = imageio.imread('sup-mat/source.png')\n",
- "driving_video = imageio.mimread('sup-mat/driving.mp4')\n",
- "\n",
- "\n",
- "source_image = resize(source_image, (384, 384))[..., :3]\n",
- "driving_video = [resize(frame, (384, 384))[..., :3] for frame in driving_video]\n",
- "\n",
- "def display(source, driving, generated=None):\n",
- " fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))\n",
- "\n",
- " ims = []\n",
- " for i in range(len(driving)):\n",
- " cols = [source]\n",
- " cols.append(driving[i])\n",
- " if generated is not None:\n",
- " cols.append(generated[i])\n",
- " im = plt.imshow(np.concatenate(cols, axis=1), animated=True)\n",
- " plt.axis('off')\n",
- " ims.append([im])\n",
- "\n",
- " ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)\n",
- " plt.close()\n",
- " return ani\n",
- " \n",
- "\n",
- "HTML(display(source_image, driving_video).to_html5_video())"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "xjM7ubVfWrwT"
- },
- "source": [
- "**Create a model and load checkpoints**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "3FQiXqQPWt5B"
- },
- "outputs": [],
- "source": [
- "from demo import load_checkpoints\n",
- "\n",
- "generator, region_predictor, avd_network = load_checkpoints(config_path='config/ted384.yaml',\n",
- " checkpoint_path='ted384.pth')"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "fdFdasHEj3t7"
- },
- "source": [
- "**Perfrorm image animation**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 471
},
- "colab_type": "code",
- "id": "SB12II11kF4c",
- "outputId": "c7f18b37-0d41-4761-e354-5b0c36cae30d"
- },
- "outputs": [
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "100%|██████████| 133/133 [00:50<00:00, 2.65it/s]\n"
- ]
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "11vorkyV0Wbk"
+ },
+ "source": [
+ "**Load checkpoints.**"
+ ]
},
{
- "data": {
- "text/html": [
- ""
+ "cell_type": "code",
+ "metadata": {
+ "id": "n49-tAcEzzeG"
+ },
+ "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')"
],
- "text/plain": [
- ""
+ "execution_count": 4,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "wP-o3LQq0a79"
+ },
+ "source": [
+ "**Perform animation.**"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 471
+ },
+ "id": "Lcv6u7Bcz27V",
+ "outputId": "eabd3a58-f0e6-4908-fc9c-b5fbb038e7fa"
+ },
+ "source": [
+ "from demo import make_animation\n",
+ "from skimage import img_as_ubyte\n",
+ "\n",
+ "predictions = make_animation(source_image, driving_video, generator, \n",
+ " region_predictor, avd_network, animation_mode='avd')\n",
+ "\n",
+ "#save resulting video\n",
+ "imageio.mimsave('generated.mp4', [img_as_ubyte(frame) for frame in predictions])\n",
+ "#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
+ }
]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
}
- ],
- "source": [
- "from demo import make_animation\n",
- "from skimage import img_as_ubyte\n",
- "\n",
- "predictions = make_animation(source_image, driving_video, generator, \n",
- " region_predictor, avd_network, animation_mode='avd')\n",
- "\n",
- "#save resulting video\n",
- "imageio.mimsave('generated.mp4', [img_as_ubyte(frame) for frame in predictions])\n",
- "#video can be downloaded from /content folder\n",
- "\n",
- "HTML(display(source_image, driving_video, predictions).to_html5_video())"
- ]
- }
- ],
- "metadata": {
- "accelerator": "GPU",
- "colab": {
- "include_colab_link": true,
- "name": "first-order-model-demo.ipynb",
- "provenance": [],
- "toc_visible": true
- },
- "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.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ ]
+}
\ No newline at end of file