{"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":"code","source":"! pip install -q --no-index --find-links=file:///kaggle/input/contrails-weights/pip \\\n    segmentation_models_pytorch\n! cp -r /kaggle/input/contrails-src ./src","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport sys\nimport yaml\nsys.path.append('/kaggle/working/src')\nimport unet5\nimport vit4\nimport unet1024\nimport util\nfrom submit import write_submission","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-08-09T13:10:51.861417Z","iopub.execute_input":"2023-08-09T13:10:51.861844Z","iopub.status.idle":"2023-08-09T13:10:55.294136Z","shell.execute_reply.started":"2023-08-09T13:10:51.861804Z","shell.execute_reply":"2023-08-09T13:10:55.29317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Configuration","metadata":{}},{"cell_type":"code","source":"cfg = yaml.safe_load(\"\"\"\ninput:\n  weight: /kaggle/input/contrails-weights\n\nunet5:\n  batch_size: 1\n  models:\n    - name: maxvit_tiny\n      encoder: maxvit_tiny_tf_512.in1k\n      decoder_channels: [256, 128, 64, 32, 16]\n      w: 1.0\n      resize: 512\n      tta: d4prob\n      folds: [0,1,2,3,4]\n\nvit4:\n  batch_size: 2\n  models:\n    - name: vit4_1024\n      encoder: maxvit_tiny_tf_512.in1k\n      decoder_channels: [256, 128, 64, 32, 32]\n      #w: 0.6669411076255138\n      w: 1.0\n      resize: 512\n      tta: d4prob\n      folds: [5,6,7,8,9]\n\nunet1024:\n  batch_size: 2\n  models:\n    - name: unet1024\n      encoder: maxvit_tiny_tf_512.in1k\n      decoder_channels: [256, 128, 64, 32, 16]\n      #w: 0.42019871465275055\n      w: 1.0\n      resize: 1024\n      tta: d4prob\n      folds: [0,2,3,4,5]\n\"\"\")","metadata":{"execution":{"iopub.status.busy":"2023-08-09T13:10:55.296135Z","iopub.execute_input":"2023-08-09T13:10:55.296532Z","iopub.status.idle":"2023-08-09T13:10:55.308891Z","shell.execute_reply.started":"2023-08-09T13:10:55.296473Z","shell.execute_reply":"2023-08-09T13:10:55.307969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Run","metadata":{}},{"cell_type":"code","source":"data_type = 'test'\n#data_type = 'validation'\ndebug=False\n\n# Unet3 (Ash-color 3-channel image)\n#preds = unet5.run(data_type, cfg, None, debug=debug)\n\n#th=0.4673\n#preds = unet1024.run(data_type, cfg, None, debug=debug)\n\nth=0.4633\npreds = vit4.run(data_type, cfg, None, debug=debug)\n\n# Ensemble\n#th = 0.5\n#preds = vit4.run(data_type, cfg, None, debug=debug)\n#unet1024.run(data_type, cfg, preds, debug=debug)\n\nutil.check_preds_finite(preds)\n\n# Write submission.csv\nsubmit = write_submission(preds, th, 'submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-08-09T13:10:55.310207Z","iopub.execute_input":"2023-08-09T13:10:55.31106Z","iopub.status.idle":"2023-08-09T13:11:40.57587Z","shell.execute_reply.started":"2023-08-09T13:10:55.311035Z","shell.execute_reply":"2023-08-09T13:11:40.574378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! tail submission.csv\n\nif data_type == 'validation':\n    ! python3 src/score.py submission.csv","metadata":{"execution":{"iopub.status.busy":"2023-08-09T13:11:40.579558Z","iopub.execute_input":"2023-08-09T13:11:40.579972Z","iopub.status.idle":"2023-08-09T13:11:41.617216Z","shell.execute_reply.started":"2023-08-09T13:11:40.579922Z","shell.execute_reply":"2023-08-09T13:11:41.616053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}