Loading
Feedback

AI Blitz #7

Solution for Mars Rotation

Solution for Mars Rotation

By derinformatiker

This notebook's solution is more reproducible than my other notebook about this challenge.



In [1]:
!git clone https://github.com/derInformatiker/AIcrowd-AIBlitz7-Solution.git
!pip install -r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt
!pip install aicrowd-cli==0.1
Cloning into 'AIcrowd-AIBlitz7-Solution'...
remote: warning: multi-pack bitmap is missing required reverse index
remote: Enumerating objects: 313, done.
remote: Counting objects: 100% (313/313), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 313 (delta 184), reused 219 (delta 121), pack-reused 0
Receiving objects: 100% (313/313), 462.25 KiB | 23.11 MiB/s, done.
Resolving deltas: 100% (184/184), done.
Collecting pandas==1.0.5
  Downloading https://files.pythonhosted.org/packages/af/f3/683bf2547a3eaeec15b39cef86f61e921b3b187f250fcd2b5c5fb4386369/pandas-1.0.5-cp37-cp37m-manylinux1_x86_64.whl (10.1MB)
     |████████████████████████████████| 10.1MB 17.5MB/s 
Collecting opencv-python==4.2.0.32
  Downloading https://files.pythonhosted.org/packages/34/a3/403dbaef909fee9f9f6a8eaff51d44085a14e5bb1a1ff7257117d744986a/opencv_python-4.2.0.32-cp37-cp37m-manylinux1_x86_64.whl (28.2MB)
     |████████████████████████████████| 28.2MB 111kB/s 
Collecting pytorch-lightning==1.2.4
  Downloading https://files.pythonhosted.org/packages/3c/9e/ddf2230626f5a56238d01a0739c62243170db1b136f8e0697db4402bec6d/pytorch_lightning-1.2.4-py3-none-any.whl (829kB)
     |████████████████████████████████| 829kB 43.8MB/s 
Collecting efficientnet-pytorch==0.6.3
  Downloading https://files.pythonhosted.org/packages/b8/cb/0309a6e3d404862ae4bc017f89645cf150ac94c14c88ef81d215c8e52925/efficientnet_pytorch-0.6.3.tar.gz
Collecting albumentations==0.4.6
  Downloading https://files.pythonhosted.org/packages/92/33/1c459c2c9a4028ec75527eff88bc4e2d256555189f42af4baf4d7bd89233/albumentations-0.4.6.tar.gz (117kB)
     |████████████████████████████████| 122kB 54.6MB/s 
Requirement 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)
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)
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)
Collecting future>=0.17.1
  Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)
     |████████████████████████████████| 829kB 45.8MB/s 
Requirement 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)
Collecting fsspec[http]>=0.8.1
  Downloading https://files.pythonhosted.org/packages/62/11/f7689b996f85e45f718745c899f6747ee5edb4878cadac0a41ab146828fa/fsspec-0.9.0-py3-none-any.whl (107kB)
     |████████████████████████████████| 112kB 57.3MB/s 
Requirement 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)
Collecting PyYAML!=5.4.*,>=5.1
  Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)
     |████████████████████████████████| 276kB 63.2MB/s 
Requirement 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)
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)
Collecting imgaug>=0.4.0
  Downloading https://files.pythonhosted.org/packages/66/b1/af3142c4a85cba6da9f4ebb5ff4e21e2616309552caca5e8acefe9840622/imgaug-0.4.0-py2.py3-none-any.whl (948kB)
     |████████████████████████████████| 952kB 43.8MB/s 
Requirement 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)
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)
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)
Collecting aiohttp; extra == "http"
  Downloading https://files.pythonhosted.org/packages/88/c0/5890b4c8b04a79b7360e8fe4490feb0bb3ab179743f199f0e6220cebd568/aiohttp-3.7.4.post0-cp37-cp37m-manylinux2014_x86_64.whl (1.3MB)
     |████████████████████████████████| 1.3MB 45.9MB/s 
Requirement 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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Collecting async-timeout<4.0,>=3.0
  Downloading https://files.pythonhosted.org/packages/e1/1e/5a4441be21b0726c4464f3f23c8b19628372f606755a9d2e46c187e65ec4/async_timeout-3.0.1-py3-none-any.whl
Collecting multidict<7.0,>=4.5
  Downloading https://files.pythonhosted.org/packages/7c/a6/4123b8165acbe773d1a8dc8e3f0d1edea16d29f7de018eda769abb56bd30/multidict-5.1.0-cp37-cp37m-manylinux2014_x86_64.whl (142kB)
     |████████████████████████████████| 143kB 59.3MB/s 
Requirement 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)
Collecting yarl<2.0,>=1.0
  Downloading https://files.pythonhosted.org/packages/f1/62/046834c5fc998c88ab2ef722f5d42122230a632212c8afa76418324f53ff/yarl-1.6.3-cp37-cp37m-manylinux2014_x86_64.whl (294kB)
     |████████████████████████████████| 296kB 61.2MB/s 
Requirement 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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Building wheels for collected packages: efficientnet-pytorch, albumentations, future, PyYAML
  Building wheel for efficientnet-pytorch (setup.py) ... done
  Created wheel for efficientnet-pytorch: filename=efficientnet_pytorch-0.6.3-cp37-none-any.whl size=12420 sha256=5392d102d1137d2f98e8caf15e7340195f00729ed94e8e0a3ff39cccbf65a4b7
  Stored in directory: /root/.cache/pip/wheels/42/1e/a9/2a578ba9ad04e776e80bf0f70d8a7f4c29ec0718b92d8f6ccd
  Building wheel for albumentations (setup.py) ... done
  Created wheel for albumentations: filename=albumentations-0.4.6-cp37-none-any.whl size=65163 sha256=8af7baf0158d7fc75cfe9703f08e94da1d46d10d138235335bc464704c260b30
  Stored in directory: /root/.cache/pip/wheels/c7/f4/89/56d1bee5c421c36c1a951eeb4adcc32fbb82f5344c086efa14
  Building wheel for future (setup.py) ... done
  Created wheel for future: filename=future-0.18.2-cp37-none-any.whl size=491058 sha256=6f66a24cd24e8cf72b4fa2585913958696f547c479d9af7f31666b685e69a83f
  Stored in directory: /root/.cache/pip/wheels/8b/99/a0/81daf51dcd359a9377b110a8a886b3895921802d2fc1b2397e
  Building wheel for PyYAML (setup.py) ... done
  Created wheel for PyYAML: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=44620 sha256=fd0e13c574c9e8849311584cd72e13977b90e8a3a3077a3f1b555c41fbbd1a8a
  Stored in directory: /root/.cache/pip/wheels/a7/c1/ea/cf5bd31012e735dc1dfea3131a2d5eae7978b251083d6247bd
Successfully built efficientnet-pytorch albumentations future PyYAML
ERROR: 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.
Installing collected packages: pandas, opencv-python, future, async-timeout, multidict, yarl, aiohttp, fsspec, PyYAML, pytorch-lightning, efficientnet-pytorch, imgaug, albumentations
  Found existing installation: pandas 1.1.5
    Uninstalling pandas-1.1.5:
      Successfully uninstalled pandas-1.1.5
  Found existing installation: opencv-python 4.1.2.30
    Uninstalling opencv-python-4.1.2.30:
      Successfully uninstalled opencv-python-4.1.2.30
  Found existing installation: future 0.16.0
    Uninstalling future-0.16.0:
      Successfully uninstalled future-0.16.0
  Found existing installation: PyYAML 3.13
    Uninstalling PyYAML-3.13:
      Successfully uninstalled PyYAML-3.13
  Found existing installation: imgaug 0.2.9
    Uninstalling imgaug-0.2.9:
      Successfully uninstalled imgaug-0.2.9
  Found existing installation: albumentations 0.1.12
    Uninstalling albumentations-0.1.12:
      Successfully uninstalled albumentations-0.1.12
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
Collecting aicrowd-cli==0.1
  Downloading https://files.pythonhosted.org/packages/84/45/232809ceb8b1462a2c7eec17335cef9e74bdd0fbde6d5d31a9fb570f1bcf/aicrowd-cli-0.1.0.tar.gz (40kB)
     |████████████████████████████████| 40kB 2.5MB/s 
Requirement already satisfied: click<8,>=7.1.2 in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (7.1.2)
Collecting gitpython
  Downloading https://files.pythonhosted.org/packages/a6/99/98019716955ba243657daedd1de8f3a88ca1f5b75057c38e959db22fb87b/GitPython-3.1.14-py3-none-any.whl (159kB)
     |████████████████████████████████| 163kB 19.8MB/s 
Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (2.23.0)
Collecting requests-toolbelt
  Downloading https://files.pythonhosted.org/packages/60/ef/7681134338fc097acef8d9b2f8abe0458e4d87559c689a8c306d0957ece5/requests_toolbelt-0.9.1-py2.py3-none-any.whl (54kB)
     |████████████████████████████████| 61kB 9.4MB/s 
Collecting rich
  Downloading https://files.pythonhosted.org/packages/1a/da/2a1f064dc620ab47f3f826ae085384084b71ea05c8c21d67f1dfc29189ab/rich-10.1.0-py3-none-any.whl (201kB)
     |████████████████████████████████| 204kB 12.6MB/s 
Requirement already satisfied: toml in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (0.10.2)
Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from aicrowd-cli==0.1) (4.41.1)
Collecting gitdb<5,>=4.0.1
  Downloading https://files.pythonhosted.org/packages/ea/e8/f414d1a4f0bbc668ed441f74f44c116d9816833a48bf81d22b697090dba8/gitdb-4.0.7-py3-none-any.whl (63kB)
     |████████████████████████████████| 71kB 11.6MB/s 
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->aicrowd-cli==0.1) (1.24.3)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (2020.12.5)
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)
Collecting commonmark<0.10.0,>=0.9.0
  Downloading https://files.pythonhosted.org/packages/b1/92/dfd892312d822f36c55366118b95d914e5f16de11044a27cf10a7d71bbbf/commonmark-0.9.1-py2.py3-none-any.whl (51kB)
     |████████████████████████████████| 51kB 8.6MB/s 
Requirement 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)
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)
Collecting colorama<0.5.0,>=0.4.0
  Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl
Collecting smmap<5,>=3.0.1
  Downloading https://files.pythonhosted.org/packages/68/ee/d540eb5e5996eb81c26ceffac6ee49041d473bc5125f2aa995cf51ec1cf1/smmap-4.0.0-py2.py3-none-any.whl
Building wheels for collected packages: aicrowd-cli
  Building wheel for aicrowd-cli (setup.py) ... done
  Created wheel for aicrowd-cli: filename=aicrowd_cli-0.1.0-cp37-none-any.whl size=34929 sha256=6c07ad37a298baeeafd99f1368b7f2e3614e008aa7041ea4c763733417b22fec
  Stored in directory: /root/.cache/pip/wheels/7e/ec/cc/a38391f23ad9bd044c91cd5e6e0a30f2a4265a1eb5adedf9f5
Successfully built aicrowd-cli
Installing collected packages: smmap, gitdb, gitpython, requests-toolbelt, commonmark, colorama, rich, aicrowd-cli
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

RESTART RUNTIME TO USE NEW PACKAGES

In [1]:
API_KEY = ""  # Please enter your API Key from [https://www.aicrowd.com/participants/me]
!aicrowd login --api-key $API_KEY
API Key valid
Saved API Key successfully!
In [2]:
!aicrowd dataset download --challenge mars-rotation

!rm -rf data
!mkdir data

!unzip -q train.zip  -d data/train
!unzip -q val.zip -d data/val
!unzip -q test.zip  -d data/test

