Loading
Feedback

AI Blitz #7

Solution for Stage Prediction

Solution for Stage Prediction

By derinformatiker


In [1]:
!git clone https://github.com/derInformatiker/AIcrowd-AIBlitz7-Solution.git
!pip install -r AIcrowd-AIBlitz7-Solution/challenge4/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: 317, done.
remote: Counting objects: 100% (317/317), done.
remote: Compressing objects: 100% (191/191), done.
remote: Total 317 (delta 186), reused 219 (delta 121), pack-reused 0
Receiving objects: 100% (317/317), 469.43 KiB | 18.78 MiB/s, done.
Resolving deltas: 100% (186/186), 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.8MB/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 112kB/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 45.9MB/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 51.3MB/s 
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)
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: 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)
Collecting future>=0.17.1
  Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)
     |████████████████████████████████| 829kB 46.9MB/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)
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)
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)
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 53.3MB/s 
Collecting PyYAML!=5.4.*,>=5.1
  Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)
     |████████████████████████████████| 276kB 61.4MB/s 
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 41.3MB/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: 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: 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: 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: 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: requests<3,>=2.21.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)) (2.23.0)
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: 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: 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: 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: 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: 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: 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)
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 31.7MB/s 
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: 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: 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: 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: 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: 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: 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: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests<3,>=2.21.0->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests<3,>=2.21.0->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (3.0.4)
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<3,>=2.21.0->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (1.24.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests<3,>=2.21.0->tensorboard>=2.2.0->pytorch-lightning==1.2.4->-r AIcrowd-AIBlitz7-Solution/challenge3/requirements.txt (line 3)) (2020.12.5)
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: 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)
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 47.8MB/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 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 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 56.6MB/s 
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: 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: 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: 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: pyasn1>=0.1.3 in /usr/local/lib/python3.7/dist-packages (from rsa<5,>=3.1.4; python_version >= "3.6"->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: 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: 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=4de89acb270b36ed56e89785762ea65276d273741c3dd6763f010fc3dc2579d4
  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=c8893ed254994c9115053a76a6df54f57efaee1f21703563fd2c652513a23bec
  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=c0e67cb8a2c83dcce6a090a86d86dd80aeaa7595712da162af958dec6d995595
  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=48904c9ecdcb655aa9f619f04f0a087c58c021282a2130a425e748e55733f10e
  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, multidict, async-timeout, 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.3MB/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 17.9MB/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 8.5MB/s 
Collecting rich
  Downloading https://files.pythonhosted.org/packages/1a/da/2a1f064dc620ab47f3f826ae085384084b71ea05c8c21d67f1dfc29189ab/rich-10.1.0-py3-none-any.whl (201kB)
     |████████████████████████████████| 204kB 38.8MB/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 10.0MB/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: 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)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->aicrowd-cli==0.1) (2.10)
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.1MB/s 
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
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)
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=4b79e7fd91a34e7d84e022bb6056132d92548bb51cdbfd6b0552678eec3ba179
  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 [14]:
!aicrowd dataset download --challenge stage-prediction

!rm -rf data
!mkdir data

!unzip -q test.zip  -d data
import os
os.rename('data/test', 'data/train')
!mv sample_submission.csv data/sample_submission.csv
sample_submission.csv: 100% 13.3k/13.3k [00:00<00:00, 796kB/s]
test.zip: 100% 27.7M/27.7M [00:02<00:00, 10.6MB/s]
In [15]:
import shutil

shutil.copy('AIcrowd-AIBlitz7-Solution/challenge4/model.py','model.py')
shutil.copy('AIcrowd-AIBlitz7-Solution/challenge4/dataset.py','dataset.py')
Out[15]:
'dataset.py'
In [16]:
import pandas as pd
baseline = []
images_list = [598,1048,1198,1498,1798]
last = 0
for u, i in enumerate(images_list):
    baseline.extend([u]*(i-last))
    last = i
baseline = [0]+baseline

df = pd.read_csv('data/sample_submission.csv')
df.label = baseline
df.to_csv('data/labels.csv',index = False)
In [17]:
import model
import dataset
import torch
import albumentations as A
import pytorch_lightning as pl
from pytorch_lightning import Trainer

if __name__ == '__main__':
    trainer = Trainer(max_epochs = 30,gpus = 1, precision=16, amp_level='O1',deterministic=True)
    
    train_tr = A.Compose([
        A.CenterCrop(256,256,always_apply=True)
    ])
    
    val_tr = A.Compose([
        A.CenterCrop(256,256,always_apply=True)
    ])
    
    model = model.Classifier({'lr':3e-4,'batch_size':32,'train_tr':train_tr,'val_tr':val_tr})
    trainer.fit(model)
    trainer.test(model)
    out = trainer.predict(model)
    output = torch.tensor([])

    for i in range(len(out)):
        output = torch.cat((output,torch.tensor(out[i][0]).argmax(1)))
    output = output.int().tolist()
    dataset.writeSub(output)
GPU available: True, used: True
TPU available: None, using: 0 TPU cores
Using native 16bit precision.

  | Name   | Type         | Params
----------------------------------------
0 | resnet | EfficientNet | 10.7 M
----------------------------------------
10.7 M    Trainable params
0         Non-trainable params
10.7 M    Total params
42.816    Total estimated model params size (MB)
Loaded pretrained weights for efficientnet-b3
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:477: UserWarning: This DataLoader will create 6 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  cpuset_checked))
/content/model.py:23: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  prob = F.softmax(x)

/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py:51: UserWarning: you defined a test_step but have no test_dataloader. Skipping test loop
  warnings.warn(*args, **kwargs)

In [ ]:

↕️  Read More


Comments

You must login before you can post a comment.