{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "Python [conda env:ml]",
      "language": "python",
      "name": "conda-env-ml-py"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8.3"
    },
    "colab": {
      "name": "run.ipynb",
      "provenance": [],
      "toc_visible": true
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "YnZdIM7nPC67",
        "outputId": "8d5b1392-f5aa-4f13-f5d6-db734d775257",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "!git clone https://github.com/derInformatiker/AIcrowd-AIBlitz7-Solution.git\n",
        "!pip install -r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt\n",
        "!pip install aicrowd-cli==0.1"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Cloning into 'AIcrowd-AIBlitz7-Solution'...\n",
            "remote: warning: multi-pack bitmap is missing required reverse index\u001b[K\n",
            "remote: Enumerating objects: 313, done.\u001b[K\n",
            "remote: Counting objects: 100% (313/313), done.\u001b[K\n",
            "remote: Compressing objects: 100% (187/187), done.\u001b[K\n",
            "remote: Total 313 (delta 184), reused 219 (delta 121), pack-reused 0\u001b[K\n",
            "Receiving objects: 100% (313/313), 462.25 KiB | 23.11 MiB/s, done.\n",
            "Resolving deltas: 100% (184/184), done.\n",
            "Collecting pandas==1.0.5\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/af/f3/683bf2547a3eaeec15b39cef86f61e921b3b187f250fcd2b5c5fb4386369/pandas-1.0.5-cp37-cp37m-manylinux1_x86_64.whl (10.1MB)\n",
            "\u001b[K     |████████████████████████████████| 10.1MB 17.5MB/s \n",
            "\u001b[?25hCollecting opencv-python==4.2.0.32\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/34/a3/403dbaef909fee9f9f6a8eaff51d44085a14e5bb1a1ff7257117d744986a/opencv_python-4.2.0.32-cp37-cp37m-manylinux1_x86_64.whl (28.2MB)\n",
            "\u001b[K     |████████████████████████████████| 28.2MB 111kB/s \n",
            "\u001b[?25hCollecting pytorch-lightning==1.2.4\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3c/9e/ddf2230626f5a56238d01a0739c62243170db1b136f8e0697db4402bec6d/pytorch_lightning-1.2.4-py3-none-any.whl (829kB)\n",
            "\u001b[K     |████████████████████████████████| 829kB 43.8MB/s \n",
            "\u001b[?25hCollecting efficientnet-pytorch==0.6.3\n",
            "  Downloading https://files.pythonhosted.org/packages/b8/cb/0309a6e3d404862ae4bc017f89645cf150ac94c14c88ef81d215c8e52925/efficientnet_pytorch-0.6.3.tar.gz\n",
            "Collecting albumentations==0.4.6\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/92/33/1c459c2c9a4028ec75527eff88bc4e2d256555189f42af4baf4d7bd89233/albumentations-0.4.6.tar.gz (117kB)\n",
            "\u001b[K     |████████████████████████████████| 122kB 54.6MB/s \n",
            "\u001b[?25hRequirement already satisfied: python-dateutil>=2.6.1 in /usr/local/lib/python3.7/dist-packages (from pandas==1.0.5->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 1)) (2.8.1)\n",
            "Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from pandas==1.0.5->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 1)) (1.19.5)\n",
            "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas==1.0.5->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 1)) (2018.9)\n",
            "Collecting future>=0.17.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)\n",
            "\u001b[K     |████████████████████████████████| 829kB 45.8MB/s \n",
            "\u001b[?25hRequirement already satisfied: tqdm>=4.41.0 in /usr/local/lib/python3.7/dist-packages (from pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (4.41.1)\n",
            "Collecting fsspec[http]>=0.8.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/62/11/f7689b996f85e45f718745c899f6747ee5edb4878cadac0a41ab146828fa/fsspec-0.9.0-py3-none-any.whl (107kB)\n",
            "\u001b[K     |████████████████████████████████| 112kB 57.3MB/s \n",
            "\u001b[?25hRequirement already satisfied: torch>=1.4 in /usr/local/lib/python3.7/dist-packages (from pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.8.1+cu101)\n",
            "Collecting PyYAML!=5.4.*,>=5.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)\n",
            "\u001b[K     |████████████████████████████████| 276kB 63.2MB/s \n",
            "\u001b[?25hRequirement already satisfied: tensorboard>=2.2.0 in /usr/local/lib/python3.7/dist-packages (from pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2.4.1)\n",
            "Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (1.4.1)\n",
            "Collecting imgaug>=0.4.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/66/b1/af3142c4a85cba6da9f4ebb5ff4e21e2616309552caca5e8acefe9840622/imgaug-0.4.0-py2.py3-none-any.whl (948kB)\n",
            "\u001b[K     |████████████████████████████████| 952kB 43.8MB/s \n",
            "\u001b[?25hRequirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.6.1->pandas==1.0.5->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 1)) (1.15.0)\n",
            "Requirement already satisfied: importlib-metadata; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.8.1)\n",
            "Requirement already satisfied: requests; extra == \"http\" in /usr/local/lib/python3.7/dist-packages (from fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2.23.0)\n",
            "Collecting aiohttp; extra == \"http\"\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/88/c0/5890b4c8b04a79b7360e8fe4490feb0bb3ab179743f199f0e6220cebd568/aiohttp-3.7.4.post0-cp37-cp37m-manylinux2014_x86_64.whl (1.3MB)\n",
            "\u001b[K     |████████████████████████████████| 1.3MB 45.9MB/s \n",
            "\u001b[?25hRequirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch>=1.4->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.7.4.3)\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.3.4)\n",
            "Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (54.2.0)\n",
            "Requirement already satisfied: protobuf>=3.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.12.4)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.0.1)\n",
            "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (0.4.3)\n",
            "Requirement already satisfied: absl-py>=0.4 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (0.12.0)\n",
            "Requirement already satisfied: grpcio>=1.24.3 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.32.0)\n",
            "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.8.0)\n",
            "Requirement already satisfied: wheel>=0.26; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (0.36.2)\n",
            "Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.7/dist-packages (from tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.28.0)\n",
            "Requirement already satisfied: scikit-image>=0.14.2 in /usr/local/lib/python3.7/dist-packages (from imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (0.16.2)\n",
            "Requirement already satisfied: Shapely in /usr/local/lib/python3.7/dist-packages (from imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (1.7.1)\n",
            "Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (7.1.2)\n",
            "Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (3.2.2)\n",
            "Requirement already satisfied: imageio in /usr/local/lib/python3.7/dist-packages (from imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (2.4.1)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata; python_version < \"3.8\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.4.1)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests; extra == \"http\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2020.12.5)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests; extra == \"http\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.0.4)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests; extra == \"http\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2.10)\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; extra == \"http\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.24.3)\n",
            "Collecting async-timeout<4.0,>=3.0\n",
            "  Downloading https://files.pythonhosted.org/packages/e1/1e/5a4441be21b0726c4464f3f23c8b19628372f606755a9d2e46c187e65ec4/async_timeout-3.0.1-py3-none-any.whl\n",
            "Collecting multidict<7.0,>=4.5\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/7c/a6/4123b8165acbe773d1a8dc8e3f0d1edea16d29f7de018eda769abb56bd30/multidict-5.1.0-cp37-cp37m-manylinux2014_x86_64.whl (142kB)\n",
            "\u001b[K     |████████████████████████████████| 143kB 59.3MB/s \n",
            "\u001b[?25hRequirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp; extra == \"http\"->fsspec[http]>=0.8.1->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (20.3.0)\n",
            "Collecting yarl<2.0,>=1.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/f1/62/046834c5fc998c88ab2ef722f5d42122230a632212c8afa76418324f53ff/yarl-1.6.3-cp37-cp37m-manylinux2014_x86_64.whl (294kB)\n",
            "\u001b[K     |████████████████████████████████| 296kB 61.2MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.3.0)\n",
            "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (0.2.8)\n",
            "Requirement already satisfied: rsa<5,>=3.1.4; python_version >= \"3.6\" in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (4.7.2)\n",
            "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (4.2.1)\n",
            "Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (1.1.1)\n",
            "Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (2.5)\n",
            "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (1.3.1)\n",
            "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (0.10.0)\n",
            "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (2.4.7)\n",
            "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.1.0)\n",
            "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.7/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (0.4.8)\n",
            "Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.7/dist-packages (from networkx>=2.0->scikit-image>=0.14.2->imgaug>=0.4.0->albumentations==0.4.6->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 5)) (4.4.2)\n",
            "Building wheels for collected packages: efficientnet-pytorch, albumentations, future, PyYAML\n",
            "  Building wheel for efficientnet-pytorch (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for efficientnet-pytorch: filename=efficientnet_pytorch-0.6.3-cp37-none-any.whl size=12420 sha256=5392d102d1137d2f98e8caf15e7340195f00729ed94e8e0a3ff39cccbf65a4b7\n",
            "  Stored in directory: /root/.cache/pip/wheels/42/1e/a9/2a578ba9ad04e776e80bf0f70d8a7f4c29ec0718b92d8f6ccd\n",
            "  Building wheel for albumentations (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for albumentations: filename=albumentations-0.4.6-cp37-none-any.whl size=65163 sha256=8af7baf0158d7fc75cfe9703f08e94da1d46d10d138235335bc464704c260b30\n",
            "  Stored in directory: /root/.cache/pip/wheels/c7/f4/89/56d1bee5c421c36c1a951eeb4adcc32fbb82f5344c086efa14\n",
            "  Building wheel for future (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for future: filename=future-0.18.2-cp37-none-any.whl size=491058 sha256=6f66a24cd24e8cf72b4fa2585913958696f547c479d9af7f31666b685e69a83f\n",
            "  Stored in directory: /root/.cache/pip/wheels/8b/99/a0/81daf51dcd359a9377b110a8a886b3895921802d2fc1b2397e\n",
            "  Building wheel for PyYAML (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for PyYAML: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=44620 sha256=fd0e13c574c9e8849311584cd72e13977b90e8a3a3077a3f1b555c41fbbd1a8a\n",
            "  Stored in directory: /root/.cache/pip/wheels/a7/c1/ea/cf5bd31012e735dc1dfea3131a2d5eae7978b251083d6247bd\n",
            "Successfully built efficientnet-pytorch albumentations future PyYAML\n",
            "\u001b[31mERROR: google-colab 1.0.0 has requirement pandas~=1.1.0; python_version >= \"3.0\", but you'll have pandas 1.0.5 which is incompatible.\u001b[0m\n",
            "Installing collected packages: pandas, opencv-python, future, async-timeout, multidict, yarl, aiohttp, fsspec, PyYAML, pytorch-lightning, efficientnet-pytorch, imgaug, albumentations\n",
            "  Found existing installation: pandas 1.1.5\n",
            "    Uninstalling pandas-1.1.5:\n",
            "      Successfully uninstalled pandas-1.1.5\n",
            "  Found existing installation: opencv-python 4.1.2.30\n",
            "    Uninstalling opencv-python-4.1.2.30:\n",
            "      Successfully uninstalled opencv-python-4.1.2.30\n",
            "  Found existing installation: future 0.16.0\n",
            "    Uninstalling future-0.16.0:\n",
            "      Successfully uninstalled future-0.16.0\n",
            "  Found existing installation: PyYAML 3.13\n",
            "    Uninstalling PyYAML-3.13:\n",
            "      Successfully uninstalled PyYAML-3.13\n",
            "  Found existing installation: imgaug 0.2.9\n",
            "    Uninstalling imgaug-0.2.9:\n",
            "      Successfully uninstalled imgaug-0.2.9\n",
            "  Found existing installation: albumentations 0.1.12\n",
            "    Uninstalling albumentations-0.1.12:\n",
            "      Successfully uninstalled albumentations-0.1.12\n",
            "Successfully installed PyYAML-5.3.1 aiohttp-3.7.4.post0 albumentations-0.4.6 async-timeout-3.0.1 efficientnet-pytorch-0.6.3 fsspec-0.9.0 future-0.18.2 imgaug-0.4.0 multidict-5.1.0 opencv-python-4.2.0.32 pandas-1.0.5 pytorch-lightning-1.2.4 yarl-1.6.3\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.colab-display-data+json": {
              "pip_warning": {
                "packages": [
                  "pandas"
                ]
              }
            }
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Collecting aicrowd-cli==0.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/84/45/232809ceb8b1462a2c7eec17335cef9e74bdd0fbde6d5d31a9fb570f1bcf/aicrowd-cli-0.1.0.tar.gz (40kB)\n",
            "\r\u001b[K     |████████                        | 10kB 24.7MB/s eta 0:00:01\r\u001b[K     |████████████████▏               | 20kB 31.3MB/s eta 0:00:01\r\u001b[K     |████████████████████████▎       | 30kB 23.3MB/s eta 0:00:01\r\u001b[K     |████████████████████████████████| 40kB 2.5MB/s \n",
            "\u001b[?25hRequirement already satisfied: click<8,>=7.1.2 in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (7.1.2)\n",
            "Collecting gitpython\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a6/99/98019716955ba243657daedd1de8f3a88ca1f5b75057c38e959db22fb87b/GitPython-3.1.14-py3-none-any.whl (159kB)\n",
            "\u001b[K     |████████████████████████████████| 163kB 19.8MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (2.23.0)\n",
            "Collecting requests-toolbelt\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/60/ef/7681134338fc097acef8d9b2f8abe0458e4d87559c689a8c306d0957ece5/requests_toolbelt-0.9.1-py2.py3-none-any.whl (54kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 9.4MB/s \n",
            "\u001b[?25hCollecting rich\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1a/da/2a1f064dc620ab47f3f826ae085384084b71ea05c8c21d67f1dfc29189ab/rich-10.1.0-py3-none-any.whl (201kB)\n",
            "\u001b[K     |████████████████████████████████| 204kB 12.6MB/s \n",
            "\u001b[?25hRequirement already satisfied: toml in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (0.10.2)\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (4.41.1)\n",
            "Collecting gitdb<5,>=4.0.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/ea/e8/f414d1a4f0bbc668ed441f74f44c116d9816833a48bf81d22b697090dba8/gitdb-4.0.7-py3-none-any.whl (63kB)\n",
            "\u001b[K     |████████████████████████████████| 71kB 11.6MB/s \n",
            "\u001b[?25hRequirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (1.24.3)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (2.10)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (2020.12.5)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (3.0.4)\n",
            "Collecting commonmark<0.10.0,>=0.9.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/b1/92/dfd892312d822f36c55366118b95d914e5f16de11044a27cf10a7d71bbbf/commonmark-0.9.1-py2.py3-none-any.whl (51kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 8.6MB/s \n",
            "\u001b[?25hRequirement already satisfied: pygments<3.0.0,>=2.6.0 in /usr/local/lib/python3.7/dist-packages (from rich->aicrowd-cli==0.1) (2.6.1)\n",
            "Requirement already satisfied: typing-extensions<4.0.0,>=3.7.4 in /usr/local/lib/python3.7/dist-packages (from rich->aicrowd-cli==0.1) (3.7.4.3)\n",
            "Collecting colorama<0.5.0,>=0.4.0\n",
            "  Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl\n",
            "Collecting smmap<5,>=3.0.1\n",
            "  Downloading https://files.pythonhosted.org/packages/68/ee/d540eb5e5996eb81c26ceffac6ee49041d473bc5125f2aa995cf51ec1cf1/smmap-4.0.0-py2.py3-none-any.whl\n",
            "Building wheels for collected packages: aicrowd-cli\n",
            "  Building wheel for aicrowd-cli (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for aicrowd-cli: filename=aicrowd_cli-0.1.0-cp37-none-any.whl size=34929 sha256=6c07ad37a298baeeafd99f1368b7f2e3614e008aa7041ea4c763733417b22fec\n",
            "  Stored in directory: /root/.cache/pip/wheels/7e/ec/cc/a38391f23ad9bd044c91cd5e6e0a30f2a4265a1eb5adedf9f5\n",
            "Successfully built aicrowd-cli\n",
            "Installing collected packages: smmap, gitdb, gitpython, requests-toolbelt, commonmark, colorama, rich, aicrowd-cli\n",
            "Successfully installed aicrowd-cli-0.1.0 colorama-0.4.4 commonmark-0.9.1 gitdb-4.0.7 gitpython-3.1.14 requests-toolbelt-0.9.1 rich-10.1.0 smmap-4.0.0\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "e8SaljuLPyVr"
      },
      "source": [
        "###RESTART RUNTIME TO USE NEW PACKAGES"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "knQ_vThDPC3v",
        "outputId": "d642ffdf-a666-490e-d3fc-94fd0f78f70a",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "source": [
        "API_KEY = \"\"  # Please enter your API Key from [https://www.aicrowd.com/participants/me]\n",
        "!aicrowd login --api-key $API_KEY"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\u001b[32mAPI Key valid\u001b[0m\n",
            "\u001b[32mSaved API Key successfully!\u001b[0m\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "to5axl1OPC15",
        "outputId": "0f34db11-3daa-4ef1-d450-38df39fe0a37",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "source": [
        "!aicrowd dataset download --challenge mars-rotation\n",
        "\n",
        "!rm -rf data\n",
        "!mkdir data\n",
        "\n",
        "!unzip -q train.zip  -d data/train\n",
        "!unzip -q val.zip -d data/val\n",
        "!unzip -q test.zip  -d data/test\n",
        "\n",
        "!mv train.csv data/train.csv\n",
        "!mv val.csv data/val.csv\n",
        "!mv sample_submission.csv data/sample_submission.csv"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "sample_submission.csv: 100% 95.9k/95.9k [00:00<00:00, 669kB/s]\n",
            "test.zip: 100% 76.5M/76.5M [00:06<00:00, 11.8MB/s]\n",
            "train.csv: 100% 377k/377k [00:00<00:00, 1.22MB/s]\n",
            "train.zip: 100% 306M/306M [00:59<00:00, 5.12MB/s]\n",
            "val.csv: 100% 33.7k/33.7k [00:00<00:00, 563kB/s]\n",
            "val.zip: 100% 30.6M/30.6M [00:02<00:00, 13.9MB/s]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4nAfDKQ5PC0c",
        "outputId": "c3b37029-b0a6-4710-ab9d-4a3c56f4e171",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 36
        }
      },
      "source": [
        "import shutil\n",
        "\n",
        "shutil.copy('AIcrowd-AIBlitz7-Solution/challenge3/model.py','model.py')\n",
        "shutil.copy('AIcrowd-AIBlitz7-Solution/challenge3/dataset.py','dataset.py')"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            },
            "text/plain": [
              "'dataset.py'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 3
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "uK8aKOmuO-T_"
      },
      "source": [
        "import dataset\n",
        "import albumentations as A\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "import torch"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "HsSSVyQKO-UB"
      },
      "source": [
        "import model\n",
        "import albumentations as A\n",
        "from albumentations.augmentations.transforms import Flip\n",
        "import pytorch_lightning as pl\n",
        "from pytorch_lightning import Trainer\n",
        "\n",
        "img_size = 230\n",
        "\n",
        "if __name__ == '__main__':\n",
        "    ckpt = pl.callbacks.model_checkpoint.ModelCheckpoint(monitor = 'val_loss',save_top_k = 1,mode = 'min')\n",
        "    trainer = Trainer(max_epochs = 100,gpus = 1, callbacks = ckpt, precision=16, amp_level='O1',deterministic=True,fast_dev_run = False)\n",
        "    \n",
        "    train_tr = A.Compose([\n",
        "        A.CenterCrop(img_size,img_size,always_apply=True),\n",
        "        Flip(p=0.25)\n",
        "    ])\n",
        "    \n",
        "    val_tr = A.Compose([\n",
        "        A.CenterCrop(img_size,img_size,always_apply=True)\n",
        "    ])\n",
        "    \n",
        "    model = model.Classifier({'lr':3e-4,'batch_size':48,'train_tr':train_tr,'val_tr':val_tr})\n",
        "    \n",
        "    #ckpt = torch.load(path)\n",
        "    #model.load_state_dict(ckpt['state_dict'])\n",
        "    trainer.fit(model)\n",
        "    trainer.test(model)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "arOKX0rSO-UC"
      },
      "source": [
        "import model\n",
        "import torch\n",
        "import albumentations as A\n",
        "from albumentations.augmentations.transforms import Flip, VerticalFlip, HorizontalFlip\n",
        "import pytorch_lightning as pl\n",
        "from pytorch_lightning import Trainer\n",
        "m = 0\n",
        "\n",
        "tr0 = A.Compose([\n",
        "        A.CenterCrop(230,230,always_apply=True)\n",
        "])\n",
        "\n",
        "tr1 = A.Compose([\n",
        "    A.CenterCrop(230,230,always_apply=True),\n",
        "    A.VerticalFlip(p = 1)\n",
        "])\n",
        "\n",
        "tr2 = A.Compose([\n",
        "    A.CenterCrop(230,230,always_apply=True),\n",
        "    A.HorizontalFlip(p = 1)\n",
        "])\n",
        "\n",
        "tr3 = A.Compose([\n",
        "    A.CenterCrop(230,230,always_apply=True),\n",
        "    A.HorizontalFlip(p = 1),\n",
        "    A.VerticalFlip(p = 1)\n",
        "])\n",
        "\n",
        "tr_list = [tr0,tr1,tr2,tr3]\n",
        "concat = torch.tensor([])\n",
        "\n",
        "for tr in tr_list:\n",
        "    if __name__ == '__main__':\n",
        "\n",
        "        path = '' #PATH OF LAST CHECKPOINT ================================\n",
        "        trainer = Trainer(gpus = 1, precision=16, amp_level='O1',deterministic=True)\n",
        "\n",
        "        train_tr = A.Compose([\n",
        "            A.CenterCrop(230,230,always_apply=True)\n",
        "        ])\n",
        "\n",
        "        val_tr = A.Compose([\n",
        "            A.CenterCrop(230,230,always_apply=True)\n",
        "        ])\n",
        "\n",
        "        m = model.Classifier({'lr':3e-4,'batch_size':48,'train_tr':train_tr,'val_tr':tr})\n",
        "\n",
        "        ckpt = torch.load(path)\n",
        "        m.load_state_dict(ckpt['state_dict'])\n",
        "\n",
        "        out = trainer.predict(m)\n",
        "        output = torch.tensor([])\n",
        "\n",
        "        for i in range(len(out)):\n",
        "            output = torch.cat((output,torch.tensor(out[i]).argmax(1)))\n",
        "        concat = torch.cat((concat,output.unsqueeze(0)),0)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "VtXOiF1YO-UD"
      },
      "source": [
        "output = torch.round(concat[0])"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "CpU5RFKYO-UE"
      },
      "source": [
        "import model\n",
        "model.writeSub(output) "
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jTqtFExTO-UE"
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}