{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# How to deal with competition that does not allow internet access.\n\n- Need GDCM library to read some of the images\n- Need updated fastai to use timm models\n- Would like to use timm\n- Not sure if these solutions are the most efficient, but they do work\n\nUsing instructions from https://www.kaggle.com/code/samuelepino/pip-installing-packages-with-no-internet, Step 1: I ran the following cell in it's own notebook called `CSpine Helper`","metadata":{}},{"cell_type":"code","source":"## Using instructions from https://www.kaggle.com/code/samuelepino/pip-installing-packages-with-no-internet\n!python -m pip download fastai -q\n!python -m pip download pylibjpeg -q\n!python -m pip download python-gdcm -q\n!python -m pip download pylibjpeg-libjpeg -q\n!python -m pip download timm -q","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"- Step 2: After running the code in it's own notebook, I used the `Add Data` button and selected `Notebook Output` and chose the `CSpine Helper` notebook.\n\n- Step 3: Install the libraries needed using sys.executable\n\n- When I installed fastai and checked the version, it still showed the original, not the updated. Adding \"--upgrade --no-deps --ignore-installed\" to the install fixed that.","metadata":{}},{"cell_type":"code","source":"# Libraries \nimport sys\n\n!{sys.executable} -m pip install '../input/cspine-helper/fastai-2.7.9-py3-none-any.whl' --upgrade --no-deps --ignore-installed -q \n!{sys.executable} -m pip install '../input/cspine-helper/fastcore-1.5.21-py3-none-any.whl' -Uqq\n!{sys.executable} -m pip install '../input/cspine-helper/pylibjpeg-1.4.0-py3-none-any.whl' -q\n!{sys.executable} -m pip install '../input/cspine-helper/pylibjpeg_libjpeg-1.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl' -q\n!{sys.executable} -m pip install '../input/cspine-helper/python_gdcm-3.0.15-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl' -q\n!{sys.executable} -m pip install '../input/cspine-helper/timm-0.6.7-py3-none-any.whl' -q","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"In order to use the timm model 'convnext_tiny', I needed to \n\n- Add the dataset of timm models from https://www.kaggle.com/datasets/kozodoi/timm-pytorch-image-models by using the Add Data button\n- Since the convnext model itself was not included, I downloaded it from https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth \n- and then used the Upload icon to upload the file to its own dataset.\n \n- Finally, the model needs to be in moved to '/root/.cache/torch/hub/checkpoints/' so that fastai can find it","metadata":{}},{"cell_type":"code","source":"#Dataset of timm models from https://www.kaggle.com/datasets/kozodoi/timm-pytorch-image-models\nsys.path.append('../input/timm-pytorch-image-models/pytorch-image-models-master')\n\n#https://www.kaggle.com/code/tanlikesmath/petfinder-pawpularity-eda-fastai-starter/notebook\n# Making pretrained weights work without needing to find the default filename\nimport os\nif not os.path.exists('/root/.cache/torch/hub/checkpoints/'):\n    os.makedirs('/root/.cache/torch/hub/checkpoints/')\n!cp '../input/convnext-tiny-ik-ema/convnext_tiny_1k_224_ema.pth' '/root/.cache/torch/hub/checkpoints/convnext_tiny_1k_224_ema.pth'\n","metadata":{},"execution_count":null,"outputs":[]}]}