{"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":"# 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_s.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-09T03:07:58.761476Z","iopub.execute_input":"2022-01-09T03:07:58.761848Z","iopub.status.idle":"2022-01-09T03:09:10.899367Z","shell.execute_reply.started":"2022-01-09T03:07:58.761753Z","shell.execute_reply":"2022-01-09T03:09:10.898381Z"},"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 = 40\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-09T03:10:16.235895Z","iopub.execute_input":"2022-01-09T03:10:16.236459Z","iopub.status.idle":"2022-01-09T03:10:16.242095Z","shell.execute_reply.started":"2022-01-09T03:10:16.236421Z","shell.execute_reply":"2022-01-09T03:10:16.241348Z"},"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-09T03:09:21.300613Z","iopub.execute_input":"2022-01-09T03:09:21.300894Z","iopub.status.idle":"2022-01-09T03:09:21.307782Z","shell.execute_reply.started":"2022-01-09T03:09:21.300862Z","shell.execute_reply":"2022-01-09T03:09:21.307095Z"},"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-09T03:09:23.415915Z","iopub.execute_input":"2022-01-09T03:09:23.416715Z","iopub.status.idle":"2022-01-09T03:09:23.42374Z","shell.execute_reply.started":"2022-01-09T03:09:23.416665Z","shell.execute_reply":"2022-01-09T03:09:23.422943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nos.listdir('yolox')","metadata":{"execution":{"iopub.status.busy":"2022-01-09T03:09:47.753279Z","iopub.execute_input":"2022-01-09T03:09:47.753914Z","iopub.status.idle":"2022-01-09T03:09:47.76029Z","shell.execute_reply.started":"2022-01-09T03:09:47.753872Z","shell.execute_reply":"2022-01-09T03:09:47.759515Z"},"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_s.pth","metadata":{"execution":{"iopub.status.busy":"2022-01-09T03:10:26.647815Z","iopub.execute_input":"2022-01-09T03:10:26.64814Z","iopub.status.idle":"2022-01-09T03:13:07.371108Z","shell.execute_reply.started":"2022-01-09T03:10:26.648105Z","shell.execute_reply":"2022-01-09T03:13:07.370263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cp -r YOLOX_outputs /kaggle/working","metadata":{"execution":{"iopub.status.busy":"2022-01-09T03:13:53.687097Z","iopub.execute_input":"2022-01-09T03:13:53.687434Z","iopub.status.idle":"2022-01-09T03:13:54.634851Z","shell.execute_reply.started":"2022-01-09T03:13:53.687394Z","shell.execute_reply":"2022-01-09T03:13:54.633929Z"},"trusted":true},"execution_count":null,"outputs":[]}]}