diff --git a/deepsvg/config.py b/deepsvg/config.py index c3cb185ef9..5ea63f5b49 100644 --- a/deepsvg/config.py +++ b/deepsvg/config.py @@ -12,8 +12,8 @@ def __init__(self, num_gpus=1): self.dataloader_module = "deepsvg.svgtensor_dataset" # self.collate_fn = None # - self.data_dir = "./dataset/icons_tensor/" # - self.meta_filepath = "./dataset/icons_meta.csv" # + self.data_dir = "deepsvg/dataset/icons_tensor/" # + self.meta_filepath = "deepsvg/dataset/icons_meta.csv" # self.loader_num_workers = 0 # self.pretrained_path = None # diff --git a/deepsvg/svglib/utils.py b/deepsvg/svglib/utils.py index ef2318ee81..c68ca8a95e 100644 --- a/deepsvg/svglib/utils.py +++ b/deepsvg/svglib/utils.py @@ -83,7 +83,7 @@ def to_gif(img_list, file_path=None, frame_duration=0.1, do_display=True): clip = concatenate_videoclips(clips, method="compose", bg_color=(255, 255, 255)) if file_path is not None: - clip.write_gif(file_path, fps=24, verbose=False, logger=None) + clip.write_gif(file_path, fps=24, verbose=False)#, logger=None) if do_display: src = clip if file_path is None else file_path diff --git a/notebooks/animation_colab.ipynb b/notebooks/animation_colab.ipynb new file mode 100644 index 0000000000..2e15a731e7 --- /dev/null +++ b/notebooks/animation_colab.ipynb @@ -0,0 +1,1761 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Animation Colab.ipynb", + "provenance": [], + "collapsed_sections": [], + "authorship_tag": "ABX9TyNKnurfoH2oESlMEEk+mB77", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "source": [ + "################################################################################\n", + "# INSTALL CONDA ON GOOGLE COLAB\n", + "################################################################################\n", + "! wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh\n", + "! chmod +x Miniconda3-py37_4.8.2-Linux-x86_64.sh\n", + "! bash ./Miniconda3-py37_4.8.2-Linux-x86_64.sh -b -f -p /usr/local\n", + "import sys\n", + "sys.path.append('/usr/local/lib/python3.7/site-packages/')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "V92E_1nJSeM7", + "outputId": "e77919a4-aa61-4cfc-ae2d-7bd2ed650ec1" + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "--2022-05-02 08:05:00-- https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh\n", + "Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8303, ...\n", + "Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.\n", + "HTTP request sent, awaiting response... 200 OK\n", + "Length: 85055499 (81M) [application/x-sh]\n", + "Saving to: ‘Miniconda3-py37_4.8.2-Linux-x86_64.sh’\n", + "\n", + "Miniconda3-py37_4.8 100%[===================>] 81.12M 124MB/s in 0.7s \n", + "\n", + "2022-05-02 08:05:00 (124 MB/s) - ‘Miniconda3-py37_4.8.2-Linux-x86_64.sh’ saved [85055499/85055499]\n", + "\n", + "PREFIX=/usr/local\n", + "Unpacking payload ...\n", + "Collecting package metadata (current_repodata.json): - \b\b\\ \b\b| \b\bdone\n", + "Solving environment: - \b\b\\ \b\bdone\n", + "\n", + "## Package Plan ##\n", + "\n", + " environment location: /usr/local\n", + "\n", + " added / updated specs:\n", + " - _libgcc_mutex==0.1=main\n", + " - asn1crypto==1.3.0=py37_0\n", + " - ca-certificates==2020.1.1=0\n", + " - certifi==2019.11.28=py37_0\n", + " - cffi==1.14.0=py37h2e261b9_0\n", + " - chardet==3.0.4=py37_1003\n", + " - conda-package-handling==1.6.0=py37h7b6447c_0\n", + " - conda==4.8.2=py37_0\n", + " - cryptography==2.8=py37h1ba5d50_0\n", + " - idna==2.8=py37_0\n", + " - ld_impl_linux-64==2.33.1=h53a641e_7\n", + " - libedit==3.1.20181209=hc058e9b_0\n", + " - libffi==3.2.1=hd88cf55_4\n", + " - libgcc-ng==9.1.0=hdf63c60_0\n", + " - libstdcxx-ng==9.1.0=hdf63c60_0\n", + " - ncurses==6.2=he6710b0_0\n", + " - openssl==1.1.1d=h7b6447c_4\n", + " - pip==20.0.2=py37_1\n", + " - pycosat==0.6.3=py37h7b6447c_0\n", + " - pycparser==2.19=py37_0\n", + " - pyopenssl==19.1.0=py37_0\n", + " - pysocks==1.7.1=py37_0\n", + " - python==3.7.6=h0371630_2\n", + " - readline==7.0=h7b6447c_5\n", + " - requests==2.22.0=py37_1\n", + " - ruamel_yaml==0.15.87=py37h7b6447c_0\n", + " - setuptools==45.2.0=py37_0\n", + " - six==1.14.0=py37_0\n", + " - sqlite==3.31.1=h7b6447c_0\n", + " - tk==8.6.8=hbc83047_0\n", + " - tqdm==4.42.1=py_0\n", + " - urllib3==1.25.8=py37_0\n", + " - wheel==0.34.2=py37_0\n", + " - xz==5.2.4=h14c3975_4\n", + " - yaml==0.1.7=had09818_2\n", + " - zlib==1.2.11=h7b6447c_3\n", + "\n", + "\n", + "The following NEW packages will be INSTALLED:\n", + "\n", + " _libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main\n", + " asn1crypto pkgs/main/linux-64::asn1crypto-1.3.0-py37_0\n", + " ca-certificates pkgs/main/linux-64::ca-certificates-2020.1.1-0\n", + " certifi pkgs/main/linux-64::certifi-2019.11.28-py37_0\n", + " cffi pkgs/main/linux-64::cffi-1.14.0-py37h2e261b9_0\n", + " chardet pkgs/main/linux-64::chardet-3.0.4-py37_1003\n", + " conda pkgs/main/linux-64::conda-4.8.2-py37_0\n", + " conda-package-han~ pkgs/main/linux-64::conda-package-handling-1.6.0-py37h7b6447c_0\n", + " cryptography pkgs/main/linux-64::cryptography-2.8-py37h1ba5d50_0\n", + " idna pkgs/main/linux-64::idna-2.8-py37_0\n", + " ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7\n", + " libedit pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0\n", + " libffi pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4\n", + " libgcc-ng pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0\n", + " libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0\n", + " ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_0\n", + " openssl pkgs/main/linux-64::openssl-1.1.1d-h7b6447c_4\n", + " pip pkgs/main/linux-64::pip-20.0.2-py37_1\n", + " pycosat pkgs/main/linux-64::pycosat-0.6.3-py37h7b6447c_0\n", + " pycparser pkgs/main/linux-64::pycparser-2.19-py37_0\n", + " pyopenssl pkgs/main/linux-64::pyopenssl-19.1.0-py37_0\n", + " pysocks pkgs/main/linux-64::pysocks-1.7.1-py37_0\n", + " python pkgs/main/linux-64::python-3.7.6-h0371630_2\n", + " readline pkgs/main/linux-64::readline-7.0-h7b6447c_5\n", + " requests pkgs/main/linux-64::requests-2.22.0-py37_1\n", + " ruamel_yaml pkgs/main/linux-64::ruamel_yaml-0.15.87-py37h7b6447c_0\n", + " setuptools pkgs/main/linux-64::setuptools-45.2.0-py37_0\n", + " six pkgs/main/linux-64::six-1.14.0-py37_0\n", + " sqlite pkgs/main/linux-64::sqlite-3.31.1-h7b6447c_0\n", + " tk pkgs/main/linux-64::tk-8.6.8-hbc83047_0\n", + " tqdm pkgs/main/noarch::tqdm-4.42.1-py_0\n", + " urllib3 pkgs/main/linux-64::urllib3-1.25.8-py37_0\n", + " wheel pkgs/main/linux-64::wheel-0.34.2-py37_0\n", + " xz pkgs/main/linux-64::xz-5.2.4-h14c3975_4\n", + " yaml pkgs/main/linux-64::yaml-0.1.7-had09818_2\n", + " zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3\n", + "\n", + "\n", + "Preparing transaction: / \b\b- \b\b\\ \b\b| \b\bdone\n", + "Executing transaction: - \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\bdone\n", + "installation finished.\n", + "WARNING:\n", + " You currently have a PYTHONPATH environment variable set. This may cause\n", + " unexpected behavior when running the Python interpreter in Miniconda3.\n", + " For best results, please verify that your PYTHONPATH only points to\n", + " directories of packages that are compatible with the Python interpreter\n", + " in Miniconda3: /usr/local\n" + ] + } + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "4dNI3X-NSF_b", + "outputId": "1b11c060-5267-468a-aa4d-6e12780cf4a3" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Cloning into 'deepsvg'...\n", + "remote: Enumerating objects: 307, done.\u001b[K\n", + "remote: Total 307 (delta 0), reused 0 (delta 0), pack-reused 307\u001b[K\n", + "Receiving objects: 100% (307/307), 11.27 MiB | 21.46 MiB/s, done.\n", + "Resolving deltas: 100% (73/73), done.\n" + ] + } + ], + "source": [ + "!git clone https://github.com/alexandre01/deepsvg.git\n", + "!cd deepsvg" + ] + }, + { + "cell_type": "code", + "source": [ + "!conda create -n deepsvg python=3.7 --y" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "L9bf4-oMSO8-", + "outputId": "0b1d97bf-a444-435c-aee2-90e65f6c92a7" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting package metadata (current_repodata.json): - \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\bdone\n", + "Solving environment: - \b\bdone\n", + "\n", + "\n", + "==> WARNING: A newer version of conda exists. <==\n", + " current version: 4.8.2\n", + " latest version: 4.12.0\n", + "\n", + "Please update conda by running\n", + "\n", + " $ conda update -n base -c defaults conda\n", + "\n", + "\n", + "\n", + "## Package Plan ##\n", + "\n", + " environment location: /usr/local/envs/deepsvg\n", + "\n", + " added / updated specs:\n", + " - python=3.7\n", + "\n", + "\n", + "The following packages will be downloaded:\n", + "\n", + " package | build\n", + " ---------------------------|-----------------\n", + " _openmp_mutex-4.5 | 1_gnu 22 KB\n", + " ca-certificates-2022.3.29 | h06a4308_1 122 KB\n", + " certifi-2021.10.8 | py37h06a4308_2 151 KB\n", + " ld_impl_linux-64-2.35.1 | h7274673_9 586 KB\n", + " libffi-3.3 | he6710b0_2 50 KB\n", + " libgcc-ng-9.3.0 | h5101ec6_17 4.8 MB\n", + " libgomp-9.3.0 | h5101ec6_17 311 KB\n", + " libstdcxx-ng-9.3.0 | hd4cf53a_17 3.1 MB\n", + " ncurses-6.3 | h7f8727e_2 782 KB\n", + " openssl-1.1.1n | h7f8727e_0 2.5 MB\n", + " pip-21.2.2 | py37h06a4308_0 1.8 MB\n", + " python-3.7.13 | h12debd9_0 46.2 MB\n", + " readline-8.1.2 | h7f8727e_1 354 KB\n", + " setuptools-61.2.0 | py37h06a4308_0 1007 KB\n", + " sqlite-3.38.2 | hc218d9a_0 1.0 MB\n", + " tk-8.6.11 | h1ccaba5_0 3.0 MB\n", + " wheel-0.37.1 | pyhd3eb1b0_0 33 KB\n", + " xz-5.2.5 | h7b6447c_0 341 KB\n", + " zlib-1.2.12 | h7f8727e_2 106 KB\n", + " ------------------------------------------------------------\n", + " Total: 66.2 MB\n", + "\n", + "The following NEW packages will be INSTALLED:\n", + "\n", + " _libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main\n", + " _openmp_mutex pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu\n", + " ca-certificates pkgs/main/linux-64::ca-certificates-2022.3.29-h06a4308_1\n", + " certifi pkgs/main/linux-64::certifi-2021.10.8-py37h06a4308_2\n", + " ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9\n", + " libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2\n", + " libgcc-ng pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17\n", + " libgomp pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17\n", + " libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17\n", + " ncurses pkgs/main/linux-64::ncurses-6.3-h7f8727e_2\n", + " openssl pkgs/main/linux-64::openssl-1.1.1n-h7f8727e_0\n", + " pip pkgs/main/linux-64::pip-21.2.2-py37h06a4308_0\n", + " python pkgs/main/linux-64::python-3.7.13-h12debd9_0\n", + " readline pkgs/main/linux-64::readline-8.1.2-h7f8727e_1\n", + " setuptools pkgs/main/linux-64::setuptools-61.2.0-py37h06a4308_0\n", + " sqlite pkgs/main/linux-64::sqlite-3.38.2-hc218d9a_0\n", + " tk pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0\n", + " wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0\n", + " xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0\n", + " zlib pkgs/main/linux-64::zlib-1.2.12-h7f8727e_2\n", + "\n", + "\n", + "\n", + "Downloading and Extracting Packages\n", + "_openmp_mutex-4.5 | 22 KB | : 100% 1.0/1 [00:00<00:00, 14.17it/s]\n", + "openssl-1.1.1n | 2.5 MB | : 100% 1.0/1 [00:00<00:00, 5.97it/s]\n", + "libstdcxx-ng-9.3.0 | 3.1 MB | : 100% 1.0/1 [00:00<00:00, 6.54it/s]\n", + "ld_impl_linux-64-2.3 | 586 KB | : 100% 1.0/1 [00:00<00:00, 16.40it/s]\n", + "python-3.7.13 | 46.2 MB | : 100% 1.0/1 [00:01<00:00, 1.39s/it] \n", + "libgomp-9.3.0 | 311 KB | : 100% 1.0/1 [00:00<00:00, 16.87it/s]\n", + "wheel-0.37.1 | 33 KB | : 100% 1.0/1 [00:00<00:00, 20.64it/s]\n", + "setuptools-61.2.0 | 1007 KB | : 100% 1.0/1 [00:00<00:00, 1.97it/s]\n", + "certifi-2021.10.8 | 151 KB | : 100% 1.0/1 [00:00<00:00, 19.08it/s]\n", + "readline-8.1.2 | 354 KB | : 100% 1.0/1 [00:00<00:00, 15.46it/s]\n", + "xz-5.2.5 | 341 KB | : 100% 1.0/1 [00:00<00:00, 13.87it/s]\n", + "ca-certificates-2022 | 122 KB | : 100% 1.0/1 [00:00<00:00, 17.87it/s]\n", + "ncurses-6.3 | 782 KB | : 100% 1.0/1 [00:00<00:00, 3.75it/s]\n", + "libgcc-ng-9.3.0 | 4.8 MB | : 100% 1.0/1 [00:00<00:00, 4.56it/s]\n", + "pip-21.2.2 | 1.8 MB | : 100% 1.0/1 [00:00<00:00, 5.08it/s]\n", + "libffi-3.3 | 50 KB | : 100% 1.0/1 [00:00<00:00, 19.62it/s]\n", + "sqlite-3.38.2 | 1.0 MB | : 100% 1.0/1 [00:00<00:00, 10.79it/s]\n", + "tk-8.6.11 | 3.0 MB | : 100% 1.0/1 [00:00<00:00, 5.31it/s]\n", + "zlib-1.2.12 | 106 KB | : 100% 1.0/1 [00:00<00:00, 20.19it/s]\n", + "Preparing transaction: | \b\b/ \b\b- \b\bdone\n", + "Verifying transaction: | \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\bdone\n", + "Executing transaction: - \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\bdone\n", + "#\n", + "# To activate this environment, use\n", + "#\n", + "# $ conda activate deepsvg\n", + "#\n", + "# To deactivate an active environment, use\n", + "#\n", + "# $ conda deactivate\n", + "\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%%bash\n", + "source activate deepsvg" + ], + "metadata": { + "id": "Y4kIDcZXSqhg" + }, + "execution_count": 4, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "!sudo apt-get install libcairo2-dev" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "o70tq0RXSy8v", + "outputId": "fb517339-e3cb-4a7a-b7af-f2ef3582128d" + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Reading package lists... Done\n", + "Building dependency tree \n", + "Reading state information... Done\n", + "The following packages were automatically installed and are no longer required:\n", + " libnvidia-common-460 nsight-compute-2020.2.0\n", + "Use 'sudo apt autoremove' to remove them.\n", + "The following additional packages will be installed:\n", + " libcairo-script-interpreter2 libpixman-1-dev libxcb-shm0-dev\n", + "Suggested packages:\n", + " libcairo2-doc\n", + "The following NEW packages will be installed:\n", + " libcairo-script-interpreter2 libcairo2-dev libpixman-1-dev libxcb-shm0-dev\n", + "0 upgraded, 4 newly installed, 0 to remove and 42 not upgraded.\n", + "Need to get 930 kB of archives.\n", + "After this operation, 3,986 kB of additional disk space will be used.\n", + "Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcairo-script-interpreter2 amd64 1.15.10-2ubuntu0.1 [53.5 kB]\n", + "Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpixman-1-dev amd64 0.34.0-2 [244 kB]\n", + "Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libxcb-shm0-dev amd64 1.13-2~ubuntu18.04 [6,684 B]\n", + "Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcairo2-dev amd64 1.15.10-2ubuntu0.1 [626 kB]\n", + "Fetched 930 kB in 1s (1,027 kB/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 4.)\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 libcairo-script-interpreter2:amd64.\n", + "(Reading database ... 155202 files and directories currently installed.)\n", + "Preparing to unpack .../libcairo-script-interpreter2_1.15.10-2ubuntu0.1_amd64.deb ...\n", + "Unpacking libcairo-script-interpreter2:amd64 (1.15.10-2ubuntu0.1) ...\n", + "Selecting previously unselected package libpixman-1-dev:amd64.\n", + "Preparing to unpack .../libpixman-1-dev_0.34.0-2_amd64.deb ...\n", + "Unpacking libpixman-1-dev:amd64 (0.34.0-2) ...\n", + "Selecting previously unselected package libxcb-shm0-dev:amd64.\n", + "Preparing to unpack .../libxcb-shm0-dev_1.13-2~ubuntu18.04_amd64.deb ...\n", + "Unpacking libxcb-shm0-dev:amd64 (1.13-2~ubuntu18.04) ...\n", + "Selecting previously unselected package libcairo2-dev:amd64.\n", + "Preparing to unpack .../libcairo2-dev_1.15.10-2ubuntu0.1_amd64.deb ...\n", + "Unpacking libcairo2-dev:amd64 (1.15.10-2ubuntu0.1) ...\n", + "Setting up libcairo-script-interpreter2:amd64 (1.15.10-2ubuntu0.1) ...\n", + "Setting up libxcb-shm0-dev:amd64 (1.13-2~ubuntu18.04) ...\n", + "Setting up libpixman-1-dev:amd64 (0.34.0-2) ...\n", + "Setting up libcairo2-dev:amd64 (1.15.10-2ubuntu0.1) ...\n", + "Processing triggers for libc-bin (2.27-3ubuntu1.3) ...\n", + "/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link\n", + "\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "cd deepsvg/" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "zAzoJLmQXeLo", + "outputId": "88fa7698-5b49-4c83-bbcb-2eee083fa5ae" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/deepsvg\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%%bash\n", + "\n", + "cd dataset/\n", + "bash download.sh\n", + "cd ..\n", + "\n", + "cd pretrained/\n", + "bash download.sh\n", + "cd ..\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "E9BQTtHRWgL5", + "outputId": "8482c460-1eb9-4358-fcc3-acce47dee110" + }, + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "IOPub data rate exceeded.\n", + "The notebook server will temporarily stop sending output\n", + "to the client in order to avoid crashing it.\n", + "To change this limit, set the config variable\n", + "`--NotebookApp.iopub_data_rate_limit`.\n", + "\n", + "Current values:\n", + "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", + "NotebookApp.rate_limit_window=3.0 (secs)\n", + "\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install -r requirements.txt" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "id": "AFI_4LgHWA1y", + "outputId": "a835cce9-3e41-44bb-fcd1-5fe62e8fbb65" + }, + "execution_count": 8, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting torch==1.4.0\n", + " Downloading torch-1.4.0-cp37-cp37m-manylinux1_x86_64.whl (753.4 MB)\n", + "\u001b[K |████████████████████████████████| 753.4 MB 6.7 kB/s \n", + "\u001b[?25hCollecting torchvision==0.5.0\n", + " Downloading torchvision-0.5.0-cp37-cp37m-manylinux1_x86_64.whl (4.0 MB)\n", + "\u001b[K |████████████████████████████████| 4.0 MB 30.6 MB/s \n", + "\u001b[?25hCollecting numpy==1.16.1\n", + " Downloading numpy-1.16.1-cp37-cp37m-manylinux1_x86_64.whl (17.3 MB)\n", + "\u001b[K |████████████████████████████████| 17.3 MB 1.3 MB/s \n", + "\u001b[?25hCollecting matplotlib\n", + " Downloading matplotlib-3.5.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)\n", + "\u001b[K |████████████████████████████████| 11.2 MB 127 kB/s \n", + "\u001b[?25hCollecting svgwrite\n", + " Downloading svgwrite-1.4.2-py3-none-any.whl (67 kB)\n", + "\u001b[K |████████████████████████████████| 67 kB 4.8 MB/s \n", + "\u001b[?25hCollecting cairosvg\n", + " Downloading CairoSVG-2.5.2-py3-none-any.whl (45 kB)\n", + "\u001b[K |████████████████████████████████| 45 kB 3.2 MB/s \n", + "\u001b[?25hCollecting IPython\n", + " Downloading ipython-7.33.0-py3-none-any.whl (793 kB)\n", + "\u001b[K |████████████████████████████████| 793 kB 44.3 MB/s \n", + "\u001b[?25hRequirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (1.14.0)\n", + "Collecting tensorflow\n", + " Downloading tensorflow-2.8.0-cp37-cp37m-manylinux2010_x86_64.whl (497.5 MB)\n", + "\u001b[K |████████████████████████████████| 497.5 MB 27 kB/s \n", + "\u001b[?25hCollecting tensorboardX\n", + " Downloading tensorboardX-2.5-py2.py3-none-any.whl (125 kB)\n", + "\u001b[K |████████████████████████████████| 125 kB 45.7 MB/s \n", + "\u001b[?25hCollecting pillow\n", + " Downloading Pillow-9.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)\n", + "\u001b[K |████████████████████████████████| 4.3 MB 39.6 MB/s \n", + "\u001b[?25hCollecting svglib\n", + " Downloading svglib-1.2.1.tar.gz (896 kB)\n", + "\u001b[K |████████████████████████████████| 896 kB 46.7 MB/s \n", + "\u001b[?25hRequirement already satisfied: tqdm in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 13)) (4.42.1)\n", + "Collecting jupyter\n", + " Downloading jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)\n", + "Collecting scikit-image\n", + " Downloading scikit_image-0.19.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.5 MB)\n", + "\u001b[K |████████████████████████████████| 13.5 MB 30.7 MB/s \n", + "\u001b[?25hCollecting pandas\n", + " Downloading pandas-1.3.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.3 MB)\n", + "\u001b[K |████████████████████████████████| 11.3 MB 30.7 MB/s \n", + "\u001b[?25hCollecting networkx\n", + " Downloading networkx-2.6.3-py3-none-any.whl (1.9 MB)\n", + "\u001b[K |████████████████████████████████| 1.9 MB 30.6 MB/s \n", + "\u001b[?25hCollecting moviepy\n", + " Downloading moviepy-1.0.3.tar.gz (388 kB)\n", + "\u001b[K |████████████████████████████████| 388 kB 47.3 MB/s \n", + "\u001b[?25hCollecting numba\n", + " Downloading numba-0.55.1-1-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.3 MB)\n", + "\u001b[K |████████████████████████████████| 3.3 MB 27.3 MB/s \n", + "\u001b[?25hCollecting sklearn\n", + " Downloading sklearn-0.0.tar.gz (1.1 kB)\n", + "Collecting umap-learn\n", + " Downloading umap-learn-0.5.3.tar.gz (88 kB)\n", + "\u001b[K |████████████████████████████████| 88 kB 7.0 MB/s \n", + "\u001b[?25hCollecting shapely\n", + " Downloading Shapely-1.8.1.post1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.0 MB)\n", + "\u001b[K |████████████████████████████████| 2.0 MB 33.1 MB/s \n", + "\u001b[?25hCollecting kivy\n", + " Downloading Kivy-2.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.5 MB)\n", + "\u001b[K |████████████████████████████████| 29.5 MB 1.6 MB/s \n", + "\u001b[?25hCollecting python-dateutil>=2.7\n", + " Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n", + "\u001b[K |████████████████████████████████| 247 kB 44.4 MB/s \n", + "\u001b[?25hCollecting cycler>=0.10\n", + " Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)\n", + "Collecting packaging>=20.0\n", + " Downloading packaging-21.3-py3-none-any.whl (40 kB)\n", + "\u001b[K |████████████████████████████████| 40 kB 5.1 MB/s \n", + "\u001b[?25hCollecting kiwisolver>=1.0.1\n", + " Downloading kiwisolver-1.4.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB)\n", + "\u001b[K |████████████████████████████████| 1.1 MB 37.1 MB/s \n", + "\u001b[?25hCollecting fonttools>=4.22.0\n", + " Downloading fonttools-4.33.3-py3-none-any.whl (930 kB)\n", + "\u001b[K |████████████████████████████████| 930 kB 44.3 MB/s \n", + "\u001b[?25hCollecting pyparsing>=2.2.1\n", + " Downloading pyparsing-3.0.8-py3-none-any.whl (98 kB)\n", + "\u001b[K |████████████████████████████████| 98 kB 6.8 MB/s \n", + "\u001b[?25hCollecting tinycss2\n", + " Downloading tinycss2-1.1.1-py3-none-any.whl (21 kB)\n", + "Collecting cssselect2\n", + " Downloading cssselect2-0.6.0-py3-none-any.whl (15 kB)\n", + "Collecting cairocffi\n", + " Downloading cairocffi-1.3.0.tar.gz (88 kB)\n", + "\u001b[K |████████████████████████████████| 88 kB 7.9 MB/s \n", + "\u001b[?25hCollecting defusedxml\n", + " Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)\n", + "Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python3.7/site-packages (from IPython->-r requirements.txt (line 7)) (45.2.0.post20200210)\n", + "Collecting pexpect>4.3; sys_platform != \"win32\"\n", + " Downloading pexpect-4.8.0-py2.py3-none-any.whl (59 kB)\n", + "\u001b[K |████████████████████████████████| 59 kB 5.3 MB/s \n", + "\u001b[?25hCollecting pygments\n", + " Downloading Pygments-2.12.0-py3-none-any.whl (1.1 MB)\n", + "\u001b[K |████████████████████████████████| 1.1 MB 39.4 MB/s \n", + "\u001b[?25hCollecting pickleshare\n", + " Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)\n", + "Collecting matplotlib-inline\n", + " Downloading matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)\n", + "Collecting jedi>=0.16\n", + " Downloading jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)\n", + "\u001b[K |████████████████████████████████| 1.6 MB 32.3 MB/s \n", + "\u001b[?25hCollecting traitlets>=4.2\n", + " Downloading traitlets-5.1.1-py3-none-any.whl (102 kB)\n", + "\u001b[K |████████████████████████████████| 102 kB 10.2 MB/s \n", + "\u001b[?25hCollecting backcall\n", + " Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)\n", + "Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0\n", + " Downloading prompt_toolkit-3.0.29-py3-none-any.whl (381 kB)\n", + "\u001b[K |████████████████████████████████| 381 kB 43.3 MB/s \n", + "\u001b[?25hCollecting decorator\n", + " Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)\n", + "Collecting keras-preprocessing>=1.1.1\n", + " Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)\n", + "\u001b[K |████████████████████████████████| 42 kB 1.2 MB/s \n", + "\u001b[?25hCollecting grpcio<2.0,>=1.24.3\n", + " Downloading grpcio-1.44.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)\n", + "\u001b[K |████████████████████████████████| 4.3 MB 31.9 MB/s \n", + "\u001b[?25hCollecting h5py>=2.9.0\n", + " Downloading h5py-3.6.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (4.1 MB)\n", + "\u001b[K |████████████████████████████████| 4.1 MB 31.6 MB/s \n", + "\u001b[?25hCollecting tensorboard<2.9,>=2.8\n", + " Downloading tensorboard-2.8.0-py3-none-any.whl (5.8 MB)\n", + "\u001b[K |████████████████████████████████| 5.8 MB 32.8 MB/s \n", + "\u001b[?25hCollecting protobuf>=3.9.2\n", + " Downloading protobuf-3.20.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB)\n", + "\u001b[K |████████████████████████████████| 1.0 MB 40.7 MB/s \n", + "\u001b[?25hCollecting astunparse>=1.6.0\n", + " Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)\n", + "Collecting termcolor>=1.1.0\n", + " Downloading termcolor-1.1.0.tar.gz (3.9 kB)\n", + "Collecting google-pasta>=0.1.1\n", + " Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)\n", + "\u001b[K |████████████████████████████████| 57 kB 4.4 MB/s \n", + "\u001b[?25hCollecting flatbuffers>=1.12\n", + " Downloading flatbuffers-2.0-py2.py3-none-any.whl (26 kB)\n", + "Collecting wrapt>=1.11.0\n", + " Downloading wrapt-1.14.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (75 kB)\n", + "\u001b[K |████████████████████████████████| 75 kB 3.5 MB/s \n", + "\u001b[?25hCollecting typing-extensions>=3.6.6\n", + " Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)\n", + "Collecting keras<2.9,>=2.8.0rc0\n", + " Downloading keras-2.8.0-py2.py3-none-any.whl (1.4 MB)\n", + "\u001b[K |████████████████████████████████| 1.4 MB 38.5 MB/s \n", + "\u001b[?25hCollecting tensorflow-io-gcs-filesystem>=0.23.1\n", + " Downloading tensorflow_io_gcs_filesystem-0.25.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.1 MB)\n", + "\u001b[K |████████████████████████████████| 2.1 MB 31.9 MB/s \n", + "\u001b[?25hCollecting gast>=0.2.1\n", + " Downloading gast-0.5.3-py3-none-any.whl (19 kB)\n", + "Collecting tf-estimator-nightly==2.8.0.dev2021122109\n", + " Downloading tf_estimator_nightly-2.8.0.dev2021122109-py2.py3-none-any.whl (462 kB)\n", + "\u001b[K |████████████████████████████████| 462 kB 44.8 MB/s \n", + "\u001b[?25hCollecting absl-py>=0.4.0\n", + " Downloading absl_py-1.0.0-py3-none-any.whl (126 kB)\n", + "\u001b[K |████████████████████████████████| 126 kB 43.2 MB/s \n", + "\u001b[?25hCollecting libclang>=9.0.1\n", + " Downloading libclang-14.0.1-py2.py3-none-manylinux1_x86_64.whl (14.5 MB)\n", + "\u001b[K |████████████████████████████████| 14.5 MB 34.2 MB/s \n", + "\u001b[?25hCollecting opt-einsum>=2.3.2\n", + " Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)\n", + "\u001b[K |████████████████████████████████| 65 kB 3.6 MB/s \n", + "\u001b[?25hCollecting reportlab\n", + " Downloading reportlab-3.6.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB)\n", + "\u001b[K |████████████████████████████████| 2.7 MB 30.5 MB/s \n", + "\u001b[?25hCollecting lxml\n", + " Downloading lxml-4.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.4 MB)\n", + "\u001b[K |████████████████████████████████| 6.4 MB 32.7 MB/s \n", + "\u001b[?25hCollecting ipywidgets\n", + " Downloading ipywidgets-7.7.0-py2.py3-none-any.whl (123 kB)\n", + "\u001b[K |████████████████████████████████| 123 kB 46.7 MB/s \n", + "\u001b[?25hCollecting jupyter-console\n", + " Downloading jupyter_console-6.4.3-py3-none-any.whl (22 kB)\n", + "Collecting nbconvert\n", + " Downloading nbconvert-6.5.0-py3-none-any.whl (561 kB)\n", + "\u001b[K |████████████████████████████████| 561 kB 44.6 MB/s \n", + "\u001b[?25hCollecting notebook\n", + " Downloading notebook-6.4.11-py3-none-any.whl (9.9 MB)\n", + "\u001b[K |████████████████████████████████| 9.9 MB 30.2 MB/s \n", + "\u001b[?25hCollecting qtconsole\n", + " Downloading qtconsole-5.3.0-py3-none-any.whl (120 kB)\n", + "\u001b[K |████████████████████████████████| 120 kB 47.3 MB/s \n", + "\u001b[?25hCollecting ipykernel\n", + " Downloading ipykernel-6.13.0-py3-none-any.whl (131 kB)\n", + "\u001b[K |████████████████████████████████| 131 kB 47.2 MB/s \n", + "\u001b[?25hCollecting PyWavelets>=1.1.1\n", + " Downloading PyWavelets-1.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.4 MB)\n", + "\u001b[K |████████████████████████████████| 6.4 MB 31.0 MB/s \n", + "\u001b[?25hCollecting imageio>=2.4.1\n", + " Downloading imageio-2.19.0-py3-none-any.whl (3.4 MB)\n", + "\u001b[K |████████████████████████████████| 3.4 MB 30.6 MB/s \n", + "\u001b[?25hCollecting scipy>=1.4.1\n", + " Downloading scipy-1.7.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (38.1 MB)\n", + "\u001b[K |████████████████████████████████| 38.1 MB 1.2 MB/s \n", + "\u001b[?25hCollecting tifffile>=2019.7.26\n", + " Downloading tifffile-2021.11.2-py3-none-any.whl (178 kB)\n", + "\u001b[K |████████████████████████████████| 178 kB 45.3 MB/s \n", + "\u001b[?25hCollecting pytz>=2017.3\n", + " Downloading pytz-2022.1-py2.py3-none-any.whl (503 kB)\n", + "\u001b[K |████████████████████████████████| 503 kB 46.5 MB/s \n", + "\u001b[?25hRequirement already satisfied: requests<3.0,>=2.8.1 in /usr/local/lib/python3.7/site-packages (from moviepy->-r requirements.txt (line 18)) (2.22.0)\n", + "Collecting proglog<=1.0.0\n", + " Downloading proglog-0.1.9.tar.gz (10 kB)\n", + "Collecting imageio_ffmpeg>=0.2.0\n", + " Downloading imageio_ffmpeg-0.4.7-py3-none-manylinux2010_x86_64.whl (26.9 MB)\n", + "\u001b[K |████████████████████████████████| 26.9 MB 59.0 MB/s \n", + "\u001b[?25hCollecting llvmlite<0.39,>=0.38.0rc1\n", + " Downloading llvmlite-0.38.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.5 MB)\n", + "\u001b[K |████████████████████████████████| 34.5 MB 11 kB/s \n", + "\u001b[?25hCollecting scikit-learn\n", + " Downloading scikit_learn-1.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.8 MB)\n", + "\u001b[K |████████████████████████████████| 24.8 MB 12.2 MB/s \n", + "\u001b[?25hCollecting pynndescent>=0.5\n", + " Downloading pynndescent-0.5.6.tar.gz (1.1 MB)\n", + "\u001b[K |████████████████████████████████| 1.1 MB 39.6 MB/s \n", + "\u001b[?25hCollecting docutils\n", + " Downloading docutils-0.18.1-py2.py3-none-any.whl (570 kB)\n", + "\u001b[K |████████████████████████████████| 570 kB 42.7 MB/s \n", + "\u001b[?25hCollecting Kivy-Garden>=0.1.4\n", + " Downloading Kivy_Garden-0.1.5-py3-none-any.whl (4.6 kB)\n", + "Collecting webencodings>=0.4\n", + " Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)\n", + "Requirement already satisfied: cffi>=1.1.0 in /usr/local/lib/python3.7/site-packages (from cairocffi->cairosvg->-r requirements.txt (line 6)) (1.14.0)\n", + "Collecting ptyprocess>=0.5\n", + " Downloading ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)\n", + "Collecting parso<0.9.0,>=0.8.0\n", + " Downloading parso-0.8.3-py2.py3-none-any.whl (100 kB)\n", + "\u001b[K |████████████████████████████████| 100 kB 10.2 MB/s \n", + "\u001b[?25hCollecting wcwidth\n", + " Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)\n", + "Collecting cached-property; python_version < \"3.8\"\n", + " Downloading cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)\n", + "Collecting tensorboard-data-server<0.7.0,>=0.6.0\n", + " Downloading tensorboard_data_server-0.6.1-py3-none-manylinux2010_x86_64.whl (4.9 MB)\n", + "\u001b[K |████████████████████████████████| 4.9 MB 29.6 MB/s \n", + "\u001b[?25hCollecting werkzeug>=0.11.15\n", + " Downloading Werkzeug-2.1.2-py3-none-any.whl (224 kB)\n", + "\u001b[K |████████████████████████████████| 224 kB 43.5 MB/s \n", + "\u001b[?25hRequirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.7/site-packages (from tensorboard<2.9,>=2.8->tensorflow->-r requirements.txt (line 9)) (0.34.2)\n", + "Collecting google-auth-oauthlib<0.5,>=0.4.1\n", + " Downloading google_auth_oauthlib-0.4.6-py2.py3-none-any.whl (18 kB)\n", + "Collecting markdown>=2.6.8\n", + " Downloading Markdown-3.3.6-py3-none-any.whl (97 kB)\n", + "\u001b[K |████████████████████████████████| 97 kB 7.1 MB/s \n", + "\u001b[?25hCollecting google-auth<3,>=1.6.3\n", + " Downloading google_auth-2.6.6-py2.py3-none-any.whl (156 kB)\n", + "\u001b[K |████████████████████████████████| 156 kB 44.4 MB/s \n", + "\u001b[?25hCollecting tensorboard-plugin-wit>=1.6.0\n", + " Downloading tensorboard_plugin_wit-1.8.1-py3-none-any.whl (781 kB)\n", + "\u001b[K |████████████████████████████████| 781 kB 44.1 MB/s \n", + "\u001b[?25hCollecting jupyterlab-widgets>=1.0.0; python_version >= \"3.6\"\n", + " Downloading jupyterlab_widgets-1.1.0-py3-none-any.whl (245 kB)\n", + "\u001b[K |████████████████████████████████| 245 kB 44.1 MB/s \n", + "\u001b[?25hCollecting ipython-genutils~=0.2.0\n", + " Downloading ipython_genutils-0.2.0-py2.py3-none-any.whl (26 kB)\n", + "Collecting nbformat>=4.2.0\n", + " Downloading nbformat-5.3.0-py3-none-any.whl (73 kB)\n", + "\u001b[K |████████████████████████████████| 73 kB 1.7 MB/s \n", + "\u001b[?25hCollecting widgetsnbextension~=3.6.0\n", + " Downloading widgetsnbextension-3.6.0-py2.py3-none-any.whl (1.6 MB)\n", + "\u001b[K |████████████████████████████████| 1.6 MB 43.4 MB/s \n", + "\u001b[?25hCollecting jupyter-client>=7.0.0\n", + " Downloading jupyter_client-7.3.0-py3-none-any.whl (130 kB)\n", + "\u001b[K |████████████████████████████████| 130 kB 46.9 MB/s \n", + "\u001b[?25hCollecting bleach\n", + " Downloading bleach-5.0.0-py3-none-any.whl (160 kB)\n", + "\u001b[K |████████████████████████████████| 160 kB 48.0 MB/s \n", + "\u001b[?25hCollecting jinja2>=3.0\n", + " Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)\n", + "\u001b[K |████████████████████████████████| 133 kB 45.6 MB/s \n", + "\u001b[?25hCollecting jupyter-core>=4.7\n", + " Downloading jupyter_core-4.10.0-py3-none-any.whl (87 kB)\n", + "\u001b[K |████████████████████████████████| 87 kB 6.5 MB/s \n", + "\u001b[?25hCollecting jupyterlab-pygments\n", + " Downloading jupyterlab_pygments-0.2.2-py2.py3-none-any.whl (21 kB)\n", + "Collecting entrypoints>=0.2.2\n", + " Downloading entrypoints-0.4-py3-none-any.whl (5.3 kB)\n", + "Collecting nbclient>=0.5.0\n", + " Downloading nbclient-0.6.0-py3-none-any.whl (70 kB)\n", + "\u001b[K |████████████████████████████████| 70 kB 7.1 MB/s \n", + "\u001b[?25hCollecting MarkupSafe>=2.0\n", + " Downloading MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)\n", + "Collecting pandocfilters>=1.4.1\n", + " Downloading pandocfilters-1.5.0-py2.py3-none-any.whl (8.7 kB)\n", + "Collecting mistune<2,>=0.8.1\n", + " Downloading mistune-0.8.4-py2.py3-none-any.whl (16 kB)\n", + "Collecting beautifulsoup4\n", + " Downloading beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)\n", + "\u001b[K |████████████████████████████████| 128 kB 45.7 MB/s \n", + "\u001b[?25hCollecting pyzmq>=17\n", + " Downloading pyzmq-22.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB)\n", + "\u001b[K |████████████████████████████████| 1.1 MB 40.5 MB/s \n", + "\u001b[?25hCollecting Send2Trash>=1.8.0\n", + " Downloading Send2Trash-1.8.0-py3-none-any.whl (18 kB)\n", + "Collecting tornado>=6.1\n", + " Downloading tornado-6.1-cp37-cp37m-manylinux2010_x86_64.whl (428 kB)\n", + "\u001b[K |████████████████████████████████| 428 kB 42.1 MB/s \n", + "\u001b[?25hCollecting prometheus-client\n", + " Downloading prometheus_client-0.14.1-py3-none-any.whl (59 kB)\n", + "\u001b[K |████████████████████████████████| 59 kB 5.6 MB/s \n", + "\u001b[?25hCollecting argon2-cffi\n", + " Downloading argon2_cffi-21.3.0-py3-none-any.whl (14 kB)\n", + "Collecting terminado>=0.8.3\n", + " Downloading terminado-0.13.3-py3-none-any.whl (14 kB)\n", + "Collecting nest-asyncio>=1.5\n", + " Downloading nest_asyncio-1.5.5-py3-none-any.whl (5.2 kB)\n", + "Collecting qtpy>=2.0.1\n", + " Downloading QtPy-2.0.1-py3-none-any.whl (65 kB)\n", + "\u001b[K |████████████████████████████████| 65 kB 4.1 MB/s \n", + "\u001b[?25hCollecting psutil\n", + " Downloading psutil-5.9.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)\n", + "\u001b[K |████████████████████████████████| 280 kB 44.8 MB/s \n", + "\u001b[?25hCollecting debugpy>=1.0\n", + " Downloading debugpy-1.6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.8 MB)\n", + "\u001b[K |████████████████████████████████| 1.8 MB 36.7 MB/s \n", + "\u001b[?25hRequirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests<3.0,>=2.8.1->moviepy->-r requirements.txt (line 18)) (2019.11.28)\n", + "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests<3.0,>=2.8.1->moviepy->-r requirements.txt (line 18)) (1.25.8)\n", + "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests<3.0,>=2.8.1->moviepy->-r requirements.txt (line 18)) (3.0.4)\n", + "Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests<3.0,>=2.8.1->moviepy->-r requirements.txt (line 18)) (2.8)\n", + "Collecting joblib>=0.11\n", + " Downloading joblib-1.1.0-py2.py3-none-any.whl (306 kB)\n", + "\u001b[K |████████████████████████████████| 306 kB 45.0 MB/s \n", + "\u001b[?25hCollecting threadpoolctl>=2.0.0\n", + " Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n", + "Requirement already satisfied: pycparser in /usr/local/lib/python3.7/site-packages (from cffi>=1.1.0->cairocffi->cairosvg->-r requirements.txt (line 6)) (2.19)\n", + "Collecting requests-oauthlib>=0.7.0\n", + " Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)\n", + "Collecting importlib-metadata>=4.4; python_version < \"3.10\"\n", + " Downloading importlib_metadata-4.11.3-py3-none-any.whl (18 kB)\n", + "Collecting cachetools<6.0,>=2.0.0\n", + " Downloading cachetools-5.0.0-py3-none-any.whl (9.1 kB)\n", + "Collecting pyasn1-modules>=0.2.1\n", + " Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)\n", + "\u001b[K |████████████████████████████████| 155 kB 43.3 MB/s \n", + "\u001b[?25hCollecting rsa<5,>=3.1.4; python_version >= \"3.6\"\n", + " Downloading rsa-4.8-py3-none-any.whl (39 kB)\n", + "Collecting fastjsonschema\n", + " Downloading fastjsonschema-2.15.3-py3-none-any.whl (22 kB)\n", + "Collecting jsonschema>=2.6\n", + " Downloading jsonschema-4.4.0-py3-none-any.whl (72 kB)\n", + "\u001b[K |████████████████████████████████| 72 kB 1.2 MB/s \n", + "\u001b[?25hCollecting soupsieve>1.2\n", + " Downloading soupsieve-2.3.2.post1-py3-none-any.whl (37 kB)\n", + "Collecting argon2-cffi-bindings\n", + " Downloading argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (86 kB)\n", + "\u001b[K |████████████████████████████████| 86 kB 5.2 MB/s \n", + "\u001b[?25hCollecting oauthlib>=3.0.0\n", + " Downloading oauthlib-3.2.0-py3-none-any.whl (151 kB)\n", + "\u001b[K |████████████████████████████████| 151 kB 49.3 MB/s \n", + "\u001b[?25hCollecting zipp>=0.5\n", + " Downloading zipp-3.8.0-py3-none-any.whl (5.4 kB)\n", + "Collecting pyasn1<0.5.0,>=0.4.6\n", + " Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)\n", + "\u001b[K |████████████████████████████████| 77 kB 5.3 MB/s \n", + "\u001b[?25hCollecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0\n", + " Downloading pyrsistent-0.18.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117 kB)\n", + "\u001b[K |████████████████████████████████| 117 kB 46.1 MB/s \n", + "\u001b[?25hCollecting attrs>=17.4.0\n", + " Downloading attrs-21.4.0-py2.py3-none-any.whl (60 kB)\n", + "\u001b[K |████████████████████████████████| 60 kB 7.3 MB/s \n", + "\u001b[?25hCollecting importlib-resources>=1.4.0; python_version < \"3.9\"\n", + " Downloading importlib_resources-5.7.1-py3-none-any.whl (28 kB)\n", + "Building wheels for collected packages: svglib, moviepy, sklearn, umap-learn, cairocffi, termcolor, proglog, pynndescent\n", + " Building wheel for svglib (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for svglib: filename=svglib-1.2.1-py3-none-any.whl size=30230 sha256=cc3441c63dd9ebd3a006fe8b4911487112e5d54a5fdf42e9b2e91cc3db348c92\n", + " Stored in directory: /root/.cache/pip/wheels/9f/52/97/c0661116fd396b64edfce39be6ae515e31a2857c839682f440\n", + " Building wheel for moviepy (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for moviepy: filename=moviepy-1.0.3-py3-none-any.whl size=110727 sha256=ce223177d246582138d46a23c7293dc8f2e0807909b94364d24b2a272d2bb1ed\n", + " Stored in directory: /root/.cache/pip/wheels/56/dc/2b/9cd600d483c04af3353d66623056fc03faed76b7518faae4df\n", + " Building wheel for sklearn (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for sklearn: filename=sklearn-0.0-py2.py3-none-any.whl size=1315 sha256=af8a353d2305876e63b59aab1ed02ef0d5ee4e6dfdf04dae5566d4f4c8df4317\n", + " Stored in directory: /root/.cache/pip/wheels/46/ef/c3/157e41f5ee1372d1be90b09f74f82b10e391eaacca8f22d33e\n", + " Building wheel for umap-learn (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for umap-learn: filename=umap_learn-0.5.3-py3-none-any.whl size=82820 sha256=5862a9f11a5c8f2c2dc491b27468c7da387e20dea4abf98a451696744b7b0b12\n", + " Stored in directory: /root/.cache/pip/wheels/b3/52/a5/1fd9e3e76a7ab34f134c07469cd6f16e27ef3a37aeff1fe821\n", + " Building wheel for cairocffi (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for cairocffi: filename=cairocffi-1.3.0-py3-none-any.whl size=89650 sha256=df3581a13b9ae8edc6f0a447929f7b4cadb796c54e11c84aa09c02ecfc2959ca\n", + " Stored in directory: /root/.cache/pip/wheels/4e/ca/e1/5c8a9692a27f639a07c949044bec943f26c81cd53d3805319f\n", + " Building wheel for termcolor (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=4e425db9a2709eb2bdcfdbf707ef1630880a1dc7f7b3ce5ba2f0119cef20bc5e\n", + " Stored in directory: /root/.cache/pip/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2\n", + " Building wheel for proglog (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for proglog: filename=proglog-0.1.9-py3-none-any.whl size=6146 sha256=af0eda61e1bec4a3031cb0fb4dc8d46305e82f50c7415dd65f3d50dadcf0b6ea\n", + " Stored in directory: /root/.cache/pip/wheels/12/36/1f/dc61e6ac10781d63cf6fa045eb09fa613a667384e12cb6e6e0\n", + " Building wheel for pynndescent (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for pynndescent: filename=pynndescent-0.5.6-py3-none-any.whl size=53931 sha256=b9ddd52457ac4f1b44f230686f77dfa1eba6b06618c707c3dc256195a7ee071c\n", + " Stored in directory: /root/.cache/pip/wheels/03/f1/56/f80d72741e400345b5a5b50ec3d929aca581bf45e0225d5c50\n", + "Successfully built svglib moviepy sklearn umap-learn cairocffi termcolor proglog pynndescent\n", + "\u001b[31mERROR: matplotlib 3.5.1 has requirement numpy>=1.17, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: tensorflow 2.8.0 has requirement numpy>=1.20, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: pywavelets 1.3.0 has requirement numpy>=1.17.3, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: scipy 1.7.3 has requirement numpy<1.23.0,>=1.16.5, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: scikit-image 0.19.2 has requirement numpy>=1.17.0, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: pandas 1.3.5 has requirement numpy>=1.17.3; platform_machine != \"aarch64\" and platform_machine != \"arm64\" and python_version < \"3.10\", but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: moviepy 1.0.3 has requirement decorator<5.0,>=4.0.2, but you'll have decorator 5.1.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: moviepy 1.0.3 has requirement numpy>=1.17.3; python_version != \"2.7\", but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: numba 0.55.1 has requirement numpy<1.22,>=1.18, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "\u001b[31mERROR: umap-learn 0.5.3 has requirement numpy>=1.17, but you'll have numpy 1.16.1 which is incompatible.\u001b[0m\n", + "Installing collected packages: torch, pillow, numpy, torchvision, python-dateutil, cycler, pyparsing, packaging, typing-extensions, kiwisolver, fonttools, matplotlib, svgwrite, webencodings, tinycss2, cssselect2, cairocffi, defusedxml, cairosvg, ptyprocess, pexpect, pygments, pickleshare, traitlets, matplotlib-inline, parso, jedi, backcall, wcwidth, prompt-toolkit, decorator, IPython, keras-preprocessing, grpcio, cached-property, h5py, tensorboard-data-server, absl-py, werkzeug, protobuf, cachetools, pyasn1, pyasn1-modules, rsa, google-auth, oauthlib, requests-oauthlib, google-auth-oauthlib, zipp, importlib-metadata, markdown, tensorboard-plugin-wit, tensorboard, astunparse, termcolor, google-pasta, flatbuffers, wrapt, keras, tensorflow-io-gcs-filesystem, gast, tf-estimator-nightly, libclang, opt-einsum, tensorflow, tensorboardX, reportlab, lxml, svglib, jupyterlab-widgets, ipython-genutils, fastjsonschema, pyrsistent, attrs, importlib-resources, jsonschema, jupyter-core, nbformat, pyzmq, Send2Trash, bleach, MarkupSafe, jinja2, jupyterlab-pygments, entrypoints, tornado, nest-asyncio, jupyter-client, nbclient, pandocfilters, mistune, soupsieve, beautifulsoup4, nbconvert, prometheus-client, argon2-cffi-bindings, argon2-cffi, psutil, debugpy, ipykernel, terminado, notebook, widgetsnbextension, ipywidgets, jupyter-console, qtpy, qtconsole, jupyter, PyWavelets, imageio, scipy, networkx, tifffile, scikit-image, pytz, pandas, proglog, imageio-ffmpeg, moviepy, llvmlite, numba, joblib, threadpoolctl, scikit-learn, sklearn, pynndescent, umap-learn, shapely, docutils, Kivy-Garden, kivy\n", + "Successfully installed IPython-7.33.0 Kivy-Garden-0.1.5 MarkupSafe-2.1.1 PyWavelets-1.3.0 Send2Trash-1.8.0 absl-py-1.0.0 argon2-cffi-21.3.0 argon2-cffi-bindings-21.2.0 astunparse-1.6.3 attrs-21.4.0 backcall-0.2.0 beautifulsoup4-4.11.1 bleach-5.0.0 cached-property-1.5.2 cachetools-5.0.0 cairocffi-1.3.0 cairosvg-2.5.2 cssselect2-0.6.0 cycler-0.11.0 debugpy-1.6.0 decorator-5.1.1 defusedxml-0.7.1 docutils-0.18.1 entrypoints-0.4 fastjsonschema-2.15.3 flatbuffers-2.0 fonttools-4.33.3 gast-0.5.3 google-auth-2.6.6 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.44.0 h5py-3.6.0 imageio-2.19.0 imageio-ffmpeg-0.4.7 importlib-metadata-4.11.3 importlib-resources-5.7.1 ipykernel-6.13.0 ipython-genutils-0.2.0 ipywidgets-7.7.0 jedi-0.18.1 jinja2-3.1.2 joblib-1.1.0 jsonschema-4.4.0 jupyter-1.0.0 jupyter-client-7.3.0 jupyter-console-6.4.3 jupyter-core-4.10.0 jupyterlab-pygments-0.2.2 jupyterlab-widgets-1.1.0 keras-2.8.0 keras-preprocessing-1.1.2 kivy-2.1.0 kiwisolver-1.4.2 libclang-14.0.1 llvmlite-0.38.0 lxml-4.8.0 markdown-3.3.6 matplotlib-3.5.1 matplotlib-inline-0.1.3 mistune-0.8.4 moviepy-1.0.3 nbclient-0.6.0 nbconvert-6.5.0 nbformat-5.3.0 nest-asyncio-1.5.5 networkx-2.6.3 notebook-6.4.11 numba-0.55.1 numpy-1.16.1 oauthlib-3.2.0 opt-einsum-3.3.0 packaging-21.3 pandas-1.3.5 pandocfilters-1.5.0 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 pillow-9.1.0 proglog-0.1.9 prometheus-client-0.14.1 prompt-toolkit-3.0.29 protobuf-3.20.1 psutil-5.9.0 ptyprocess-0.7.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pygments-2.12.0 pynndescent-0.5.6 pyparsing-3.0.8 pyrsistent-0.18.1 python-dateutil-2.8.2 pytz-2022.1 pyzmq-22.3.0 qtconsole-5.3.0 qtpy-2.0.1 reportlab-3.6.9 requests-oauthlib-1.3.1 rsa-4.8 scikit-image-0.19.2 scikit-learn-1.0.2 scipy-1.7.3 shapely-1.8.1.post1 sklearn-0.0 soupsieve-2.3.2.post1 svglib-1.2.1 svgwrite-1.4.2 tensorboard-2.8.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorboardX-2.5 tensorflow-2.8.0 tensorflow-io-gcs-filesystem-0.25.0 termcolor-1.1.0 terminado-0.13.3 tf-estimator-nightly-2.8.0.dev2021122109 threadpoolctl-3.1.0 tifffile-2021.11.2 tinycss2-1.1.1 torch-1.4.0 torchvision-0.5.0 tornado-6.1 traitlets-5.1.1 typing-extensions-4.2.0 umap-learn-0.5.3 wcwidth-0.2.5 webencodings-0.5.1 werkzeug-2.1.2 widgetsnbextension-3.6.0 wrapt-1.14.1 zipp-3.8.0\n" + ] + }, + { + "output_type": "display_data", + "data": { + "application/vnd.colab-display-data+json": { + "pip_warning": { + "packages": [ + "cycler", + "dateutil", + "ipython_genutils", + "ipywidgets", + "jupyter_core", + "kiwisolver", + "pexpect", + "pickleshare", + "traitlets", + "wcwidth", + "zmq" + ] + } + } + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip3 install cairosvg" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YwQHBzHnjxMX", + "outputId": "04e7f0de-5d5f-445c-d35f-71b50c3c6e43" + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting cairosvg\n", + " Using cached CairoSVG-2.5.2-py3-none-any.whl (45 kB)\n", + "Collecting cairocffi\n", + " Using cached cairocffi-1.3.0-py3-none-any.whl\n", + "Requirement already satisfied: defusedxml in /usr/local/lib/python3.7/dist-packages (from cairosvg) (0.7.1)\n", + "Collecting cssselect2\n", + " Using cached cssselect2-0.6.0-py3-none-any.whl (15 kB)\n", + "Requirement already satisfied: tinycss2 in /usr/local/lib/python3.7/dist-packages (from cairosvg) (1.1.1)\n", + "Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from cairosvg) (7.1.2)\n", + "Requirement already satisfied: cffi>=1.1.0 in /usr/local/lib/python3.7/dist-packages (from cairocffi->cairosvg) (1.15.0)\n", + "Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.1.0->cairocffi->cairosvg) (2.21)\n", + "Requirement already satisfied: webencodings in /usr/local/lib/python3.7/dist-packages (from cssselect2->cairosvg) (0.5.1)\n", + "Installing collected packages: cssselect2, cairocffi, cairosvg\n", + "Successfully installed cairocffi-1.3.0 cairosvg-2.5.2 cssselect2-0.6.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pwd\n", + "import os\n", + "os.chdir('/content/deepsvg')\n", + "!pwd\n", + "\n", + "import sys,os\n", + "sys.path.append(os.getcwd())\n", + "\n", + "print(sys.path)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EcW2PM01g9B8", + "outputId": "2cde228a-4a30-49fb-fac1-fdfd333ef5fc" + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content\n", + "/content/deepsvg\n", + "['', '/content', '/env/python', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages', '/usr/local/lib/python3.7/dist-packages/IPython/extensions', '/root/.ipython', '/content/deepsvg']\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%load_ext autoreload\n", + "%autoreload 2" + ], + "metadata": { + "id": "36j_if1KcQg2" + }, + "execution_count": 5, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "os.chdir(\"..\")" + ], + "metadata": { + "id": "089fygQ0cRJG" + }, + "execution_count": 6, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "from deepsvg.svglib.svg import SVG\n", + "\n", + "from deepsvg import utils\n", + "from deepsvg.difflib.tensor import SVGTensor\n", + "from deepsvg.svglib.utils import to_gif\n", + "from deepsvg.svglib.geom import Bbox\n", + "from deepsvg.svgtensor_dataset import SVGTensorDataset, load_dataset, SVGFinetuneDataset\n", + "from deepsvg.utils.utils import batchify, linear\n", + "\n", + "import torch\n", + "import numpy as np\n", + "from torch.utils.data import DataLoader\n", + "import torch.nn as nn\n" + ], + "metadata": { + "id": "AIO2aNXHcU7X" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "device = torch.device(\"cuda:0\"if torch.cuda.is_available() else \"cpu\") \n", + "\n" + ], + "metadata": { + "id": "NS2RjjA9cXkR" + }, + "execution_count": 8, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pretrained_path = \"deepsvg/pretrained/hierarchical_ordered.pth.tar\"\n", + "from configs.deepsvg.hierarchical_ordered import Config\n", + "\n", + "cfg = Config()\n", + "cfg.model_cfg.dropout = 0. # for faster convergence\n", + "model = cfg.make_model().to(device)\n", + "utils.load_model(pretrained_path, model)\n", + "model.eval();\n" + ], + "metadata": { + "id": "AgQPCy0xcZws" + }, + "execution_count": 33, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "dataset = load_dataset(cfg)" + ], + "metadata": { + "id": "M2XhKQIDcnbM" + }, + "execution_count": 12, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "def load_svg(filename):\n", + " svg = SVG.load_svg(filename)\n", + " svg = dataset.simplify(svg)\n", + " svg = dataset.preprocess(svg, mean=True)\n", + " return svg" + ], + "metadata": { + "id": "XnM6-Tmym43-" + }, + "execution_count": 13, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "def easein_easeout(t):\n", + " return t*t / (2. * (t*t - t) + 1.);\n", + "\n", + "def interpolate(z1, z2, n=25, filename=None, ease=True, do_display=True):\n", + " alphas = torch.linspace(0., 1., n)\n", + " if ease:\n", + " alphas = easein_easeout(alphas)\n", + " z_list = [(1-a) * z1 + a * z2 for a in alphas]\n", + " \n", + " img_list = [decode(z, do_display=False, return_png=True) for z in z_list]\n", + " to_gif(img_list + img_list[::-1], file_path=filename, frame_duration=1/12)\n", + "\n", + "def encode(data):\n", + " model_args = batchify((data[key] for key in cfg.model_args), device)\n", + " with torch.no_grad():\n", + " z = model(*model_args, encode_mode=True)\n", + " return z\n", + "\n", + "def encode_icon(idx):\n", + " data = dataset.get(id=idx, random_aug=False)\n", + " return encode(data)\n", + " \n", + "def encode_svg(svg):\n", + " data = dataset.get(svg=svg)\n", + " return encode(data)\n", + "\n", + "def decode(z, do_display=True, return_svg=False, return_png=False):\n", + " commands_y, args_y = model.greedy_sample(z=z)\n", + " tensor_pred = SVGTensor.from_cmd_args(commands_y[0].cpu(), args_y[0].cpu())\n", + " svg_path_sample = SVG.from_tensor(tensor_pred.data, viewbox=Bbox(256), allow_empty=True).normalize().split_paths().set_color(\"random\")\n", + " \n", + " if return_svg:\n", + " return svg_path_sample\n", + " \n", + " return svg_path_sample.draw(do_display=do_display, return_png=return_png)\n", + "\n", + "def interpolate_icons(idx1=None, idx2=None, n=25, *args, **kwargs):\n", + " z1, z2 = encode_icon(idx1), encode_icon(idx2)\n", + " interpolate(z1, z2, n=n, *args, **kwargs)\n", + "\n" + ], + "metadata": { + "id": "9oRml4Wln2UQ" + }, + "execution_count": 14, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "\n", + "# Loading user-drawn frames\n", + "\n", + "lego1 = load_svg(\"deepsvg/docs/frames/lego_1.svg\")\n", + "lego2 = load_svg(\"deepsvg/docs/frames/lego_2.svg\")\n", + "\n", + "# draw_colored lets you see the individual paths in an SVG icon.\n", + "\n", + "lego1.draw_colored(); lego2.draw_colored()\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "MsaZTIsrn6eZ", + "outputId": "30fff756-4ad4-4d67-933b-cff227051214" + }, + "execution_count": 15, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "bird1 = load_svg(\"deepsvg/docs/frames/bird_1.svg\")\n", + "bird2 = load_svg(\"deepsvg/docs/frames/bird_2.svg\"); bird2.permute([1, 0, 2]);\n", + "\n" + ], + "metadata": { + "id": "hGVNiCoyn-yZ" + }, + "execution_count": 16, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bird1.draw_colored(); bird2.draw_colored()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "IumQ8onWoI39", + "outputId": "82fee68c-98e8-47f6-ed06-1450ad450d4c" + }, + "execution_count": 17, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "face1 = load_svg(\"deepsvg/docs/frames/face_1.svg\"); face1.permute([1, 0, 2, 3, 4, 5]);\n", + "face2 = load_svg(\"deepsvg/docs/frames/face_2.svg\"); face2.permute([5, 0, 1, 2, 3, 4]); face2[0].reverse();\n" + ], + "metadata": { + "id": "SPRrJgT9oO7d" + }, + "execution_count": 18, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "face1.draw_colored(); face2.draw_colored()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "XKIGz2eCoUEn", + "outputId": "fe142ed1-50f0-4db8-f921-b49716406b80" + }, + "execution_count": 19, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "football1 = load_svg(\"deepsvg/docs/frames/football_1.svg\"); football1.permute([0, 1, 4, 2, 3, 5, 6, 7]); football1[3].reverse(); football1[4].reverse();\n", + "football2 = load_svg(\"deepsvg/docs/frames/football_2.svg\"); football2.permute([0, 2, 3, 5, 4, 7, 6, 1]);\n" + ], + "metadata": { + "id": "o6TOcPHFoWZV" + }, + "execution_count": 53, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "football1.draw_colored(); football2.draw_colored()\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "Ne9C4K-vobdv", + "outputId": "b32c4ec9-e94f-4248-a5ce-322bb482c4e2" + }, + "execution_count": 21, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "pencil1 = load_svg(\"deepsvg/docs/frames/pencil_1.svg\")\n", + "pencil2 = load_svg(\"deepsvg/docs/frames/pencil_2.svg\"); pencil2.permute([1, 0, 2, 3, 4, 5]);\n", + "\n" + ], + "metadata": { + "id": "22QeoS04ocxS" + }, + "execution_count": 22, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pencil1.draw_colored(); pencil2.draw_colored()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "3dEEZ8Oyoktn", + "outputId": "ab16bb9d-5dfa-422a-f5f9-159d721d6d85" + }, + "execution_count": 23, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n", + "ship1 = load_svg(\"deepsvg/docs/frames/ship_1.svg\"); ship1.permute([0, 1, 3, 2]);\n", + "ship2 = load_svg(\"deepsvg/docs/frames/ship_2.svg\")\n", + "\n" + ], + "metadata": { + "id": "XQjTDey2oqCd" + }, + "execution_count": 46, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ship1.draw_colored(); ship2.draw_colored()\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 424 + }, + "id": "z2ROZb-SouiC", + "outputId": "f3e18073-305b-4ef1-cee1-c8ae0648a132" + }, + "execution_count": 47, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n" + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "image/svg+xml": "\n\n\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "finetune_dataset = SVGFinetuneDataset(dataset, [lego1, lego2, football1, football2, bird1, bird2, ship1, ship2, pencil1, pencil2, face1, face2],\n", + " frac=1.0, nb_augmentations=750)" + ], + "metadata": { + "id": "8Nazg6MmoxuP" + }, + "execution_count": 54, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "dataloader = DataLoader(finetune_dataset, batch_size=cfg.batch_size, shuffle=True, drop_last=True,\n", + " num_workers=cfg.loader_num_workers, collate_fn=cfg.collate_fn)\n", + "\n", + "# Optimizer, lr & warmup schedulers\n", + "optimizers = cfg.make_optimizers(model)\n", + "scheduler_lrs = cfg.make_schedulers(optimizers, epoch_size=len(dataloader))\n", + "scheduler_warmups = cfg.make_warmup_schedulers(optimizers, scheduler_lrs)\n", + "\n", + "loss_fns = [l.to(device) for l in cfg.make_losses()]" + ], + "metadata": { + "id": "vSKO5wFeo0a7" + }, + "execution_count": 55, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "epoch = 2\n", + "for step, data in enumerate(dataloader):\n", + " model.train()\n", + " model_args = [data[arg].to(device) for arg in cfg.model_args]\n", + " labels = data[\"label\"].to(device) if \"label\" in data else None\n", + " params_dict, weights_dict = cfg.get_params(step, epoch), cfg.get_weights(step, epoch)\n", + "\n", + " for i, (loss_fn, optimizer, scheduler_lr, scheduler_warmup, optimizer_start) in enumerate(\n", + " zip(loss_fns, optimizers, scheduler_lrs, scheduler_warmups, cfg.optimizer_starts), 1):\n", + " optimizer.zero_grad()\n", + "\n", + " output = model(*model_args, params=params_dict)\n", + " loss_dict = loss_fn(output, labels, weights=weights_dict)\n", + "\n", + " loss_dict[\"loss\"].backward()\n", + " if cfg.grad_clip is not None:\n", + " nn.utils.clip_grad_norm_(model.parameters(), cfg.grad_clip)\n", + "\n", + " optimizer.step()\n", + " if scheduler_lr is not None:\n", + " scheduler_lr.step()\n", + " if scheduler_warmup is not None:\n", + " scheduler_warmup.step()\n", + "\n", + " if step % 20 == 0:\n", + " print(f\"Step {step}: loss: {loss_dict['loss']}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "R16D-2bAo3vr", + "outputId": "901196e0-b42d-46bc-f40d-091fddfa688e" + }, + "execution_count": 56, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Step 0: loss: 9.97685432434082\n", + "Step 20: loss: 1.1884565353393555\n", + "Step 40: loss: 0.3745199739933014\n", + "Step 60: loss: 0.13616029918193817\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "model.eval();" + ], + "metadata": { + "id": "b3xE3MnCo7UB" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pwd" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "id": "GZKMPs2WslQn", + "outputId": "dde738aa-2765-46c0-9622-d0909111e33d" + }, + "execution_count": 41, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "'/content'" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + } + }, + "metadata": {}, + "execution_count": 41 + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n", + "z_lego1, z_lego2 = encode_svg(lego1), encode_svg(lego2)\n", + "interpolate(z_lego1, z_lego2, filename=\"lego.gif\", do_display=False)\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 238 + }, + "id": "zOlCktE1pucD", + "outputId": "035efee1-ae63-4eb6-e9e0-27b05bd6485d" + }, + "execution_count": 42, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "100%|██████████| 101/101 [00:01<00:00, 85.40it/s]\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "z_face1, z_face2 = encode_svg(face1), encode_svg(face2)\n", + "interpolate(z_face1, z_face2, filename=\"face.gif\", do_display=False)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 238 + }, + "id": "VbA65G18pwXH", + "outputId": "45c2c2e3-0839-410e-9437-f98bc3948013" + }, + "execution_count": 43, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "100%|██████████| 101/101 [00:01<00:00, 96.20it/s]\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n", + "z_bird1, z_bird2 = encode_svg(bird1), encode_svg(bird2)\n", + "interpolate(z_bird1, z_bird2, filename=\"bird.gif\", do_display=False)\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 238 + }, + "id": "KNh7edeVtUd0", + "outputId": "8456d0c3-672a-4e4a-b418-51fa091b8cfe" + }, + "execution_count": 44, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "100%|██████████| 101/101 [00:01<00:00, 86.87it/s]\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "z_football1, z_football2 = encode_svg(football1), encode_svg(football2)\n", + "interpolate(z_football1, z_football2, filename=\"football.gif\", do_display=False)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 238 + }, + "id": "HBz1_r7P-FsP", + "outputId": "542cbae7-8293-4636-8228-73b409d68265" + }, + "execution_count": 57, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "100%|██████████| 101/101 [00:01<00:00, 82.15it/s]\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "z_football1, z_football2 = encode_svg(football1), encode_svg(football2)\n", + "interpolate(z_football1, z_football2, filename=\"football.gif\", do_display=False)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 238 + }, + "id": "sfLv12QftgD8", + "outputId": "eefced4a-5870-4570-ee2b-ca947714a3ee" + }, + "execution_count": 45, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "100%|██████████| 101/101 [00:01<00:00, 87.65it/s]\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "z_football1, z_football2 = encode_svg(football1), encode_svg(football2)\n", + "interpolate(z_football1, z_football2, filename=\"football.gif\", do_display=False)\n", + "\n", + "ship1" + ], + "metadata": { + "id": "_KcQWM0xuofo" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file