{"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":"import greatbarrierreef\nimport pandas as pd\nimport numpy as np\n\ndef predict(image_np):\n    predictions = []\n    for i in range(2):\n        score = np.random.randint(1,10)/10\n\n        x_min = np.random.randint(0,500)\n        y_min = 0\n\n        bbox_width = np.random.randint(1,200)\n        bbox_height = np.random.randint(1,200)\n        \n        predictions.append('{:.2f} {} {} {} {}'.format(score, x_min, y_min, bbox_width, bbox_height))\n    return ' '.join(predictions)\n\nenv = greatbarrierreef.make_env()   # initialize the environment\niter_test = env.iter_test()    # an iterator which loops over the test set and sample submission\nsubmission_dict = {\n    'row_num': [],\n    'annotations': [],\n}\n\nfor (image_np, sample_prediction_df) in iter_test:\n    sample_prediction_df['annotations'] = predict(image_np)\n    env.predict(sample_prediction_df)\n\n    submission_dict['row_num'].append(sample_prediction_df['index'].values[0])\n    submission_dict['annotations'].append(sample_prediction_df['annotations'].values[0])\n    print('Prediction:', submission_dict['annotations'][-1])","metadata":{"execution":{"iopub.status.busy":"2021-12-17T19:39:45.870665Z","iopub.execute_input":"2021-12-17T19:39:45.871062Z","iopub.status.idle":"2021-12-17T19:39:45.904963Z","shell.execute_reply.started":"2021-12-17T19:39:45.870953Z","shell.execute_reply":"2021-12-17T19:39:45.903783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pd.DataFrame(submission_dict).to_csv('submission.csv',index=False)","metadata":{"execution":{"iopub.status.busy":"2021-12-09T18:09:31.600798Z","iopub.execute_input":"2021-12-09T18:09:31.601042Z","iopub.status.idle":"2021-12-09T18:09:31.608111Z","shell.execute_reply.started":"2021-12-09T18:09:31.601013Z","shell.execute_reply":"2021-12-09T18:09:31.606945Z"},"trusted":true},"execution_count":null,"outputs":[]}]}