{"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 os\nfrom pathlib import Path\nimport sys\nimport wandb\n!wandb off\nfrom tqdm import tqdm\nimport warnings\nimport cv2\nimport pandas as pd\nfrom pathlib import Path\nimport numpy as np\nimport matplotlib as mpl\nfrom tqdm import tqdm\nimport shutil\nimport yaml\nimport warnings\nimport cv2\nfrom matplotlib import patches as patches\nimport shutil\nimport yaml\nfrom matplotlib import pyplot as plt\nfrom IPython.display import display_html\nimport torch\nimport shutil\nimport yaml\nimport time\nimport random\n\nname1 = \"ignore\"\nname2 = \"true\"\nwarnings.filterwarnings(name1)\nenviron_name = \"WANDB_SILENT\"\nos.environ[environ_name] = name2\nCONFIG = dict()\nCONFIG[\"competition\"] = \"greatReef\"\nCONFIG[\"_wandb_kernel\"] = \"aot\"\n\n# # Custom colors\n# class color:\n#     S = '\\033[1m' + '\\033[94m'\n#     E = '\\033[0m'\n    \n# my_colors = [\"#16558F\", \"#1583D2\", \"#61B0B7\", \"#ADDEFF\", \"#A99AEA\", \"#7158B7\"]\n# print(color.S+\"Current Directory\"+color.E, os.getcwd())\n# print(color.S+\"Notebook Color Scheme:\"+color.E)\n# sns.palplot(sns.color_palette(my_colors))","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:15:15.908721Z","iopub.execute_input":"2022-11-10T11:15:15.908977Z","iopub.status.idle":"2022-11-10T11:15:20.459647Z","shell.execute_reply.started":"2022-11-10T11:15:15.908947Z","shell.execute_reply":"2022-11-10T11:15:20.458884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# def save_dataset_artifact(run_name, artifact_name, path):\n#     '''Saves dataset to W&B Artifactory.\n#     run_name: name of the experiment\n#     artifact_name: under what name should the dataset be stored\n#     path: path to the dataset'''\n    \n#     run = wandb.init(project='g2net', \n#                      name=run_name, \n#                      config=CONFIG, anonymous=\"allow\")\n#     artifact = wandb.Artifact(name=artifact_name, \n#                               type='dataset')\n#     artifact.add_file(path)\n\n#     wandb.log_artifact(artifact)\n#     wandb.finish()\n#     print(\"Artifact has been saved successfully.\")\n    \n    \n# def create_wandb_plot(x_data=None, y_data=None, x_name=None, y_name=None, title=None, log=None, plot=\"line\"):\n#     '''Create and save lineplot/barplot in W&B Environment.\n#     x_data & y_data: Pandas Series containing x & y data\n#     x_name & y_name: strings containing axis names\n#     title: title of the graph\n#     log: string containing name of log'''\n    \n#     data = [[label, val] for (label, val) in zip(x_data, y_data)]\n#     table = wandb.Table(data=data, columns = [x_name, y_name])\n    \n#     if plot == \"line\":\n#         wandb.log({log : wandb.plot.line(table, x_name, y_name, title=title)})\n#     elif plot == \"bar\":\n#         wandb.log({log : wandb.plot.bar(table, x_name, y_name, title=title)})\n#     elif plot == \"scatter\":\n#         wandb.log({log : wandb.plot.scatter(table, x_name, y_name, title=title)})\n        \n        \n# def create_wandb_hist(x_data=None, x_name=None, title=None, log=None):\n#     '''Create and save histogram in W&B Environment.\n#     x_data: Pandas Series containing x values\n#     x_name: strings containing axis name\n#     title: title of the graph\n#     log: string containing name of log'''\n    \n#     data = [[x] for x in x_data]\n#     table = wandb.Table(data=data, columns=[x_name])\n#     wandb.log({log : wandb.plot.histogram(table, x_name, title=title)})","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-11-10T11:15:20.461287Z","iopub.execute_input":"2022-11-10T11:15:20.461546Z","iopub.status.idle":"2022-11-10T11:15:20.466694Z","shell.execute_reply.started":"2022-11-10T11:15:20.461512Z","shell.execute_reply":"2022-11-10T11:15:20.466023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# print(color.S+\"-Directory Structure-\"+color.E)\n# print(color.S+\"Before:\"+color.E, os.listdir(\"../\"))\n\n# Create 2 new folders\ndir1 = '../images'\ndir2 = '../labels'\nos.makedirs(dir1)\nos.makedirs(dir2)\nos.listdir(\"../\")\n\n# print(color.S+\"After:\"+color.E, os.listdir(\"../\"))","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:15:20.467965Z","iopub.execute_input":"2022-11-10T11:15:20.468611Z","iopub.status.idle":"2022-11-10T11:15:20.485432Z","shell.execute_reply.started":"2022-11-10T11:15:20.468576Z","shell.execute_reply":"2022-11-10T11:15:20.484708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csv_path = \"../input/2021-greatbarrierreef-prep-data\" + \"/\" + \"train.csv\"\ntrain = pd.read_csv(train_csv_path)\n\ntrain = train[train[\"no_annotations\"]>0]\nflag = True\ntrain = train.reset_index(drop=flag)\n\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:15:20.487181Z","iopub.execute_input":"2022-11-10T11:15:20.488198Z","iopub.status.idle":"2022-11-10T11:15:20.695728Z","shell.execute_reply.started":"2022-11-10T11:15:20.488159Z","shell.execute_reply":"2022-11-10T11:15:20.695032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"name = \"path\"\ntrain_path = train[name]\ntrain_path_list = train_path.tolist()\nfor path in tqdm(train_path_list):\n    split_path = path.split(\"/\")\n    \n    video_id_idx = -2\n    video_frame_idx = -1\n    video_id = split_path[video_id_idx]\n    video_frame = split_path[video_frame_idx]\n\n    path_image = f\"../images\" + \"/\" + f\"{video_id}\" + \"_\" + f\"{video_frame}\"\n    \n    old_path = path\n    new_path = path_image\n    shutil.copy(src=old_path, dst=new_path)","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:15:26.097174Z","iopub.execute_input":"2022-11-10T11:15:26.097613Z","iopub.status.idle":"2022-11-10T11:16:29.24706Z","shell.execute_reply.started":"2022-11-10T11:15:26.097573Z","shell.execute_reply":"2022-11-10T11:16:29.246209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"figsize = [10, 10]\nplt.figure(figsize=figsize)\nprint(\"Sample image(video_1_5840.jpg) show as follow:\")\nimg_path = \"../images/video_1_5840.jpg\"\nimNumpy = cv2.imread(img_path)\nimNumpy = cv2.cvtColor(imNumpy, cv2.COLOR_BGR2RGB)\nplt.imshow(imNumpy)\naxis_off = \"off\"\nplt.axis(axis_off)","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:16:34.773411Z","iopub.execute_input":"2022-11-10T11:16:34.773687Z","iopub.status.idle":"2022-11-10T11:16:35.230735Z","shell.execute_reply.started":"2022-11-10T11:16:34.773659Z","shell.execute_reply":"2022-11-10T11:16:35.228311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def coco2yolo(image_height, image_width, bboxes):\n    \n    bboxes = np.array(bboxes)\n    bboxes = bboxes.astype(float)\n\n    tmp1 = bboxes[:, [0, 2]] / image_width\n    tmp2 = bboxes[:, [1, 3]] / image_height\n    tmp3 = bboxes[:, [0, 1]] + bboxes[:, [2, 3]] / 2\n    bboxes[:, [0, 2]]= tmp1\n    bboxes[:, [1, 3]]= tmp2\n    bboxes[:, [0, 1]] = tmp3\n    \n    para1 = 0\n    para2 = 1\n    bboxes = np.clip(bboxes, a_min=para1, a_max=para2)\n    \n    return bboxes","metadata":{"execution":{"iopub.status.busy":"2022-11-10T13:02:25.102312Z","iopub.execute_input":"2022-11-10T13:02:25.102585Z","iopub.status.idle":"2022-11-10T13:02:25.109017Z","shell.execute_reply.started":"2022-11-10T13:02:25.102554Z","shell.execute_reply":"2022-11-10T13:02:25.10803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tmp = list()\nyolo_bboxes = tmp\nnum = len(train)\n\nfor k in tqdm(range(num)):\n    tmp = k\n    row_data = train.iloc[tmp, :]\n    height_col_name = \"height\"\n    width_name = \"width\"\n    height = row_data[height_col_name]\n    width = row_data[width_name]\n    coco_bbox_name = row_data[\"coco_bbox\"]\n    coco_bbox = eval(coco_bbox_name)\n    name = \"no_annotations\"\n    len_bbox = row_data[name]\n    \n    # Create file and write in it\n    name = \"path_labels\"\n    path = row_data[name]\n    with open(path, 'w') as file:\n        \n        num = 0\n        if len_bbox == num: \n            name = \"\"\n            file.write(name)\n            continue\n        \n        tmp = coco2yolo(height, width, coco_bbox)\n        yolo_bbox = tmp\n        yolo_bboxes.append(tmp)\n        \n        # Write annotations in file\n        for i in range(len_bbox):\n            annot = [\"0\"]\n            annot += yolo_bbox[i].astype(str).tolist()\n            if i + 1 == len_bbox:\n                annot += [\"\"]\n            else:\n                annot += [\"\\n\"]\n            \n            annot = \" \".join(annot)\n            annot = annot.strip()\n            file.write(annot)\n            \nname = \"yolo_bbox\"\ntrain[name] = yolo_bboxes","metadata":{"execution":{"iopub.status.busy":"2022-11-10T13:02:32.265204Z","iopub.execute_input":"2022-11-10T13:02:32.26595Z","iopub.status.idle":"2022-11-10T13:02:35.049645Z","shell.execute_reply.started":"2022-11-10T13:02:32.265913Z","shell.execute_reply":"2022-11-10T13:02:35.04829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Some sample images\nimages_list = os.listdir(\"/kaggle/images\")\nimages = os.listdir(\"/kaggle/images\")[12:18]\n\nvid_id, seq_id = list(), list()\nfor im in images:\n    im_list = im.split(\"_\")\n    vid_id.append(im_list[1])\n    seq_id.append(im_list[2].split(\".\")[0])\n    \nwidth, height = 2, 3\nfigsize = [23, 10]\nfig, axs = plt.subplots(width, height, figsize=figsize)\naxs = axs.flatten()\n\nfor k in range(width * height):\n    img_path = f\"/kaggle/images/{images[k]}\"\n    im = cv2.cvtColor(cv2.imread(img_path), cv2.COLOR_BGR2RGB)\n    dh = im.shape[0]\n    dw = im.shape[1]\n\n    path = f\"/kaggle/labels/video_{vid_id[k]}_{seq_id[k]}.txt\"\n    content = open(path, \"r\").read()\n    txt = content.split(\" \")[1:]\n    num = len(txt) // 4\n    no_boxes = num\n    \n    num = 0\n    i = num\n    while i < no_boxes:\n        num = 4\n        i = i + num\n        tmp = txt[:i]\n        x, y, w, h = tmp[-4:]\n        \n        x = float(x)\n        y = float(y)\n        w = float(w)\n        h = float(h)\n\n        l, r, t, b = int((x - w / 2) * dw), int((x + w / 2) * dw), int((y - h / 2) * dh), int((y + h / 2) * dh)\n        \n        tmp = 0\n        if l < tmp: \n            l = tmp\n        if r > dw - 1: \n            r = dw - 1\n        if t < tmp: \n            t = tmp\n        if b > dh - 1: \n            b = dh - 1\n        \n        para1, para2 = (l, t), (r, b)\n        para3 = (255, 0, 0)\n        para4 = 3\n        cv2.rectangle(im, para1, para2, para3, para4)\n\n    axs[k].imshow(im)\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-10T13:04:01.70509Z","iopub.execute_input":"2022-11-10T13:04:01.705656Z","iopub.status.idle":"2022-11-10T13:04:04.132049Z","shell.execute_reply.started":"2022-11-10T13:04:01.705618Z","shell.execute_reply":"2022-11-10T13:04:04.131148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"name = \"video_id\"\ntrain_list = [0, 2]\ntest_list = [1]\ntrain_data = train[train[name].isin(train_list)]\ntest_data = train[train[name].isin(test_list)]\n\npath_images_name = \"path_images\"\npath_labels_name = \"path_labels\"\ntmp = train_data[path_images_name]\ntrain_images = list(tmp)\ntmp = train_data[path_labels_name]\ntrain_labels = list(tmp)\n\ntmp = test_data[path_images_name]\ntest_images = list(tmp)\ntmp = test_data[path_labels_name]\ntest_labels = list(tmp)\n\n\nprint(\"The number of train images is:\", len(train_data))\nprint(\"The number of test images is:\", len(test_data))","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:35:58.833492Z","iopub.execute_input":"2022-11-10T11:35:58.833756Z","iopub.status.idle":"2022-11-10T11:35:58.846857Z","shell.execute_reply.started":"2022-11-10T11:35:58.833727Z","shell.execute_reply":"2022-11-10T11:35:58.846061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_image_path = \"../working/train_images.txt\"\ntest_image_path = \"../working/test_images.txt\"\nwith open(train_image_path, \"w\") as f:\n    for p in train_images:\n        f.write(p)\n        f.write('\\n')\n        \nwith open(test_image_path, \"w\") as f:\n    for p in test_images:\n        f.write(p)\n        f.write('\\n')\n\nconfig = dict()\nconfig[\"path\"] = '/kaggle/working'\nconfig[\"train\"] = '/kaggle/working/train_images.txt'\nconfig[\"val\"] = '/kaggle/working/test_images.txt'\nconfig[\"nc\"] = 1\nconfig[\"names\"] = ['cots']\n\ncots_yaml_path = \"../working/cots.yaml\"\nwith open(cots_yaml_path, \"w\") as f:\n    yaml.dump(config, f, default_flow_style=False)\n\nwork_path = \"../working\"\nos.listdir(work_path)","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:42:57.986342Z","iopub.execute_input":"2022-11-10T11:42:57.986613Z","iopub.status.idle":"2022-11-10T11:42:58.003865Z","shell.execute_reply.started":"2022-11-10T11:42:57.986584Z","shell.execute_reply":"2022-11-10T11:42:58.003181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%cd /kaggle/working     \n!cp -r /kaggle/input/yolov5-lib-ds /kaggle/working/yolov5     \n%cd yolov5     \n%pip install -qr requirements.txt   \n\nfrom yolov5 import utils\ndisplay = utils.notebook_init()","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:43:32.670689Z","iopub.execute_input":"2022-11-10T11:43:32.670955Z","iopub.status.idle":"2022-11-10T11:43:44.821142Z","shell.execute_reply.started":"2022-11-10T11:43:32.670924Z","shell.execute_reply":"2022-11-10T11:43:44.820221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"MODEL = \"yolov5s\"\nPROJECT = \"GreatBarrierReef\"\nRUN_NAME = f\"{MODEL}_size{500}_epochs{3}_batch{4}_simple\"\nCOTS_TAML = \"/kaggle/working/cots.yaml\"","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:47:15.210733Z","iopub.execute_input":"2022-11-10T11:47:15.211143Z","iopub.status.idle":"2022-11-10T11:47:15.220618Z","shell.execute_reply.started":"2022-11-10T11:47:15.211104Z","shell.execute_reply":"2022-11-10T11:47:15.219877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!wandb off\n!python train.py --img 500 --batch 4 --epochs 3 --data /kaggle/working/cots.yaml\\\n                --weights {MODEL}.pt\\\n                --workers 0\\\n                --project {PROJECT}\\\n                --name {RUN_NAME}\\\n                --exist-ok","metadata":{"execution":{"iopub.status.busy":"2022-11-10T11:47:50.237644Z","iopub.execute_input":"2022-11-10T11:47:50.238006Z","iopub.status.idle":"2022-11-10T12:09:44.121374Z","shell.execute_reply.started":"2022-11-10T11:47:50.237965Z","shell.execute_reply":"2022-11-10T12:09:44.120474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cd /kaggle/working/yolov5\n!ls {PROJECT}/{RUN_NAME}","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:47:29.648691Z","iopub.execute_input":"2022-11-10T12:47:29.648989Z","iopub.status.idle":"2022-11-10T12:47:31.648411Z","shell.execute_reply.started":"2022-11-10T12:47:29.648957Z","shell.execute_reply":"2022-11-10T12:47:31.647516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"output_dir = f\"{PROJECT}/{RUN_NAME}\"\nplt.figure(figsize = (15,15))\nplt.axis('off')\nplt.imshow(plt.imread(f'{output_dir}/results.png'))","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:47:33.945653Z","iopub.execute_input":"2022-11-10T12:47:33.945949Z","iopub.status.idle":"2022-11-10T12:47:34.834745Z","shell.execute_reply.started":"2022-11-10T12:47:33.945909Z","shell.execute_reply":"2022-11-10T12:47:34.834057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(3, 2, figsize = (2*7,3*4), constrained_layout = True)\nfor row in range(3):\n    ax[row][0].imshow(plt.imread(f'{output_dir}/val_batch{row}_labels.jpg'))\n    ax[row][0].set_xticks([])\n    ax[row][0].set_yticks([])\n    ax[row][0].set_title(f'{output_dir}/val_batch{row}_labels.jpg', fontsize = 12)\n    \n    ax[row][1].imshow(plt.imread(f'{output_dir}/val_batch{row}_pred.jpg'))\n    ax[row][1].set_xticks([])\n    ax[row][1].set_yticks([])\n    ax[row][1].set_title(f'{output_dir}/val_batch{row}_pred.jpg', fontsize = 12)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:47:40.315688Z","iopub.execute_input":"2022-11-10T12:47:40.315965Z","iopub.status.idle":"2022-11-10T12:47:42.298745Z","shell.execute_reply.started":"2022-11-10T12:47:40.315935Z","shell.execute_reply":"2022-11-10T12:47:42.298065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas\ncsv_path = f'{output_dir}/results.csv'\nresults_csv = pd.read_csv(csv_path)\nresults_csv.head()\nresults_csv.keys()","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:52:51.367955Z","iopub.execute_input":"2022-11-10T12:52:51.36822Z","iopub.status.idle":"2022-11-10T12:52:51.379267Z","shell.execute_reply.started":"2022-11-10T12:52:51.36819Z","shell.execute_reply":"2022-11-10T12:52:51.37842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"precision:\", results_csv['   metrics/precision'].mean())\nprint(\"recall:\", results_csv['      metrics/recall'].mean())","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:54:33.678788Z","iopub.execute_input":"2022-11-10T12:54:33.679073Z","iopub.status.idle":"2022-11-10T12:54:33.684798Z","shell.execute_reply.started":"2022-11-10T12:54:33.67904Z","shell.execute_reply":"2022-11-10T12:54:33.684051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_pt_path = \"../input/reef-baseline-fold12\"\nbest_pt_path = best_pt_path + \"/\" + \"l6_3600_uflip_vm5_f12_up\"\nbest_pt_path = best_pt_path + \"/\" + \"f1\"\nbest_pt_path = best_pt_path + \"/\" + \"best.pt\"\nMODEL_PATH = best_pt_path\nset_conf = 0.01\nset_iou = 0.5\n\nyolov5_lib_ds_path = \"../input/yolov5-lib-ds\"\npara1 = \"custom\"\npara2 = \"local\"\nmodel = torch.hub.load(yolov5_lib_ds_path, para1,\n                       path=MODEL_PATH,\n                       source=para2, \n                       force_reload=True)\n\n\nmodel.conf = set_conf\nmodel.iou = set_iou","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:22:57.510437Z","iopub.execute_input":"2022-11-10T12:22:57.511262Z","iopub.status.idle":"2022-11-10T12:23:01.779023Z","shell.execute_reply.started":"2022-11-10T12:22:57.511211Z","shell.execute_reply":"2022-11-10T12:23:01.778275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pathlib import Path\nUltralytics_path = Path(\"/root/.config/Ultralytics\")\nUltralytics_path.mkdir(parents=True, exist_ok=True)\n# !mkdir -p /root/.config/Ultralytics\n\n!cp /kaggle/input/yolov5-font/Arial.ttf /root/.config/Ultralytics/","metadata":{"execution":{"iopub.status.busy":"2022-11-10T12:28:45.170271Z","iopub.execute_input":"2022-11-10T12:28:45.17058Z","iopub.status.idle":"2022-11-10T12:28:46.192208Z","shell.execute_reply.started":"2022-11-10T12:28:45.170547Z","shell.execute_reply":"2022-11-10T12:28:46.191041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import greatbarrierreef\nfrom pathlib import Path\nimport os\ntmp = greatbarrierreef.make_env()\nenv = tmp\ntmp = env.iter_test()\niter_test = tmp\n\nfor k, (image, sample_prediction_df) in enumerate(tqdm(iter_test)):\n    \n    annotation = \"\"\n    size = 3600\n    augment_flag = True\n    prediction = model(image, size=size, augment=augment_flag)\n    prediction_object = prediction.pandas()\n    bounding_boxes = prediction_object.xyxy[0]\n    shape = bounding_boxes.shape[0]\n    print(\"The prediction object is :\", prediction_object)\n    print(\"The bounding boxes is :\", bounding_boxes)\n    print(\"The shape is :\", shape)\n    \n    if shape == 0:\n        annotation = \"\"\n    else:\n        iterrows = bounding_boxes.iterrows()\n        for k, row in iterrows:\n            threshold = 0.15\n            if row.confidence > threshold:\n                annotation += \"{} {} {} {} {}\".format(row.confidence, int(row.xmin), int(row.ymin), int(row.xmax-row.xmin), int(row.ymax-row.ymin))\n    \n    tmp = annotation.strip()\n    sample_prediction_df['annotations'] = tmp\n    \n    env.predict(sample_prediction_df)","metadata":{"execution":{"iopub.status.busy":"2022-11-10T13:05:37.270134Z","iopub.execute_input":"2022-11-10T13:05:37.270415Z","iopub.status.idle":"2022-11-10T13:05:37.283277Z","shell.execute_reply.started":"2022-11-10T13:05:37.270385Z","shell.execute_reply":"2022-11-10T13:05:37.282436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}