{"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":"**This notebook is copy of this one https://www.kaggle.com/steamedsheep/yolov5-is-all-you-need \nI just changed the following parameters:size10000_conf0.015_augTrue_row.confidence0.28","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport torch\nfrom tqdm import tqdm\nimport sys\n\nsys.path.append('../input/tensorflow-great-barrier-reef')","metadata":{"execution":{"iopub.status.busy":"2022-01-18T17:33:59.913214Z","iopub.execute_input":"2022-01-18T17:33:59.913491Z","iopub.status.idle":"2022-01-18T17:33:59.919629Z","shell.execute_reply.started":"2022-01-18T17:33:59.913453Z","shell.execute_reply":"2022-01-18T17:33:59.91866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir -p /root/.config/Ultralytics\n!cp /kaggle/input/yolov5-font/Arial.ttf /root/.config/Ultralytics/","metadata":{"execution":{"iopub.status.busy":"2022-01-18T17:33:59.952269Z","iopub.execute_input":"2022-01-18T17:33:59.952619Z","iopub.status.idle":"2022-01-18T17:34:01.263568Z","shell.execute_reply.started":"2022-01-18T17:33:59.952586Z","shell.execute_reply":"2022-01-18T17:34:01.262471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import greatbarrierreef\nenv = greatbarrierreef.make_env()# initialize the environment\niter_test = env.iter_test()      # an iterator which loops over the test set and sample submission","metadata":{"execution":{"iopub.status.busy":"2022-01-18T17:34:01.266146Z","iopub.execute_input":"2022-01-18T17:34:01.266452Z","iopub.status.idle":"2022-01-18T17:34:01.297627Z","shell.execute_reply.started":"2022-01-18T17:34:01.266396Z","shell.execute_reply":"2022-01-18T17:34:01.296897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = torch.hub.load('../input/yolov5-lib-ds', \n                       'custom', \n                       path='../input/reef-baseline-fold12/l6_3600_uflip_vm5_f12_up/f1/best.pt',\n                       source='local',\n                       force_reload=True)  # local repo\nmodel.conf = 0.20","metadata":{"execution":{"iopub.status.busy":"2022-01-18T17:34:01.299368Z","iopub.execute_input":"2022-01-18T17:34:01.299867Z","iopub.status.idle":"2022-01-18T17:34:07.765249Z","shell.execute_reply.started":"2022-01-18T17:34:01.299828Z","shell.execute_reply":"2022-01-18T17:34:07.764431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"for idx, (img, pred_df) in enumerate(tqdm(iter_test)):\n    anno = ''\n    r = model(img, size=10000, augment=True)\n    if r.pandas().xyxy[0].shape[0] == 0:\n        anno = ''\n    else:\n        for idx, row in r.pandas().xyxy[0].iterrows():\n            if row.confidence > 0.28:\n                anno += '{} {} {} {} {} '.format(row.confidence, int(row.xmin), int(row.ymin), int(row.xmax-row.xmin), int(row.ymax-row.ymin))\n#                 pred.append([row.confidence, row.xmin, row.ymin, row.xmax-row.xmin, row.ymax-row.ymin])\n    pred_df['annotations'] = anno.strip(' ')\n    env.predict(pred_df)","metadata":{"execution":{"iopub.status.busy":"2022-01-18T17:34:07.766954Z","iopub.execute_input":"2022-01-18T17:34:07.767202Z","iopub.status.idle":"2022-01-18T17:34:16.629896Z","shell.execute_reply.started":"2022-01-18T17:34:07.76717Z","shell.execute_reply":"2022-01-18T17:34:16.628651Z"},"trusted":true},"execution_count":null,"outputs":[]}]}