!mv train.csv data/train.csv
!mv val.csv data/val.csv
!mv sample_submission.csv data/sample_submission.csv
sample_submission.csv: 100% 95.9k/95.9k [00:00<00:00, 669kB/s]
test.zip: 100% 76.5M/76.5M [00:06<00:00, 11.8MB/s]
train.csv: 100% 377k/377k [00:00<00:00, 1.22MB/s]
train.zip: 100% 306M/306M [00:59<00:00, 5.12MB/s]
val.csv: 100% 33.7k/33.7k [00:00<00:00, 563kB/s]
val.zip: 100% 30.6M/30.6M [00:02<00:00, 13.9MB/s]
In [3]:
import shutil

shutil.copy('AIcrowd-AIBlitz7-Solution/challenge3/model.py','model.py')
shutil.copy('AIcrowd-AIBlitz7-Solution/challenge3/dataset.py','dataset.py')
Out[3]:
'dataset.py'
In [4]:
import dataset
import albumentations as A
import matplotlib.pyplot as plt
import pandas as pd
import torch
In [ ]:
import model
import albumentations as A
from albumentations.augmentations.transforms import Flip
import pytorch_lightning as pl
from pytorch_lightning import Trainer

img_size = 230

if __name__ == '__main__':
    ckpt = pl.callbacks.model_checkpoint.ModelCheckpoint(monitor = 'val_loss',save_top_k = 1,mode = 'min')
    trainer = Trainer(max_epochs = 100,gpus = 1, callbacks = ckpt, precision=16, amp_level='O1',deterministic=True,fast_dev_run = False)
    
    train_tr = A.Compose([
        A.CenterCrop(img_size,img_size,always_apply=True),
        Flip(p=0.25)
    ])
    
    val_tr = A.Compose([
        A.CenterCrop(img_size,img_size,always_apply=True)
    ])
    
    model = model.Classifier({'lr':3e-4,'batch_size':48,'train_tr':train_tr,'val_tr':val_tr})
    
    #ckpt = torch.load(path)
    #model.load_state_dict(ckpt['state_dict'])
    trainer.fit(model)
    trainer.test(model)
In [ ]:
import model
import torch
import albumentations as A
from albumentations.augmentations.transforms import Flip, VerticalFlip, HorizontalFlip
import pytorch_lightning as pl
from pytorch_lightning import Trainer
m = 0

tr0 = A.Compose([
        A.CenterCrop(230,230,always_apply=True)
])

tr1 = A.Compose([
    A.CenterCrop(230,230,always_apply=True),
    A.VerticalFlip(p = 1)
])

tr2 = A.Compose([
    A.CenterCrop(230,230,always_apply=True),
    A.HorizontalFlip(p = 1)
])

tr3 = A.Compose([
    A.CenterCrop(230,230,always_apply=True),
    A.HorizontalFlip(p = 1),
    A.VerticalFlip(p = 1)
])

tr_list = [tr0,tr1,tr2,tr3]
concat = torch.tensor([])

for tr in tr_list:
    if __name__ == '__main__':

        path = '' #PATH OF LAST CHECKPOINT ================================
        trainer = Trainer(gpus = 1, precision=16, amp_level='O1',deterministic=True)

        train_tr = A.Compose([
            A.CenterCrop(230,230,always_apply=True)
        ])

        val_tr = A.Compose([
            A.CenterCrop(230,230,always_apply=True)
        ])

        m = model.Classifier({'lr':3e-4,'batch_size':48,'train_tr':train_tr,'val_tr':tr})

        ckpt = torch.load(path)
        m.load_state_dict(ckpt['state_dict'])

        out = trainer.predict(m)
        output = torch.tensor([])

        for i in range(len(out)):
            output = torch.cat((output,torch.tensor(out[i]).argmax(1)))
        concat = torch.cat((concat,output.unsqueeze(0)),0)
In [ ]:
output = torch.round(concat[0])
In [ ]:
import model
model.writeSub(output)
In [ ]:

↕️  Read More


Comments

You must login before you can post a comment.