Skip to content

Instantly share code, notes, and snippets.

@lunaisnotaboy
Last active May 9, 2021 23:39
Show Gist options
  • Save lunaisnotaboy/f003faab394cbef9d189252bcb0c83b6 to your computer and use it in GitHub Desktop.
Save lunaisnotaboy/f003faab394cbef9d189252bcb0c83b6 to your computer and use it in GitHub Desktop.

Revisions

  1. lunaisnotaboy revised this gist May 9, 2021. No changes.
  2. lunaisnotaboy revised this gist May 9, 2021. No changes.
  3. lunaisnotaboy revised this gist May 9, 2021. 1 changed file with 17 additions and 440 deletions.
    457 changes: 17 additions & 440 deletions video2x_on_colab.ipynb
    Original file line number Diff line number Diff line change
    @@ -43,149 +43,32 @@
    {
    "cell_type": "code",
    "metadata": {
    "id": "KHWzMi7epefm",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "39706ca4-e43b-4cef-ae15-0bd42c1cc8aa"
    "id": "KHWzMi7epefm"
    },
    "source": [
    "!apt install ffmpeg\n",
    "!apt install libmagic1 python3-yaml\n",
    "!apt install libvulkan-dev\n",
    "!pip install --user youtube-dl "
    ],
    "execution_count": 1,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Reading package lists... Done\n",
    "Building dependency tree \n",
    "Reading state information... Done\n",
    "ffmpeg is already the newest version (7:3.4.8-0ubuntu0.2).\n",
    "The following package was automatically installed and is no longer required:\n",
    " libnvidia-common-460\n",
    "Use 'apt autoremove' to remove it.\n",
    "0 upgraded, 0 newly installed, 0 to remove and 34 not upgraded.\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 'apt autoremove' to remove it.\n",
    "The following additional packages will be installed:\n",
    " libmagic-mgc\n",
    "Suggested packages:\n",
    " file\n",
    "The following NEW packages will be installed:\n",
    " libmagic-mgc libmagic1 python3-yaml\n",
    "0 upgraded, 3 newly installed, 0 to remove and 34 not upgraded.\n",
    "Need to get 362 kB of archives.\n",
    "After this operation, 5,684 kB of additional disk space will be used.\n",
    "Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic-mgc amd64 1:5.32-2ubuntu0.4 [184 kB]\n",
    "Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.4 [68.6 kB]\n",
    "Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-yaml amd64 3.12-1build2 [109 kB]\n",
    "Fetched 362 kB in 1s (592 kB/s)\n",
    "Selecting previously unselected package libmagic-mgc.\n",
    "(Reading database ... 160706 files and directories currently installed.)\n",
    "Preparing to unpack .../libmagic-mgc_1%3a5.32-2ubuntu0.4_amd64.deb ...\n",
    "Unpacking libmagic-mgc (1:5.32-2ubuntu0.4) ...\n",
    "Selecting previously unselected package libmagic1:amd64.\n",
    "Preparing to unpack .../libmagic1_1%3a5.32-2ubuntu0.4_amd64.deb ...\n",
    "Unpacking libmagic1:amd64 (1:5.32-2ubuntu0.4) ...\n",
    "Selecting previously unselected package python3-yaml.\n",
    "Preparing to unpack .../python3-yaml_3.12-1build2_amd64.deb ...\n",
    "Unpacking python3-yaml (3.12-1build2) ...\n",
    "Setting up python3-yaml (3.12-1build2) ...\n",
    "Setting up libmagic-mgc (1:5.32-2ubuntu0.4) ...\n",
    "Setting up libmagic1:amd64 (1:5.32-2ubuntu0.4) ...\n",
    "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n",
    "Processing triggers for libc-bin (2.27-3ubuntu1.2) ...\n",
    "/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link\n",
    "\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 'apt autoremove' to remove it.\n",
    "The following additional packages will be installed:\n",
    " libvulkan1 mesa-vulkan-drivers\n",
    "The following NEW packages will be installed:\n",
    " libvulkan-dev libvulkan1 mesa-vulkan-drivers\n",
    "0 upgraded, 3 newly installed, 0 to remove and 34 not upgraded.\n",
    "Need to get 3,632 kB of archives.\n",
    "After this operation, 22.2 MB of additional disk space will be used.\n",
    "Get:1 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 libvulkan1 amd64 1.1.126.0-2~gpu18.04.1 [101 kB]\n",
    "Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 mesa-vulkan-drivers amd64 20.0.8-0ubuntu1~18.04.1 [3,059 kB]\n",
    "Get:3 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 libvulkan-dev amd64 1.1.126.0-2~gpu18.04.1 [472 kB]\n",
    "Fetched 3,632 kB in 1s (3,837 kB/s)\n",
    "Selecting previously unselected package libvulkan1:amd64.\n",
    "(Reading database ... 160752 files and directories currently installed.)\n",
    "Preparing to unpack .../libvulkan1_1.1.126.0-2~gpu18.04.1_amd64.deb ...\n",
    "Unpacking libvulkan1:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Selecting previously unselected package libvulkan-dev:amd64.\n",
    "Preparing to unpack .../libvulkan-dev_1.1.126.0-2~gpu18.04.1_amd64.deb ...\n",
    "Unpacking libvulkan-dev:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Selecting previously unselected package mesa-vulkan-drivers:amd64.\n",
    "Preparing to unpack .../mesa-vulkan-drivers_20.0.8-0ubuntu1~18.04.1_amd64.deb ...\n",
    "Unpacking mesa-vulkan-drivers:amd64 (20.0.8-0ubuntu1~18.04.1) ...\n",
    "Setting up libvulkan1:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Setting up mesa-vulkan-drivers:amd64 (20.0.8-0ubuntu1~18.04.1) ...\n",
    "Setting up libvulkan-dev:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Processing triggers for libc-bin (2.27-3ubuntu1.2) ...\n",
    "/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link\n",
    "\n",
    "Collecting youtube-dl\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/f4/93/3faf0e257fe2d37672901b46739bf63e198066e53dd02d956d6b2daa9c49/youtube_dl-2021.4.26-py2.py3-none-any.whl (1.9MB)\n",
    "\u001b[K |████████████████████████████████| 1.9MB 18.8MB/s \n",
    "\u001b[?25hInstalling collected packages: youtube-dl\n",
    "\u001b[33m WARNING: The script youtube-dl is installed in '/root/.local/bin' which is not on PATH.\n",
    " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\n",
    "Successfully installed youtube-dl-2021.4.26\n"
    ],
    "name": "stdout"
    }
    ]
    "execution_count": null,
    "outputs": []
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "J_HgTNbqsb7b",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "2aabc51d-9c3b-45de-a876-7a02b6f31537"
    "id": "J_HgTNbqsb7b"
    },
    "source": [
    "!git clone https://github.com/k4yt3x/video2x.git"
    ],
    "execution_count": 2,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Cloning into 'video2x'...\n",
    "remote: Enumerating objects: 2898, done.\u001b[K\n",
    "remote: Counting objects: 100% (107/107), done.\u001b[K\n",
    "remote: Compressing objects: 100% (82/82), done.\u001b[K\n",
    "remote: Total 2898 (delta 57), reused 64 (delta 23), pack-reused 2791\u001b[K\n",
    "Receiving objects: 100% (2898/2898), 10.11 MiB | 34.74 MiB/s, done.\n",
    "Resolving deltas: 100% (1928/1928), done.\n"
    ],
    "name": "stdout"
    }
    ]
    "execution_count": null,
    "outputs": []
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "AYqbe1d-s_Qd",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "31df796e-c796-4c2c-9bd6-51263b60bf99"
    "id": "AYqbe1d-s_Qd"
    },
    "source": [
    "import os\n",
    @@ -196,90 +79,13 @@
    "!wget -O video2x.yaml http://akas.io/v2xcolab\n",
    "os.chdir('../..')"
    ],
    "execution_count": 3,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Note: checking out '4.7.0'.\n",
    "\n",
    "You are in 'detached HEAD' state. You can look around, make experimental\n",
    "changes and commit them, and you can discard any commits you make in this\n",
    "state without impacting any branches by performing another checkout.\n",
    "\n",
    "If you want to create a new branch to retain commits you create, you may\n",
    "do so (now or later) by using -b with the checkout command again. Example:\n",
    "\n",
    " git checkout -b <new-branch-name>\n",
    "\n",
    "HEAD is now at c2260ca updated wordings and translations\n",
    "Ignoring python-magic-bin: markers 'platform_system == \"Windows\"' don't match your environment\n",
    "Collecting avalon_framework\n",
    " Downloading https://files.pythonhosted.org/packages/42/54/2eb7bd419cdb63c19ce11ddbf428baf84991b505775b524e3e6e48717eb4/avalon_framework-1.8.2.tar.gz\n",
    "Collecting colorama\n",
    " Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl\n",
    "Collecting patool\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/43/94/52243ddff508780dd2d8110964320ab4851134a55ab102285b46e740f76a/patool-1.12-py2.py3-none-any.whl (77kB)\n",
    "\u001b[K |████████████████████████████████| 81kB 9.7MB/s \n",
    "\u001b[?25hRequirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 4)) (7.1.2)\n",
    "Collecting pyqt5\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/ed/62/cd9f10702c75b242f82da858668fba0cda04cda92133244d3d1555e530b4/PyQt5-5.15.4-cp36.cp37.cp38.cp39-abi3-manylinux2014_x86_64.whl (8.3MB)\n",
    "\u001b[K |████████████████████████████████| 8.3MB 15.9MB/s \n",
    "\u001b[?25hCollecting python-magic\n",
    " Downloading https://files.pythonhosted.org/packages/ba/7c/1d1d4bdda29bfec662b9b50951dee2dddf7747d3cbf7777f3d1c63372bd0/python_magic-0.4.22-py2.py3-none-any.whl\n",
    "Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 8)) (3.13)\n",
    "Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 9)) (2.23.0)\n",
    "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 10)) (4.41.1)\n",
    "Collecting PyQt5-sip<13,>=12.8\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/31/24/f887203677955ba4d5d4efe9176ac7ed2bf84efce8c243ab91e63183ad9e/PyQt5_sip-12.8.1-cp37-cp37m-manylinux1_x86_64.whl (283kB)\n",
    "\u001b[K |████████████████████████████████| 286kB 58.2MB/s \n",
    "\u001b[?25hCollecting PyQt5-Qt5>=5.15\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/83/d4/241a6a518d0bcf0a9fcdcbad5edfed18d43e884317eab8d5230a2b27e206/PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (59.9MB)\n",
    "\u001b[K |████████████████████████████████| 59.9MB 1.2MB/s \n",
    "\u001b[?25hRequirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (3.0.4)\n",
    "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (1.24.3)\n",
    "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (2020.12.5)\n",
    "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (2.10)\n",
    "Building wheels for collected packages: avalon-framework\n",
    " Building wheel for avalon-framework (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
    " Created wheel for avalon-framework: filename=avalon_framework-1.8.2-cp37-none-any.whl size=3887 sha256=192b3baeb6e188a9120809beee23d5f1aa7171380c79f6bcda4b16c21c1d3e30\n",
    " Stored in directory: /root/.cache/pip/wheels/bc/dc/66/b70eaa8087bebd78ea3710db7e7c228158adf7f06126d3f74f\n",
    "Successfully built avalon-framework\n",
    "Installing collected packages: avalon-framework, colorama, patool, PyQt5-sip, PyQt5-Qt5, pyqt5, python-magic\n",
    "Successfully installed PyQt5-Qt5-5.15.2 PyQt5-sip-12.8.1 avalon-framework-1.8.2 colorama-0.4.4 patool-1.12 pyqt5-5.15.4 python-magic-0.4.22\n",
    "--2021-05-09 23:16:17-- http://akas.io/v2xcolab\n",
    "Resolving akas.io (akas.io)... 172.67.159.114, 104.21.66.110, 2606:4700:3033::ac43:9f72, ...\n",
    "Connecting to akas.io (akas.io)|172.67.159.114|:80... connected.\n",
    "HTTP request sent, awaiting response... 301 Moved Permanently\n",
    "Location: https://akas.io/v2xcolab [following]\n",
    "--2021-05-09 23:16:17-- https://akas.io/v2xcolab\n",
    "Connecting to akas.io (akas.io)|172.67.159.114|:443... connected.\n",
    "HTTP request sent, awaiting response... 301 Moved Permanently\n",
    "Location: https://gist.github.com/Felixkruemel/71e62de4bb38965ead2e0f4bae7ef4ee/raw/video2x.yaml [following]\n",
    "--2021-05-09 23:16:17-- https://gist.github.com/Felixkruemel/71e62de4bb38965ead2e0f4bae7ef4ee/raw/video2x.yaml\n",
    "Resolving gist.github.com (gist.github.com)... 185.199.110.133, 185.199.111.133, 185.199.109.133, ...\n",
    "Connecting to gist.github.com (gist.github.com)|185.199.110.133|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 11269 (11K) [text/plain]\n",
    "Saving to: ‘video2x.yaml’\n",
    "\n",
    "video2x.yaml 100%[===================>] 11.00K --.-KB/s in 0s \n",
    "\n",
    "2021-05-09 23:16:17 (45.6 MB/s) - ‘video2x.yaml’ saved [11269/11269]\n",
    "\n"
    ],
    "name": "stdout"
    }
    ]
    "execution_count": null,
    "outputs": []
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "L-B9cbd3svK3",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "5c49874b-b2df-4915-82e3-82e03e0f54c5"
    "id": "L-B9cbd3svK3"
    },
    "source": [
    "!wget https://github.com/nihui/realsr-ncnn-vulkan/releases/download/20200818/realsr-ncnn-vulkan-20200818-linux.zip\n",
    @@ -289,120 +95,8 @@
    "!wget https://github.com/nihui/srmd-ncnn-vulkan/releases/download/20200818/srmd-ncnn-vulkan-20200818-linux.zip\n",
    "!7z x srmd-ncnn-vulkan-20200818-linux.zip"
    ],
    "execution_count": 14,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "--2021-05-09 23:23:32-- https://github.com/nihui/realsr-ncnn-vulkan/releases/download/20200818/realsr-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.114.3\n",
    "Connecting to github.com (github.com)|140.82.114.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/266992649/4532cf80-e1a6-11ea-92d4-a7ec957f8881?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232332Z&X-Amz-Expires=300&X-Amz-Signature=30ec643780e6c6d5ed3556aa6d3909427f50f1fce3e6008b0e2ddf8d543f34fa&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=266992649&response-content-disposition=attachment%3B%20filename%3Drealsr-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:32-- https://github-releases.githubusercontent.com/266992649/4532cf80-e1a6-11ea-92d4-a7ec957f8881?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232332Z&X-Amz-Expires=300&X-Amz-Signature=30ec643780e6c6d5ed3556aa6d3909427f50f1fce3e6008b0e2ddf8d543f34fa&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=266992649&response-content-disposition=attachment%3B%20filename%3Drealsr-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 63191916 (60M) [application/octet-stream]\n",
    "Saving to: ‘realsr-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "realsr-ncnn-vulkan- 100%[===================>] 60.26M 110MB/s in 0.5s \n",
    "\n",
    "2021-05-09 23:23:32 (110 MB/s) - ‘realsr-ncnn-vulkan-20200818-linux.zip’ saved [63191916/63191916]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 63191916 bytes (61 MiB)\n",
    "\n",
    "Extracting archive: realsr-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = realsr-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 63191916\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 26% 3 - realsr-ncnn-vulkan-20200818-linux/models-DF2K/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 52% 6 - realsr-ncnn-vulkan-20200818-linux/models-DF2K_JPEG/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 79% 6 - realsr-ncnn-vulkan-20200818-linux/models-DF2K_JPEG/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 97% 8 - realsr-ncnn-vulkan-20200818-linux/realsr-ncnn-vulkan\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 3\n",
    "Files: 6\n",
    "Size: 71000625\n",
    "Compressed: 63191916\n",
    "--2021-05-09 23:23:33-- https://github.com/nihui/waifu2x-ncnn-vulkan/releases/download/20200818/waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.112.3\n",
    "Connecting to github.com (github.com)|140.82.112.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/179304752/e3bc3200-e1a0-11ea-956a-50b816565560?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232334Z&X-Amz-Expires=300&X-Amz-Signature=409e61bdc94cbb0c8844d4fa15170c1f9e42663dcb91a9a258af4583a471c534&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=179304752&response-content-disposition=attachment%3B%20filename%3Dwaifu2x-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:34-- https://github-releases.githubusercontent.com/179304752/e3bc3200-e1a0-11ea-956a-50b816565560?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232334Z&X-Amz-Expires=300&X-Amz-Signature=409e61bdc94cbb0c8844d4fa15170c1f9e42663dcb91a9a258af4583a471c534&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=179304752&response-content-disposition=attachment%3B%20filename%3Dwaifu2x-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 34790822 (33M) [application/octet-stream]\n",
    "Saving to: ‘waifu2x-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "waifu2x-ncnn-vulkan 100%[===================>] 33.18M 130MB/s in 0.3s \n",
    "\n",
    "2021-05-09 23:23:34 (130 MB/s) - ‘waifu2x-ncnn-vulkan-20200818-linux.zip’ saved [34790822/34790822]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 34790822 bytes (34 MiB)\n",
    "\n",
    "Extracting archive: waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 34790822\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 38% 26 - waifu2x-ncnn-vulkan-20200818-linux/models-cunet/noise3_model.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 82% 37 - waifu2x-ncnn-vulkan-20200818-lin . -cunet/noise1_scale2.0x_model.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 4\n",
    "Files: 40\n",
    "Size: 39739616\n",
    "Compressed: 34790822\n",
    "--2021-05-09 23:23:34-- https://github.com/nihui/srmd-ncnn-vulkan/releases/download/20200818/srmd-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.112.3\n",
    "Connecting to github.com (github.com)|140.82.112.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/241619197/862ae400-e1a6-11ea-8f1c-42bd6bf51975?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232335Z&X-Amz-Expires=300&X-Amz-Signature=5b14f632761e35e153eca0d1a59c9c555639cbbd2ef907ccbce487a8e38a664e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=241619197&response-content-disposition=attachment%3B%20filename%3Dsrmd-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:35-- https://github-releases.githubusercontent.com/241619197/862ae400-e1a6-11ea-8f1c-42bd6bf51975?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232335Z&X-Amz-Expires=300&X-Amz-Signature=5b14f632761e35e153eca0d1a59c9c555639cbbd2ef907ccbce487a8e38a664e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=241619197&response-content-disposition=attachment%3B%20filename%3Dsrmd-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 18588126 (18M) [application/octet-stream]\n",
    "Saving to: ‘srmd-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "srmd-ncnn-vulkan-20 100%[===================>] 17.73M --.-KB/s in 0.09s \n",
    "\n",
    "2021-05-09 23:23:35 (189 MB/s) - ‘srmd-ncnn-vulkan-20200818-linux.zip’ saved [18588126/18588126]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 18588126 bytes (18 MiB)\n",
    "\n",
    "Extracting archive: srmd-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = srmd-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 18588126\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 88% 14 - srmd-ncnn-vulkan-20200818-linux/models-srmd/srmdnf_x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 2\n",
    "Files: 14\n",
    "Size: 21862543\n",
    "Compressed: 18588126\n"
    ],
    "name": "stdout"
    }
    ]
    "execution_count": null,
    "outputs": []
    },
    {
    "cell_type": "markdown",
    @@ -416,142 +110,25 @@
    {
    "cell_type": "code",
    "metadata": {
    "id": "aG7elRJztDwm",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "051d7794-ffdd-4ec9-ef55-43ced6ee8979"
    "id": "aG7elRJztDwm"
    },
    "source": [
    "!sh -c '/root/.local/bin/youtube-dl https://www.youtube.com/watch?v=X8TCB9s1kRs -f mp4 -o video.mp4'"
    ],
    "execution_count": 6,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "[youtube] X8TCB9s1kRs: Downloading webpage\n",
    "[youtube] X8TCB9s1kRs: Downloading player 838cc154\n",
    "[download] Destination: video.mp4\n",
    "\u001b[K[download] 100% of 19.44MiB in 00:00\n"
    ],
    "name": "stdout"
    }
    ]
    "execution_count": null,
    "outputs": []
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "CGcpvH3vtEmX",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "48712173-f805-4239-f773-d186c926cc45"
    "id": "CGcpvH3vtEmX"
    },
    "source": [
    "!pip install -U PyYAML\n",
    "!python video2x/src/video2x.py -i /content/video.mp4 -o video_4x.mp4 -d waifu2x_ncnn_vulkan -r 4.0"
    ],
    "execution_count": null,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Requirement already up-to-date: PyYAML in /usr/local/lib/python3.7/dist-packages (5.4.1)\n",
    "\n",
    " __ __ _ _ ___ __ __\n",
    " \\ \\ / / (_) | | |__ \\ \\ \\ / /\n",
    " \\ \\ / / _ __| | ___ ___ ) | \\ V /\n",
    " \\ \\/ / | | / _` | / _ \\ / _ \\ / / > <\n",
    " \\ / | | | (_| | | __/ | (_) | / /_ / . \\\n",
    " \\/ |_| \\__,_| \\___| \\___/ |____| /_/ \\_\\\n",
    "\n",
    "\n",
    " Video2X Video Enlarger\n",
    "\n",
    "\u001b[1m Version 4.3.1\u001b[0m\n",
    "\n",
    "\u001b[32m[+] INFO: Loading files into processing queue\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.353248 [+] INFO: Input path(s): /content/video.mp4\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.360096 [+] INFO: File MIME type: video/mp4\u001b[0m\n",
    "\u001b[32m[+] INFO: Loaded files into processing queue\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.361176 [+] INFO: Input file: /content/video.mp4\u001b[0m\n",
    "\u001b[32m[+] INFO: Reading file information\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.361322 [+] INFO: Executing: /usr/bin/ffprobe -v quiet -print_format json -show_format -show_streams -i /content/video.mp4\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.067857 [+] INFO: Creating cache directory /tmp/video2x\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068276 [+] INFO: Extracted frames are being saved to: /tmp/video2x/tmpbxbos5mv\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068452 [+] INFO: Upscaled frames are being saved to: /tmp/video2x/tmpt7j8vdih\u001b[0m\n",
    "\u001b[32m[+] INFO: Starting upscaling video/GIF\u001b[0m\n",
    "\u001b[32m[+] INFO: Getting total number of frames in the file\u001b[0m\n",
    "\u001b[32m[+] INFO: Calculating scaling parameters\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068744 [+] INFO: Framerate: 24.0\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068811 [+] INFO: Width: 640\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068860 [+] INFO: Height: 360\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068903 [+] INFO: Total number of frames: 6240\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068946 [+] INFO: Output width: 2560\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068988 [+] INFO: Output height: 1440\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069030 [+] INFO: Required scale ratio: 4.0\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069077 [+] INFO: Upscaling jobs queue: [2, 2]\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069189 [+] INFO: Executing: /usr/bin/ffmpeg -hwaccel auto -y -i /content/video.mp4 -pix_fmt rgb24 /tmp/video2x/tmpbxbos5mv/extracted_%0d.png\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.073672 [+] INFO: Main process waiting for subprocesses to exit\u001b[0m\n",
    "ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers\n",
    " built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)\n",
    " configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared\n",
    " libavutil 55. 78.100 / 55. 78.100\n",
    " libavcodec 57.107.100 / 57.107.100\n",
    " libavformat 57. 83.100 / 57. 83.100\n",
    " libavdevice 57. 10.100 / 57. 10.100\n",
    " libavfilter 6.107.100 / 6.107.100\n",
    " libavresample 3. 7. 0 / 3. 7. 0\n",
    " libswscale 4. 8.100 / 4. 8.100\n",
    " libswresample 2. 9.100 / 2. 9.100\n",
    " libpostproc 54. 7.100 / 54. 7.100\n",
    "Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/content/video.mp4':\n",
    " Metadata:\n",
    " major_brand : mp42\n",
    " minor_version : 0\n",
    " compatible_brands: isommp42\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " Duration: 00:04:20.06, start: 0.000000, bitrate: 627 kb/s\n",
    " Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 528 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    " Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    "Stream mapping:\n",
    " Stream #0:0 -> #0:0 (h264 (native) -> png (native))\n",
    "Press [q] to stop, [?] for help\n",
    "\u001b[0;36m[h264 @ 0x559182a3ed00] \u001b[0m\u001b[1;31mA hardware frames context is required for VDPAU decoding.\n",
    "\u001b[0mOutput #0, image2, to '/tmp/video2x/tmpbxbos5mv/extracted_%0d.png':\n",
    " Metadata:\n",
    " major_brand : mp42\n",
    " minor_version : 0\n",
    " compatible_brands: isommp42\n",
    " encoder : Lavf57.83.100\n",
    " Stream #0:0(und): Video: png, rgb24, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 24 tbn, 24 tbc (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    " encoder : Lavc57.107.100 png\n",
    "frame= 6240 fps= 72 q=-0.0 Lsize=N/A time=00:04:20.00 bitrate=N/A speed= 3x \n",
    "video:1192922kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown\n",
    "\u001b[90m2021-05-09 23:25:17.949644 [+] INFO: Subprocess 436 exited with code 0\u001b[0m\n",
    "\u001b[32m[+] INFO: Starting to upscale extracted frames\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.090639 [+] INFO: [upscaler] Subprocess 426 executing: /content/waifu2x-ncnn-vulkan-20200818-linux/waifu2x-ncnn-vulkan -n 2 -s 2 -t 400 -g 0 -j 1:1:1 -i /tmp/video2x/tmpbxbos5mv -o /tmp/video2x/tmpt7j8vdih\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.092116 [+] INFO: Starting progress monitor\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.092792 [+] INFO: Starting upscaled image cleaner\u001b[0m\n",
    "Processing: video.mp4 (pass 1/2): 0%| | 0/6240 [00:00<?, ?it/s]\u001b[90m2021-05-09 23:25:18.107896 [+] INFO: Main process waiting for subprocesses to exit\u001b[0m\n",
    "[0 Tesla T4] queueC=2[8] queueG=0[16] queueT=1[2]\n",
    "[0 Tesla T4] bugsbn1=0 buglbia=0 bugcopc=0 bugihfa=0\n",
    "[0 Tesla T4] fp16p=1 fp16s=1 fp16a=1 int8s=1 int8a=1\n",
    "Processing: video.mp4 (pass 1/2): 42%|####1 | 2612/6240 [11:47<15:56, 3.79it/s]"
    ],
    "name": "stdout"
    }
    ]
    "outputs": []
    },
    {
    "cell_type": "markdown",
  4. lunaisnotaboy revised this gist May 9, 2021. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions video2x_on_colab.ipynb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,8 @@
    "colab": {
    "name": "Video2X_on_Colab.ipynb",
    "provenance": [],
    "collapsed_sections": []
    "collapsed_sections": [],
    "include_colab_link": true
    },
    "kernelspec": {
    "name": "python3",
    @@ -14,6 +15,16 @@
    "accelerator": "GPU"
    },
    "cells": [
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "view-in-github",
    "colab_type": "text"
    },
    "source": [
    "<a href=\"https://colab.research.google.com/gist/lunaisnotaboy/f003faab394cbef9d189252bcb0c83b6/video2x_on_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {
    @@ -536,7 +547,7 @@
    "[0 Tesla T4] queueC=2[8] queueG=0[16] queueT=1[2]\n",
    "[0 Tesla T4] bugsbn1=0 buglbia=0 bugcopc=0 bugihfa=0\n",
    "[0 Tesla T4] fp16p=1 fp16s=1 fp16a=1 int8s=1 int8a=1\n",
    "Processing: video.mp4 (pass 1/2): 42%|####1 | 2608/6240 [11:46<16:08, 3.75it/s]"
    "Processing: video.mp4 (pass 1/2): 42%|####1 | 2612/6240 [11:47<15:56, 3.79it/s]"
    ],
    "name": "stdout"
    }
  5. lunaisnotaboy created this gist May 9, 2021.
    568 changes: 568 additions & 0 deletions video2x_on_colab.ipynb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,568 @@
    {
    "nbformat": 4,
    "nbformat_minor": 0,
    "metadata": {
    "colab": {
    "name": "Video2X_on_Colab.ipynb",
    "provenance": [],
    "collapsed_sections": []
    },
    "kernelspec": {
    "name": "python3",
    "display_name": "Python 3"
    },
    "accelerator": "GPU"
    },
    "cells": [
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "TZc9KswXw0R7"
    },
    "source": [
    "This is an example playbook for using Google Colab with Video2X. Press Shift+Tab to run a line. All ncnn-vulkan upscalers are supported currently\n",
    "\n",
    "Be sure to select a GPU instance under \"Runtime\" above. Depending on the instance you get the speed of upscaling will vary a lot.\n",
    "\n",
    "Be warned: Colab is free to use, but also requires users to not abuse it!\n",
    "\n",
    "In this example a short clip will be upscaled and uploaded to your Google Drive. You will need to enter an authorization key at the last step!"
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "KHWzMi7epefm",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "39706ca4-e43b-4cef-ae15-0bd42c1cc8aa"
    },
    "source": [
    "!apt install ffmpeg\n",
    "!apt install libmagic1 python3-yaml\n",
    "!apt install libvulkan-dev\n",
    "!pip install --user youtube-dl "
    ],
    "execution_count": 1,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Reading package lists... Done\n",
    "Building dependency tree \n",
    "Reading state information... Done\n",
    "ffmpeg is already the newest version (7:3.4.8-0ubuntu0.2).\n",
    "The following package was automatically installed and is no longer required:\n",
    " libnvidia-common-460\n",
    "Use 'apt autoremove' to remove it.\n",
    "0 upgraded, 0 newly installed, 0 to remove and 34 not upgraded.\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 'apt autoremove' to remove it.\n",
    "The following additional packages will be installed:\n",
    " libmagic-mgc\n",
    "Suggested packages:\n",
    " file\n",
    "The following NEW packages will be installed:\n",
    " libmagic-mgc libmagic1 python3-yaml\n",
    "0 upgraded, 3 newly installed, 0 to remove and 34 not upgraded.\n",
    "Need to get 362 kB of archives.\n",
    "After this operation, 5,684 kB of additional disk space will be used.\n",
    "Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic-mgc amd64 1:5.32-2ubuntu0.4 [184 kB]\n",
    "Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.4 [68.6 kB]\n",
    "Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-yaml amd64 3.12-1build2 [109 kB]\n",
    "Fetched 362 kB in 1s (592 kB/s)\n",
    "Selecting previously unselected package libmagic-mgc.\n",
    "(Reading database ... 160706 files and directories currently installed.)\n",
    "Preparing to unpack .../libmagic-mgc_1%3a5.32-2ubuntu0.4_amd64.deb ...\n",
    "Unpacking libmagic-mgc (1:5.32-2ubuntu0.4) ...\n",
    "Selecting previously unselected package libmagic1:amd64.\n",
    "Preparing to unpack .../libmagic1_1%3a5.32-2ubuntu0.4_amd64.deb ...\n",
    "Unpacking libmagic1:amd64 (1:5.32-2ubuntu0.4) ...\n",
    "Selecting previously unselected package python3-yaml.\n",
    "Preparing to unpack .../python3-yaml_3.12-1build2_amd64.deb ...\n",
    "Unpacking python3-yaml (3.12-1build2) ...\n",
    "Setting up python3-yaml (3.12-1build2) ...\n",
    "Setting up libmagic-mgc (1:5.32-2ubuntu0.4) ...\n",
    "Setting up libmagic1:amd64 (1:5.32-2ubuntu0.4) ...\n",
    "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n",
    "Processing triggers for libc-bin (2.27-3ubuntu1.2) ...\n",
    "/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link\n",
    "\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 'apt autoremove' to remove it.\n",
    "The following additional packages will be installed:\n",
    " libvulkan1 mesa-vulkan-drivers\n",
    "The following NEW packages will be installed:\n",
    " libvulkan-dev libvulkan1 mesa-vulkan-drivers\n",
    "0 upgraded, 3 newly installed, 0 to remove and 34 not upgraded.\n",
    "Need to get 3,632 kB of archives.\n",
    "After this operation, 22.2 MB of additional disk space will be used.\n",
    "Get:1 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 libvulkan1 amd64 1.1.126.0-2~gpu18.04.1 [101 kB]\n",
    "Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 mesa-vulkan-drivers amd64 20.0.8-0ubuntu1~18.04.1 [3,059 kB]\n",
    "Get:3 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 libvulkan-dev amd64 1.1.126.0-2~gpu18.04.1 [472 kB]\n",
    "Fetched 3,632 kB in 1s (3,837 kB/s)\n",
    "Selecting previously unselected package libvulkan1:amd64.\n",
    "(Reading database ... 160752 files and directories currently installed.)\n",
    "Preparing to unpack .../libvulkan1_1.1.126.0-2~gpu18.04.1_amd64.deb ...\n",
    "Unpacking libvulkan1:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Selecting previously unselected package libvulkan-dev:amd64.\n",
    "Preparing to unpack .../libvulkan-dev_1.1.126.0-2~gpu18.04.1_amd64.deb ...\n",
    "Unpacking libvulkan-dev:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Selecting previously unselected package mesa-vulkan-drivers:amd64.\n",
    "Preparing to unpack .../mesa-vulkan-drivers_20.0.8-0ubuntu1~18.04.1_amd64.deb ...\n",
    "Unpacking mesa-vulkan-drivers:amd64 (20.0.8-0ubuntu1~18.04.1) ...\n",
    "Setting up libvulkan1:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Setting up mesa-vulkan-drivers:amd64 (20.0.8-0ubuntu1~18.04.1) ...\n",
    "Setting up libvulkan-dev:amd64 (1.1.126.0-2~gpu18.04.1) ...\n",
    "Processing triggers for libc-bin (2.27-3ubuntu1.2) ...\n",
    "/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link\n",
    "\n",
    "Collecting youtube-dl\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/f4/93/3faf0e257fe2d37672901b46739bf63e198066e53dd02d956d6b2daa9c49/youtube_dl-2021.4.26-py2.py3-none-any.whl (1.9MB)\n",
    "\u001b[K |████████████████████████████████| 1.9MB 18.8MB/s \n",
    "\u001b[?25hInstalling collected packages: youtube-dl\n",
    "\u001b[33m WARNING: The script youtube-dl is installed in '/root/.local/bin' which is not on PATH.\n",
    " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\n",
    "Successfully installed youtube-dl-2021.4.26\n"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "J_HgTNbqsb7b",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "2aabc51d-9c3b-45de-a876-7a02b6f31537"
    },
    "source": [
    "!git clone https://github.com/k4yt3x/video2x.git"
    ],
    "execution_count": 2,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Cloning into 'video2x'...\n",
    "remote: Enumerating objects: 2898, done.\u001b[K\n",
    "remote: Counting objects: 100% (107/107), done.\u001b[K\n",
    "remote: Compressing objects: 100% (82/82), done.\u001b[K\n",
    "remote: Total 2898 (delta 57), reused 64 (delta 23), pack-reused 2791\u001b[K\n",
    "Receiving objects: 100% (2898/2898), 10.11 MiB | 34.74 MiB/s, done.\n",
    "Resolving deltas: 100% (1928/1928), done.\n"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "AYqbe1d-s_Qd",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "31df796e-c796-4c2c-9bd6-51263b60bf99"
    },
    "source": [
    "import os\n",
    "os.chdir('video2x/src')\n",
    "!git checkout 4.7.0\n",
    "!pip install -r requirements.txt\n",
    "!rm -rf video2x.yaml\n",
    "!wget -O video2x.yaml http://akas.io/v2xcolab\n",
    "os.chdir('../..')"
    ],
    "execution_count": 3,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Note: checking out '4.7.0'.\n",
    "\n",
    "You are in 'detached HEAD' state. You can look around, make experimental\n",
    "changes and commit them, and you can discard any commits you make in this\n",
    "state without impacting any branches by performing another checkout.\n",
    "\n",
    "If you want to create a new branch to retain commits you create, you may\n",
    "do so (now or later) by using -b with the checkout command again. Example:\n",
    "\n",
    " git checkout -b <new-branch-name>\n",
    "\n",
    "HEAD is now at c2260ca updated wordings and translations\n",
    "Ignoring python-magic-bin: markers 'platform_system == \"Windows\"' don't match your environment\n",
    "Collecting avalon_framework\n",
    " Downloading https://files.pythonhosted.org/packages/42/54/2eb7bd419cdb63c19ce11ddbf428baf84991b505775b524e3e6e48717eb4/avalon_framework-1.8.2.tar.gz\n",
    "Collecting colorama\n",
    " Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl\n",
    "Collecting patool\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/43/94/52243ddff508780dd2d8110964320ab4851134a55ab102285b46e740f76a/patool-1.12-py2.py3-none-any.whl (77kB)\n",
    "\u001b[K |████████████████████████████████| 81kB 9.7MB/s \n",
    "\u001b[?25hRequirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 4)) (7.1.2)\n",
    "Collecting pyqt5\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/ed/62/cd9f10702c75b242f82da858668fba0cda04cda92133244d3d1555e530b4/PyQt5-5.15.4-cp36.cp37.cp38.cp39-abi3-manylinux2014_x86_64.whl (8.3MB)\n",
    "\u001b[K |████████████████████████████████| 8.3MB 15.9MB/s \n",
    "\u001b[?25hCollecting python-magic\n",
    " Downloading https://files.pythonhosted.org/packages/ba/7c/1d1d4bdda29bfec662b9b50951dee2dddf7747d3cbf7777f3d1c63372bd0/python_magic-0.4.22-py2.py3-none-any.whl\n",
    "Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 8)) (3.13)\n",
    "Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 9)) (2.23.0)\n",
    "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 10)) (4.41.1)\n",
    "Collecting PyQt5-sip<13,>=12.8\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/31/24/f887203677955ba4d5d4efe9176ac7ed2bf84efce8c243ab91e63183ad9e/PyQt5_sip-12.8.1-cp37-cp37m-manylinux1_x86_64.whl (283kB)\n",
    "\u001b[K |████████████████████████████████| 286kB 58.2MB/s \n",
    "\u001b[?25hCollecting PyQt5-Qt5>=5.15\n",
    "\u001b[?25l Downloading https://files.pythonhosted.org/packages/83/d4/241a6a518d0bcf0a9fcdcbad5edfed18d43e884317eab8d5230a2b27e206/PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (59.9MB)\n",
    "\u001b[K |████████████████████████████████| 59.9MB 1.2MB/s \n",
    "\u001b[?25hRequirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (3.0.4)\n",
    "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (1.24.3)\n",
    "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (2020.12.5)\n",
    "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->-r requirements.txt (line 9)) (2.10)\n",
    "Building wheels for collected packages: avalon-framework\n",
    " Building wheel for avalon-framework (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
    " Created wheel for avalon-framework: filename=avalon_framework-1.8.2-cp37-none-any.whl size=3887 sha256=192b3baeb6e188a9120809beee23d5f1aa7171380c79f6bcda4b16c21c1d3e30\n",
    " Stored in directory: /root/.cache/pip/wheels/bc/dc/66/b70eaa8087bebd78ea3710db7e7c228158adf7f06126d3f74f\n",
    "Successfully built avalon-framework\n",
    "Installing collected packages: avalon-framework, colorama, patool, PyQt5-sip, PyQt5-Qt5, pyqt5, python-magic\n",
    "Successfully installed PyQt5-Qt5-5.15.2 PyQt5-sip-12.8.1 avalon-framework-1.8.2 colorama-0.4.4 patool-1.12 pyqt5-5.15.4 python-magic-0.4.22\n",
    "--2021-05-09 23:16:17-- http://akas.io/v2xcolab\n",
    "Resolving akas.io (akas.io)... 172.67.159.114, 104.21.66.110, 2606:4700:3033::ac43:9f72, ...\n",
    "Connecting to akas.io (akas.io)|172.67.159.114|:80... connected.\n",
    "HTTP request sent, awaiting response... 301 Moved Permanently\n",
    "Location: https://akas.io/v2xcolab [following]\n",
    "--2021-05-09 23:16:17-- https://akas.io/v2xcolab\n",
    "Connecting to akas.io (akas.io)|172.67.159.114|:443... connected.\n",
    "HTTP request sent, awaiting response... 301 Moved Permanently\n",
    "Location: https://gist.github.com/Felixkruemel/71e62de4bb38965ead2e0f4bae7ef4ee/raw/video2x.yaml [following]\n",
    "--2021-05-09 23:16:17-- https://gist.github.com/Felixkruemel/71e62de4bb38965ead2e0f4bae7ef4ee/raw/video2x.yaml\n",
    "Resolving gist.github.com (gist.github.com)... 185.199.110.133, 185.199.111.133, 185.199.109.133, ...\n",
    "Connecting to gist.github.com (gist.github.com)|185.199.110.133|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 11269 (11K) [text/plain]\n",
    "Saving to: ‘video2x.yaml’\n",
    "\n",
    "video2x.yaml 100%[===================>] 11.00K --.-KB/s in 0s \n",
    "\n",
    "2021-05-09 23:16:17 (45.6 MB/s) - ‘video2x.yaml’ saved [11269/11269]\n",
    "\n"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "L-B9cbd3svK3",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "5c49874b-b2df-4915-82e3-82e03e0f54c5"
    },
    "source": [
    "!wget https://github.com/nihui/realsr-ncnn-vulkan/releases/download/20200818/realsr-ncnn-vulkan-20200818-linux.zip\n",
    "!7z x realsr-ncnn-vulkan-20200818-linux.zip\n",
    "!wget https://github.com/nihui/waifu2x-ncnn-vulkan/releases/download/20200818/waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "!7z x waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "!wget https://github.com/nihui/srmd-ncnn-vulkan/releases/download/20200818/srmd-ncnn-vulkan-20200818-linux.zip\n",
    "!7z x srmd-ncnn-vulkan-20200818-linux.zip"
    ],
    "execution_count": 14,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "--2021-05-09 23:23:32-- https://github.com/nihui/realsr-ncnn-vulkan/releases/download/20200818/realsr-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.114.3\n",
    "Connecting to github.com (github.com)|140.82.114.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/266992649/4532cf80-e1a6-11ea-92d4-a7ec957f8881?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232332Z&X-Amz-Expires=300&X-Amz-Signature=30ec643780e6c6d5ed3556aa6d3909427f50f1fce3e6008b0e2ddf8d543f34fa&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=266992649&response-content-disposition=attachment%3B%20filename%3Drealsr-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:32-- https://github-releases.githubusercontent.com/266992649/4532cf80-e1a6-11ea-92d4-a7ec957f8881?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232332Z&X-Amz-Expires=300&X-Amz-Signature=30ec643780e6c6d5ed3556aa6d3909427f50f1fce3e6008b0e2ddf8d543f34fa&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=266992649&response-content-disposition=attachment%3B%20filename%3Drealsr-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 63191916 (60M) [application/octet-stream]\n",
    "Saving to: ‘realsr-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "realsr-ncnn-vulkan- 100%[===================>] 60.26M 110MB/s in 0.5s \n",
    "\n",
    "2021-05-09 23:23:32 (110 MB/s) - ‘realsr-ncnn-vulkan-20200818-linux.zip’ saved [63191916/63191916]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 63191916 bytes (61 MiB)\n",
    "\n",
    "Extracting archive: realsr-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = realsr-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 63191916\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 26% 3 - realsr-ncnn-vulkan-20200818-linux/models-DF2K/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 52% 6 - realsr-ncnn-vulkan-20200818-linux/models-DF2K_JPEG/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 79% 6 - realsr-ncnn-vulkan-20200818-linux/models-DF2K_JPEG/x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 97% 8 - realsr-ncnn-vulkan-20200818-linux/realsr-ncnn-vulkan\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 3\n",
    "Files: 6\n",
    "Size: 71000625\n",
    "Compressed: 63191916\n",
    "--2021-05-09 23:23:33-- https://github.com/nihui/waifu2x-ncnn-vulkan/releases/download/20200818/waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.112.3\n",
    "Connecting to github.com (github.com)|140.82.112.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/179304752/e3bc3200-e1a0-11ea-956a-50b816565560?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232334Z&X-Amz-Expires=300&X-Amz-Signature=409e61bdc94cbb0c8844d4fa15170c1f9e42663dcb91a9a258af4583a471c534&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=179304752&response-content-disposition=attachment%3B%20filename%3Dwaifu2x-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:34-- https://github-releases.githubusercontent.com/179304752/e3bc3200-e1a0-11ea-956a-50b816565560?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232334Z&X-Amz-Expires=300&X-Amz-Signature=409e61bdc94cbb0c8844d4fa15170c1f9e42663dcb91a9a258af4583a471c534&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=179304752&response-content-disposition=attachment%3B%20filename%3Dwaifu2x-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 34790822 (33M) [application/octet-stream]\n",
    "Saving to: ‘waifu2x-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "waifu2x-ncnn-vulkan 100%[===================>] 33.18M 130MB/s in 0.3s \n",
    "\n",
    "2021-05-09 23:23:34 (130 MB/s) - ‘waifu2x-ncnn-vulkan-20200818-linux.zip’ saved [34790822/34790822]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 34790822 bytes (34 MiB)\n",
    "\n",
    "Extracting archive: waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = waifu2x-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 34790822\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 38% 26 - waifu2x-ncnn-vulkan-20200818-linux/models-cunet/noise3_model.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 82% 37 - waifu2x-ncnn-vulkan-20200818-lin . -cunet/noise1_scale2.0x_model.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 4\n",
    "Files: 40\n",
    "Size: 39739616\n",
    "Compressed: 34790822\n",
    "--2021-05-09 23:23:34-- https://github.com/nihui/srmd-ncnn-vulkan/releases/download/20200818/srmd-ncnn-vulkan-20200818-linux.zip\n",
    "Resolving github.com (github.com)... 140.82.112.3\n",
    "Connecting to github.com (github.com)|140.82.112.3|:443... connected.\n",
    "HTTP request sent, awaiting response... 302 Found\n",
    "Location: https://github-releases.githubusercontent.com/241619197/862ae400-e1a6-11ea-8f1c-42bd6bf51975?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232335Z&X-Amz-Expires=300&X-Amz-Signature=5b14f632761e35e153eca0d1a59c9c555639cbbd2ef907ccbce487a8e38a664e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=241619197&response-content-disposition=attachment%3B%20filename%3Dsrmd-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream [following]\n",
    "--2021-05-09 23:23:35-- https://github-releases.githubusercontent.com/241619197/862ae400-e1a6-11ea-8f1c-42bd6bf51975?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210509%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210509T232335Z&X-Amz-Expires=300&X-Amz-Signature=5b14f632761e35e153eca0d1a59c9c555639cbbd2ef907ccbce487a8e38a664e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=241619197&response-content-disposition=attachment%3B%20filename%3Dsrmd-ncnn-vulkan-20200818-linux.zip&response-content-type=application%2Foctet-stream\n",
    "Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n",
    "Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n",
    "HTTP request sent, awaiting response... 200 OK\n",
    "Length: 18588126 (18M) [application/octet-stream]\n",
    "Saving to: ‘srmd-ncnn-vulkan-20200818-linux.zip’\n",
    "\n",
    "srmd-ncnn-vulkan-20 100%[===================>] 17.73M --.-KB/s in 0.09s \n",
    "\n",
    "2021-05-09 23:23:35 (189 MB/s) - ‘srmd-ncnn-vulkan-20200818-linux.zip’ saved [18588126/18588126]\n",
    "\n",
    "\n",
    "7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\n",
    "p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Xeon(R) CPU @ 2.20GHz (406F0),ASM,AES-NI)\n",
    "\n",
    "Scanning the drive for archives:\n",
    " 0M Scan\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b1 file, 18588126 bytes (18 MiB)\n",
    "\n",
    "Extracting archive: srmd-ncnn-vulkan-20200818-linux.zip\n",
    "--\n",
    "Path = srmd-ncnn-vulkan-20200818-linux.zip\n",
    "Type = zip\n",
    "Physical Size = 18588126\n",
    "\n",
    " 0%\b\b\b\b \b\b\b\b 88% 14 - srmd-ncnn-vulkan-20200818-linux/models-srmd/srmdnf_x4.bin\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bEverything is Ok\n",
    "\n",
    "Folders: 2\n",
    "Files: 14\n",
    "Size: 21862543\n",
    "Compressed: 18588126\n"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "rS7V937Geyqr"
    },
    "source": [
    "Replace the link with the YouTube (or any other site YT-DL supports) link you want to use."
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "aG7elRJztDwm",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "051d7794-ffdd-4ec9-ef55-43ced6ee8979"
    },
    "source": [
    "!sh -c '/root/.local/bin/youtube-dl https://www.youtube.com/watch?v=X8TCB9s1kRs -f mp4 -o video.mp4'"
    ],
    "execution_count": 6,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "[youtube] X8TCB9s1kRs: Downloading webpage\n",
    "[youtube] X8TCB9s1kRs: Downloading player 838cc154\n",
    "[download] Destination: video.mp4\n",
    "\u001b[K[download] 100% of 19.44MiB in 00:00\n"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "CGcpvH3vtEmX",
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "outputId": "48712173-f805-4239-f773-d186c926cc45"
    },
    "source": [
    "!pip install -U PyYAML\n",
    "!python video2x/src/video2x.py -i /content/video.mp4 -o video_4x.mp4 -d waifu2x_ncnn_vulkan -r 4.0"
    ],
    "execution_count": null,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Requirement already up-to-date: PyYAML in /usr/local/lib/python3.7/dist-packages (5.4.1)\n",
    "\n",
    " __ __ _ _ ___ __ __\n",
    " \\ \\ / / (_) | | |__ \\ \\ \\ / /\n",
    " \\ \\ / / _ __| | ___ ___ ) | \\ V /\n",
    " \\ \\/ / | | / _` | / _ \\ / _ \\ / / > <\n",
    " \\ / | | | (_| | | __/ | (_) | / /_ / . \\\n",
    " \\/ |_| \\__,_| \\___| \\___/ |____| /_/ \\_\\\n",
    "\n",
    "\n",
    " Video2X Video Enlarger\n",
    "\n",
    "\u001b[1m Version 4.3.1\u001b[0m\n",
    "\n",
    "\u001b[32m[+] INFO: Loading files into processing queue\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.353248 [+] INFO: Input path(s): /content/video.mp4\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.360096 [+] INFO: File MIME type: video/mp4\u001b[0m\n",
    "\u001b[32m[+] INFO: Loaded files into processing queue\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.361176 [+] INFO: Input file: /content/video.mp4\u001b[0m\n",
    "\u001b[32m[+] INFO: Reading file information\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:50.361322 [+] INFO: Executing: /usr/bin/ffprobe -v quiet -print_format json -show_format -show_streams -i /content/video.mp4\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.067857 [+] INFO: Creating cache directory /tmp/video2x\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068276 [+] INFO: Extracted frames are being saved to: /tmp/video2x/tmpbxbos5mv\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068452 [+] INFO: Upscaled frames are being saved to: /tmp/video2x/tmpt7j8vdih\u001b[0m\n",
    "\u001b[32m[+] INFO: Starting upscaling video/GIF\u001b[0m\n",
    "\u001b[32m[+] INFO: Getting total number of frames in the file\u001b[0m\n",
    "\u001b[32m[+] INFO: Calculating scaling parameters\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068744 [+] INFO: Framerate: 24.0\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068811 [+] INFO: Width: 640\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068860 [+] INFO: Height: 360\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068903 [+] INFO: Total number of frames: 6240\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068946 [+] INFO: Output width: 2560\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.068988 [+] INFO: Output height: 1440\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069030 [+] INFO: Required scale ratio: 4.0\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069077 [+] INFO: Upscaling jobs queue: [2, 2]\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.069189 [+] INFO: Executing: /usr/bin/ffmpeg -hwaccel auto -y -i /content/video.mp4 -pix_fmt rgb24 /tmp/video2x/tmpbxbos5mv/extracted_%0d.png\u001b[0m\n",
    "\u001b[90m2021-05-09 23:23:51.073672 [+] INFO: Main process waiting for subprocesses to exit\u001b[0m\n",
    "ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers\n",
    " built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)\n",
    " configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared\n",
    " libavutil 55. 78.100 / 55. 78.100\n",
    " libavcodec 57.107.100 / 57.107.100\n",
    " libavformat 57. 83.100 / 57. 83.100\n",
    " libavdevice 57. 10.100 / 57. 10.100\n",
    " libavfilter 6.107.100 / 6.107.100\n",
    " libavresample 3. 7. 0 / 3. 7. 0\n",
    " libswscale 4. 8.100 / 4. 8.100\n",
    " libswresample 2. 9.100 / 2. 9.100\n",
    " libpostproc 54. 7.100 / 54. 7.100\n",
    "Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/content/video.mp4':\n",
    " Metadata:\n",
    " major_brand : mp42\n",
    " minor_version : 0\n",
    " compatible_brands: isommp42\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " Duration: 00:04:20.06, start: 0.000000, bitrate: 627 kb/s\n",
    " Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 528 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    " Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    "Stream mapping:\n",
    " Stream #0:0 -> #0:0 (h264 (native) -> png (native))\n",
    "Press [q] to stop, [?] for help\n",
    "\u001b[0;36m[h264 @ 0x559182a3ed00] \u001b[0m\u001b[1;31mA hardware frames context is required for VDPAU decoding.\n",
    "\u001b[0mOutput #0, image2, to '/tmp/video2x/tmpbxbos5mv/extracted_%0d.png':\n",
    " Metadata:\n",
    " major_brand : mp42\n",
    " minor_version : 0\n",
    " compatible_brands: isommp42\n",
    " encoder : Lavf57.83.100\n",
    " Stream #0:0(und): Video: png, rgb24, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 24 tbn, 24 tbc (default)\n",
    " Metadata:\n",
    " creation_time : 2020-03-02T00:38:56.000000Z\n",
    " handler_name : ISO Media file produced by Google Inc. Created on: 03/01/2020.\n",
    " encoder : Lavc57.107.100 png\n",
    "frame= 6240 fps= 72 q=-0.0 Lsize=N/A time=00:04:20.00 bitrate=N/A speed= 3x \n",
    "video:1192922kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown\n",
    "\u001b[90m2021-05-09 23:25:17.949644 [+] INFO: Subprocess 436 exited with code 0\u001b[0m\n",
    "\u001b[32m[+] INFO: Starting to upscale extracted frames\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.090639 [+] INFO: [upscaler] Subprocess 426 executing: /content/waifu2x-ncnn-vulkan-20200818-linux/waifu2x-ncnn-vulkan -n 2 -s 2 -t 400 -g 0 -j 1:1:1 -i /tmp/video2x/tmpbxbos5mv -o /tmp/video2x/tmpt7j8vdih\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.092116 [+] INFO: Starting progress monitor\u001b[0m\n",
    "\u001b[90m2021-05-09 23:25:18.092792 [+] INFO: Starting upscaled image cleaner\u001b[0m\n",
    "Processing: video.mp4 (pass 1/2): 0%| | 0/6240 [00:00<?, ?it/s]\u001b[90m2021-05-09 23:25:18.107896 [+] INFO: Main process waiting for subprocesses to exit\u001b[0m\n",
    "[0 Tesla T4] queueC=2[8] queueG=0[16] queueT=1[2]\n",
    "[0 Tesla T4] bugsbn1=0 buglbia=0 bugcopc=0 bugihfa=0\n",
    "[0 Tesla T4] fp16p=1 fp16s=1 fp16a=1 int8s=1 int8a=1\n",
    "Processing: video.mp4 (pass 1/2): 42%|####1 | 2608/6240 [11:46<16:08, 3.75it/s]"
    ],
    "name": "stdout"
    }
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "cPhLseBZxhEN"
    },
    "source": [
    "Enter your authorization key below. Just follow the steps :)"
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "sCQAsq2SuN4H"
    },
    "source": [
    "from google.colab import drive\n",
    "drive.mount('/content/gdrive')\n",
    "!cp video_4x.mp4 \"gdrive/My Drive/video_4x_2.mp4\""
    ],
    "execution_count": null,
    "outputs": []
    }
    ]
    }