├── README.md └── automatic-3d-ken-burns.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Automatic 3D Ken Burns Effect from a Single Image 2 | 3 | A PyTorch based implementation of the techniques presented in the following paper: ['3D Ken Burns Effect from a Single Image'](https://arxiv.org/abs/1909.05483). 4 | 5 | ## Getting Started 6 | To get started simply click the following badge: 7 | 8 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/agmm/colab-3d-ken-burns/blob/master/automatic-3d-ken-burns.ipynb) 9 | 10 | ## Note 11 | Before running this notebook make sure that your runtime type is 'Python 3 with GPU acceleration'. 12 | 13 | ## Credits 14 | - Implementation by: [Simon Niklaus](https://github.com/sniklaus/3d-ken-burns) 15 | - Google Colab notebook by: [Arnaldo Gabriel](https://github.com/agmm/colab-3d-ken-burns) 16 | 17 | ## More Info 18 | - Paper: https://arxiv.org/abs/1909.05483 19 | - Repo: https://github.com/sniklaus/3d-ken-burns 20 | - Video: https://www.youtube.com/watch?v=WrajxHHfRBA -------------------------------------------------------------------------------- /automatic-3d-ken-burns.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "colab-3d-ken-burns.ipynb", 7 | "provenance": [], 8 | "private_outputs": true, 9 | "collapsed_sections": [] 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "accelerator": "GPU" 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "A8Nop9pf84kR", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "# Automatic 3D Ken Burns Effect from a Single Image\n", 26 | "\n", 27 | "A PyTorch based implementation of the techniques presented in the following paper: ['3D Ken Burns Effect from a Single Image'](https://arxiv.org/abs/1909.05483).\n", 28 | "\n", 29 | "## Note\n", 30 | "Before running this notebook make sure that your runtime type is 'Python 3 with GPU acceleration'.\n", 31 | "\n", 32 | "## Credits\n", 33 | "- Implementation by: [Simon Niklaus](https://github.com/sniklaus/3d-ken-burns)\n", 34 | "- Google Colab notebook by: [Arnaldo Gabriel](https://github.com/agmm/colab-3d-ken-burns)\n", 35 | "\n", 36 | "## More Info\n", 37 | "- Paper: https://arxiv.org/abs/1909.05483\n", 38 | "- Repo: https://github.com/sniklaus/3d-ken-burns\n", 39 | "- Video: https://www.youtube.com/watch?v=WrajxHHfRBA" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "metadata": { 45 | "id": "ySAPF18KOMOx", 46 | "colab_type": "code", 47 | "colab": {} 48 | }, 49 | "source": [ 50 | "# Download the repo from Github\n", 51 | "!git clone https://github.com/sniklaus/3d-ken-burns.git" 52 | ], 53 | "execution_count": 0, 54 | "outputs": [] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "metadata": { 59 | "id": "i6Aha-7YPALc", 60 | "colab_type": "code", 61 | "colab": {} 62 | }, 63 | "source": [ 64 | "# Move into the downloaded repository\n", 65 | "%cd 3d-ken-burns" 66 | ], 67 | "execution_count": 0, 68 | "outputs": [] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "metadata": { 73 | "id": "KeM53Mcy0s86", 74 | "colab_type": "code", 75 | "colab": {} 76 | }, 77 | "source": [ 78 | "# Create a new directory to store the videos\n", 79 | "!mkdir videos" 80 | ], 81 | "execution_count": 0, 82 | "outputs": [] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "metadata": { 87 | "id": "ZydVEq3jOTKD", 88 | "colab_type": "code", 89 | "colab": {} 90 | }, 91 | "source": [ 92 | "# Install dependencies\n", 93 | "!pip install cupy\n", 94 | "!pip install moviepy" 95 | ], 96 | "execution_count": 0, 97 | "outputs": [] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "metadata": { 102 | "id": "4Nl4SOOhr9HR", 103 | "colab_type": "code", 104 | "colab": {} 105 | }, 106 | "source": [ 107 | "# Setup environment variable for CUDA\n", 108 | "%env CUDA_HOME=/usr/local/cuda" 109 | ], 110 | "execution_count": 0, 111 | "outputs": [] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "metadata": { 116 | "id": "kPwSizSvqhtt", 117 | "colab_type": "code", 118 | "colab": {} 119 | }, 120 | "source": [ 121 | "# Download the pre-trained models\n", 122 | "!bash download.bash" 123 | ], 124 | "execution_count": 0, 125 | "outputs": [] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "metadata": { 130 | "id": "rnePDQ6XO1XO", 131 | "colab_type": "code", 132 | "colab": {} 133 | }, 134 | "source": [ 135 | "# Generate the autozoom video\n", 136 | "!python autozoom.py --in ./images/doublestrike.jpg --out ./videos/autozoom.mp4" 137 | ], 138 | "execution_count": 0, 139 | "outputs": [] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "metadata": { 144 | "id": "Tlwr5Lj7uQgB", 145 | "colab_type": "code", 146 | "colab": {} 147 | }, 148 | "source": [ 149 | "# Play the generated video\n", 150 | "from IPython.display import HTML\n", 151 | "from base64 import b64encode\n", 152 | "\n", 153 | "def video(path):\n", 154 | " mp4 = open(path,'rb').read()\n", 155 | " data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n", 156 | " return HTML('' % data_url)\n", 157 | "\n", 158 | "video('./videos/autozoom.mp4')" 159 | ], 160 | "execution_count": 0, 161 | "outputs": [] 162 | } 163 | ] 164 | } --------------------------------------------------------------------------------