{"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":"# Remarks\n\nFor best AP, please use v5 which is trained with \n- e=40,\n- mode = yolo-l\n- inputsize = 960x960\n- Foldings = StratifiedK\n- the result hyperparameters is default","metadata":{}},{"cell_type":"markdown","source":"##### Clone YoloX Repo and Install Requirements","metadata":{}},{"cell_type":"code","source":"import os\nfrom IPython import display\nos.mkdir('../tmp')\nos.chdir('../tmp')\n\n# Clone repo\n!git clone https://github.com/Megvii-BaseDetection/YOLOX -q\n\n# Install requirments.txt    \n%cd YOLOX\n!pip install -U pip && pip install -r requirements.txt\n!pip install -v -e . \n\n# Download YoloX-S pretreined model\n!wget https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_l.pth\n\n# Install COCO API    \n!pip install -Uqqq 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'    \ndisplay.clear_output()","metadata":{"execution":{"iopub.status.busy":"2022-01-16T13:07:23.921409Z","iopub.execute_input":"2022-01-16T13:07:23.921842Z","iopub.status.idle":"2022-01-16T13:08:59.553221Z","shell.execute_reply.started":"2022-01-16T13:07:23.921755Z","shell.execute_reply":"2022-01-16T13:08:59.552373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%writefile cots_config.py\n\nimport os\nfrom yolox.exp import Exp as MyExp\n\nclass Exp(MyExp):\n    def __init__(self):\n        super(Exp, self).__init__()\n        self.depth = 0.33\n        self.width = 0.50\n        self.exp_name = os.path.split(os.path.realpath(__file__))[1].split(\".\")[0]\n        \n        # dirs\n        self.data_dir = '/kaggle/input/cotscocostratifiedk5folds-4919-imgs/dataset/images'\n        self.train_ann = '/kaggle/input/cotscocostratifiedk5folds-4919-imgs/dataset/images/annotations/train.json'\n        self.val_ann = '/kaggle/input/cotscocostratifiedk5folds-4919-imgs/dataset/images/annotations/valid.json'\n        \n        self.input_size = (960, 960)\n        self.test_size = (960, 960)\n        self.num_classes = 1\n        \n        self.max_epoch = 37\n        self.data_num_workers = 2\n        self.eval_interval = 1\n        \n        # Augmentations\n        self.mosaic_prob = 1.0\n        self.mosaic_scale = (0.5, 1.5)\n        self.mixup_prob = 1.0\n        self.hsv_prob = 1.0\n        self.flip_prob = 0.5\n        self.no_aug_epochs = 2","metadata":{"execution":{"iopub.status.busy":"2022-01-16T13:08:59.555519Z","iopub.execute_input":"2022-01-16T13:08:59.555794Z","iopub.status.idle":"2022-01-16T13:08:59.563238Z","shell.execute_reply.started":"2022-01-16T13:08:59.555753Z","shell.execute_reply":"2022-01-16T13:08:59.562548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%writefile datasets/voc_classes.py\n\nVOC_CLASSES = (\n  \"starfish\",\n)","metadata":{"execution":{"iopub.status.busy":"2022-01-16T13:08:59.564764Z","iopub.execute_input":"2022-01-16T13:08:59.565391Z","iopub.status.idle":"2022-01-16T13:08:59.575204Z","shell.execute_reply.started":"2022-01-16T13:08:59.565352Z","shell.execute_reply":"2022-01-16T13:08:59.574549Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%writefile datasets/coco_classes.py\n\nCOCO_CLASSES = (\n  \"starfish\",\n)","metadata":{"execution":{"iopub.status.busy":"2022-01-16T13:08:59.577384Z","iopub.execute_input":"2022-01-16T13:08:59.577933Z","iopub.status.idle":"2022-01-16T13:08:59.585109Z","shell.execute_reply.started":"2022-01-16T13:08:59.577895Z","shell.execute_reply":"2022-01-16T13:08:59.584362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python tools/train.py \\\n    -f cots_config.py \\\n    -d 1 \\\n    -b 16 \\\n    --fp16 \\\n    -o \\\n    -c yolox_l.pth","metadata":{"execution":{"iopub.status.busy":"2022-01-16T13:08:59.586505Z","iopub.execute_input":"2022-01-16T13:08:59.587071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cp -r YOLOX_outputs /kaggle/working","metadata":{"execution":{"iopub.status.busy":"2022-01-09T13:49:18.141618Z","iopub.execute_input":"2022-01-09T13:49:18.141871Z","iopub.status.idle":"2022-01-09T13:49:18.897852Z","shell.execute_reply.started":"2022-01-09T13:49:18.141842Z","shell.execute_reply":"2022-01-09T13:49:18.896417Z"},"trusted":true},"execution_count":null,"outputs":[]}]}