{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "7TLDy5mi1rid" }, "source": [ "# Run once only!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "nG64GBsoyoMH" }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "--fxPES99Cp0", "outputId": "aa291a7e-68b8-4115-f177-fad3ce43a8fd" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Cloning into 'GPEN'...\n", "remote: Enumerating objects: 142, done.\u001b[K\n", "remote: Counting objects: 100% (142/142), done.\u001b[K\n", "remote: Compressing objects: 100% (123/123), done.\u001b[K\n", "remote: Total 142 (delta 21), reused 127 (delta 12), pack-reused 0\u001b[K\n", "Receiving objects: 100% (142/142), 22.05 MiB | 39.74 MiB/s, done.\n", "Resolving deltas: 100% (21/21), done.\n" ] } ], "source": [ "! git clone https://github.com/KenjieDec/GPEN GPEN" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "t8AU9f7U-vKz", "outputId": "b2489822-858c-4e26-82c4-9da16573501c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2021-06-13 05:26:36-- https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/RetinaFace-R50.pth\n", "Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.25\n", "Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.25|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 109497761 (104M) [application/octet-stream]\n", "Saving to: ‘RetinaFace-R50.pth’\n", "\n", "RetinaFace-R50.pth 100%[===================>] 104.42M 9.53MB/s in 17s \n", "\n", "2021-06-13 05:26:55 (6.17 MB/s) - ‘RetinaFace-R50.pth’ saved [109497761/109497761]\n", "\n", "--2021-06-13 05:26:55-- https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-512.pth\n", "Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.25\n", "Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.25|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 284085738 (271M) [application/octet-stream]\n", "Saving to: ‘GPEN-512.pth’\n", "\n", "GPEN-512.pth 100%[===================>] 270.92M 8.48MB/s in 43s \n", "\n", "2021-06-13 05:27:40 (6.30 MB/s) - ‘GPEN-512.pth’ saved [284085738/284085738]\n", "\n", "--2021-06-13 05:27:40-- https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-1024-Color.pth\n", "Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.25\n", "Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.25|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 284914645 (272M) [application/octet-stream]\n", "Saving to: ‘GPEN-1024-Color.pth’\n", "\n", "GPEN-1024-Color.pth 100%[===================>] 271.71M 9.09MB/s in 42s \n", "\n", "2021-06-13 05:28:25 (6.43 MB/s) - ‘GPEN-1024-Color.pth’ saved [284914645/284914645]\n", "\n" ] } ], "source": [ "!wget \"https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/RetinaFace-R50.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116085&Signature=GlUNW6%2B8FxvxWmE9jKIZYOOciKQ%3D\" -O GPEN/weights/RetinaFace-R50.pth\n", "!wget \"https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-512.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116208&Signature=hBgvVvKVSNGeXqT8glG%2Bd2t2OKc%3D\" -O GPEN/weights/GPEN-512.pth\n", "!wget \"https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-Colorization-1024.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116315&Signature=9tPavW2h%2F1LhIKiXj73sTQoWqcc%3D\" -O GPEN/weights/GPEN-1024-Color.pth " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Zfc5z0CyAVKY", "outputId": "98dc0eab-167c-4415-96f5-9e8af5bc2a6e" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting torch==1.7.1\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/90/5d/095ddddc91c8a769a68c791c019c5793f9c4456a688ddd235d6670924ecb/torch-1.7.1-cp37-cp37m-manylinux1_x86_64.whl (776.8MB)\n", "\u001b[K |████████████████████████████████| 776.8MB 24kB/s \n", "\u001b[?25hCollecting torchvision==0.8.2\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/94/df/969e69a94cff1c8911acb0688117f95e1915becc1e01c73e7960a2c76ec8/torchvision-0.8.2-cp37-cp37m-manylinux1_x86_64.whl (12.8MB)\n", "\u001b[K |████████████████████████████████| 12.8MB 264kB/s \n", "\u001b[?25hCollecting torchaudio==0.7.2\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/37/16/ecdb9eb09ec6b8133d6c9536ea9e49cd13c9b5873c8488b8b765a39028da/torchaudio-0.7.2-cp37-cp37m-manylinux1_x86_64.whl (7.6MB)\n", "\u001b[K |████████████████████████████████| 7.6MB 18.2MB/s \n", "\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from torch==1.7.1) (1.19.5)\n", "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch==1.7.1) (3.7.4.3)\n", "Requirement already satisfied: pillow>=4.1.1 in /usr/local/lib/python3.7/dist-packages (from torchvision==0.8.2) (7.1.2)\n", "\u001b[31mERROR: torchtext 0.9.1 has requirement torch==1.8.1, but you'll have torch 1.7.1 which==incompatible.\u001b[0m\n", "Installing collected packages: torch, torchvision, torchaudio\n", " Found existing installation: torch 1.8.1+cu101\n", " Uninstalling torch-1.8.1+cu101:\n", " Successfully uninstalled torch-1.8.1+cu101\n", " Found existing installation: torchvision 0.9.1+cu101\n", " Uninstalling torchvision-0.9.1+cu101:\n", " Successfully uninstalled torchvision-0.9.1+cu101\n", "Successfully installed torch-1.7.1 torchaudio-0.7.2 torchvision-0.8.2\n", "Requirement already satisfied: pip in /usr/local/lib/python3.7/dist-packages (19.3.1)\n", "Requirement already satisfied: install in /usr/local/lib/python3.7/dist-packages (1.3.4)\n", "Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (4.1.2.30)\n", "Requirement already satisfied: numpy>=1.14.5 in /usr/local/lib/python3.7/dist-packages (from opencv-python) (1.19.5)\n" ] } ], "source": [ "!pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2\n", "!pip install pip install opencv-python" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "BlSfEFXgnAHu", "outputId": "6502bfec-2efd-4e36-fef6-4fc354132ea2" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/content/GPEN\n" ] } ], "source": [ "%cd GPEN" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "dt6hIEjyx7Nt", "outputId": "13de37fd-6dca-437f-c892-be89560a83d6" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2021-06-13 05:31:09-- https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip\n", "Resolving github.com (github.com)... 140.82.113.3\n", "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n", "HTTP request sent, awaiting response... 302 Found\n", "Location: https://github-releases.githubusercontent.com/1335132/d2f252e2-9801-11e7-9fbf-bc7b4e4b5c83?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210613T053109Z&X-Amz-Expires=300&X-Amz-Signature=0297051ab9ba7cd75b20f001e6392f931bd0fbde6cea59a28c6b3bb7fdb97b78&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=1335132&response-content-disposition=attachment%3B%20filename%3Dninja-linux.zip&response-content-type=application%2Foctet-stream [following]\n", "--2021-06-13 05:31:09-- https://github-releases.githubusercontent.com/1335132/d2f252e2-9801-11e7-9fbf-bc7b4e4b5c83?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210613T053109Z&X-Amz-Expires=300&X-Amz-Signature=0297051ab9ba7cd75b20f001e6392f931bd0fbde6cea59a28c6b3bb7fdb97b78&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=1335132&response-content-disposition=attachment%3B%20filename%3Dninja-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: 77854 (76K) [application/octet-stream]\n", "Saving to: ‘ninja-linux.zip’\n", "\n", "ninja-linux.zip 100%[===================>] 76.03K --.-KB/s in 0.002s \n", "\n", "2021-06-13 05:31:09 (32.1 MB/s) - ‘ninja-linux.zip’ saved [77854/77854]\n", "\n", "Archive: ninja-linux.zip\n", " inflating: /usr/local/bin/ninja \n", "update-alternatives: using /usr/local/bin/ninja to provide /usr/bin/ninja (ninja) in auto mode\n" ] } ], "source": [ "!wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip\n", "!sudo unzip ninja-linux.zip -d /usr/local/bin/\n", "!sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force" ] }, { "cell_type": "markdown", "metadata": { "id": "MHS0GTSK1hnf" }, "source": [ "# Main Code\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "NOo9qIPb1Ivn", "outputId": "268e81d3-bb69-42c0-a5ca-704cce5b37a8" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 Solvay_conference_1927.png\n" ] } ], "source": [ "!python face_enhancement.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "XeAs7bPg1KpZ", "outputId": "a9e0b3de-d00b-4329-b079-2ed52a22f58a" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 examples/grays/106000_gray.png\n" ] } ], "source": [ "!python face_colorization.py" ] }, { "cell_type": "markdown", "metadata": { "id": "WDCm7xJee4c2" }, "source": [ "# Download multiple images all at once" ] }, { "cell_type": "markdown", "metadata": { "id": "6zC7BIgHe-Z2" }, "source": [ "download on outs" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "4tAqGLPpe0Ez" }, "outputs": [], "source": [ "!zip -r /content/GPEN/examples/outs.zip /content/GPEN/examples/outs" ] }, { "cell_type": "markdown", "metadata": { "id": "0W7jMJlqfD2R" }, "source": [ "download on couts" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "B3-JMXM3e0wT" }, "outputs": [], "source": [ "!zip -r /content/GPEN/examples/couts.zip /content/GPEN/examples/couts" ] } ], "metadata": { "accelerator": "GPU", "colab": { "name": "GPEN.ipynb", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }