{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":29653,"databundleVersionId":2420395,"sourceType":"competition"},{"sourceId":1183165,"sourceType":"datasetVersion","datasetId":672377},{"sourceId":9041737,"sourceType":"datasetVersion","datasetId":5451076}],"dockerImageVersionId":30747,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# Install the ultralytics package from GitHub\n!pip install git+https://github.com/ultralytics/ultralytics.git@main","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:41:22.384248Z","iopub.execute_input":"2024-07-26T19:41:22.384962Z","iopub.status.idle":"2024-07-26T19:41:54.701857Z","shell.execute_reply.started":"2024-07-26T19:41:22.384933Z","shell.execute_reply":"2024-07-26T19:41:54.700885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport random\nimport cv2\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom ultralytics import YOLO\nimport wandb","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:09:57.981043Z","iopub.execute_input":"2024-07-26T21:09:57.981418Z","iopub.status.idle":"2024-07-26T21:09:57.986270Z","shell.execute_reply.started":"2024-07-26T21:09:57.981386Z","shell.execute_reply":"2024-07-26T21:09:57.985091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_path = '/kaggle/input'\ndata_name = 'brain-tumor-by-plane-object-detection-main'\naxial_path = os.path.join(base_path, data_name, 'axial_t1wce_2_class')\ncoronal_path = os.path.join(base_path, data_name, 'coronal_t1wce_2_class')\nsagittal_path = os.path.join(base_path, data_name, 'sagittal_t1wce_2_class')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:20.103914Z","iopub.execute_input":"2024-07-26T19:42:20.104295Z","iopub.status.idle":"2024-07-26T19:42:20.109580Z","shell.execute_reply.started":"2024-07-26T19:42:20.104265Z","shell.execute_reply":"2024-07-26T19:42:20.108557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_files(path):\n    return os.listdir(os.path.join(path, 'images', 'test')), os.listdir(os.path.join(path, 'labels', 'test')), os.listdir(os.path.join(path, 'images', 'train')), os.listdir(os.path.join(path, 'labels', 'train'))","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:25.917434Z","iopub.execute_input":"2024-07-26T19:42:25.917816Z","iopub.status.idle":"2024-07-26T19:42:25.925391Z","shell.execute_reply.started":"2024-07-26T19:42:25.917785Z","shell.execute_reply":"2024-07-26T19:42:25.924605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"axial_test_img_files, axial_test_lb_files, axial_train_img_files, axial_train_lb_files = get_files(axial_path)\ncoronal_test_img_files, coronal_test_lb_files, coronal_train_img_files, coronal_train_lb_files = get_files(coronal_path)\nsagittal_test_img_files, sagittal_test_lb_files, sagittal_train_img_files, sagittal_train_lb_files = get_files(sagittal_path)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:27.613396Z","iopub.execute_input":"2024-07-26T19:42:27.614028Z","iopub.status.idle":"2024-07-26T19:42:27.875157Z","shell.execute_reply.started":"2024-07-26T19:42:27.613997Z","shell.execute_reply":"2024-07-26T19:42:27.874247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'{len(axial_test_img_files), len(axial_test_lb_files), len(axial_train_img_files), len(axial_train_lb_files)}')\nprint(f'{len(coronal_test_img_files), len(coronal_test_lb_files), len(coronal_train_img_files), len(coronal_train_lb_files)}')\nprint(f'{len(sagittal_test_img_files), len(sagittal_test_lb_files), len(sagittal_train_img_files), len(sagittal_train_lb_files)}')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:29.513516Z","iopub.execute_input":"2024-07-26T19:42:29.513833Z","iopub.status.idle":"2024-07-26T19:42:29.519247Z","shell.execute_reply.started":"2024-07-26T19:42:29.513807Z","shell.execute_reply":"2024-07-26T19:42:29.518413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def count_class_id(path):\n    count_1 = 0\n    count_0 = 0\n\n    # Duyệt qua tất cả các file trong thư mục\n    for filename in os.listdir(os.path.join(path, 'labels', 'train')):\n        if filename.endswith(\".txt\"):\n            file_path = os.path.join(path, 'labels', 'train', filename)\n            with open(file_path, 'r') as file:\n                class_id = file.read(1)\n                if class_id == '1':\n                    count_1 += 1\n                elif class_id == '0':\n                    count_0 += 1\n\n    print(f'Class 0: {count_0}\\nClass 1: {count_1}')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:31.895247Z","iopub.execute_input":"2024-07-26T19:42:31.895572Z","iopub.status.idle":"2024-07-26T19:42:31.902567Z","shell.execute_reply.started":"2024-07-26T19:42:31.895547Z","shell.execute_reply":"2024-07-26T19:42:31.901483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count_class_id(axial_path)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:34.230977Z","iopub.execute_input":"2024-07-26T19:42:34.231360Z","iopub.status.idle":"2024-07-26T19:42:34.940933Z","shell.execute_reply.started":"2024-07-26T19:42:34.231330Z","shell.execute_reply":"2024-07-26T19:42:34.940005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count_class_id(coronal_path)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:36.630999Z","iopub.execute_input":"2024-07-26T19:42:36.631369Z","iopub.status.idle":"2024-07-26T19:42:37.370601Z","shell.execute_reply.started":"2024-07-26T19:42:36.631337Z","shell.execute_reply":"2024-07-26T19:42:37.369662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count_class_id(sagittal_path)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:39.108004Z","iopub.execute_input":"2024-07-26T19:42:39.108821Z","iopub.status.idle":"2024-07-26T19:42:39.717085Z","shell.execute_reply.started":"2024-07-26T19:42:39.108785Z","shell.execute_reply":"2024-07-26T19:42:39.716181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def data_overview(path, data_type='train'):\n    img_files = os.listdir(os.path.join(path, 'images', data_type))\n    random_imgs = random.sample(img_files, 8)\n\n    fig, axs = plt.subplots(2, 4, figsize=(16, 5))\n\n    for i, img_file in enumerate(random_imgs):\n        row = i // 4\n        col = i % 4\n\n        img_path = os.path.join(path, 'images', data_type, img_file)\n        img = cv2.imread(img_path)\n\n        lb_file = os.path.splitext(img_file)[0] + \".txt\"\n        lb_path = os.path.join(path, 'labels', data_type, lb_file)\n        with open(lb_path, \"r\") as f:\n            lbs = f.read().strip().split(\"\\n\")\n\n        for lb in lbs:\n            class_id, x_center, y_center, width, height = map(float, lb.split())\n            x_min = int((x_center - width/2) * img.shape[1])\n            y_min = int((y_center - height/2) * img.shape[0])\n            x_max = int((x_center + width/2) * img.shape[1])\n            y_max = int((y_center + height/2) * img.shape[0])\n\n            if int(class_id) == 0:\n                cv2.rectangle(img, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)\n            else:\n                cv2.rectangle(img, (x_min, y_min), (x_max, y_max), (0, 0, 255), 2)\n\n\n        axs[row, col].set_title(f'{img_file} - class: {class_id}')\n        axs[row, col].imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\n        axs[row, col].axis('off')\n\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:41.831993Z","iopub.execute_input":"2024-07-26T19:42:41.832734Z","iopub.status.idle":"2024-07-26T19:42:41.846415Z","shell.execute_reply.started":"2024-07-26T19:42:41.832700Z","shell.execute_reply":"2024-07-26T19:42:41.845434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_overview(axial_path, 'train')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:44.325905Z","iopub.execute_input":"2024-07-26T19:42:44.326720Z","iopub.status.idle":"2024-07-26T19:42:45.301121Z","shell.execute_reply.started":"2024-07-26T19:42:44.326685Z","shell.execute_reply":"2024-07-26T19:42:45.300234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_overview(coronal_path, 'train')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:48.188718Z","iopub.execute_input":"2024-07-26T19:42:48.189400Z","iopub.status.idle":"2024-07-26T19:42:49.144351Z","shell.execute_reply.started":"2024-07-26T19:42:48.189363Z","shell.execute_reply":"2024-07-26T19:42:49.143449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_overview(sagittal_path, 'train')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:42:52.205376Z","iopub.execute_input":"2024-07-26T19:42:52.206337Z","iopub.status.idle":"2024-07-26T19:42:53.154454Z","shell.execute_reply.started":"2024-07-26T19:42:52.206300Z","shell.execute_reply":"2024-07-26T19:42:53.153563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"text = \"\"\"\npath: /kaggle/input/brain-tumor-by-plane-object-detection-main\ntrain: \n    - axial_t1wce_2_class/images/train\n    - coronal_t1wce_2_class/images/train\n    - sagittal_t1wce_2_class/images/train\nval:\n    - axial_t1wce_2_class/images/test\n    - coronal_t1wce_2_class/images/test\n    - sagittal_t1wce_2_class/images/test\n# Classes\nnc: 2\nnames: ['negative','positive']\n\"\"\"\nwith open(\"./data.yaml\", 'w') as file:\n    file.write(text)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:44:03.296799Z","iopub.execute_input":"2024-07-26T19:44:03.297165Z","iopub.status.idle":"2024-07-26T19:44:03.302687Z","shell.execute_reply.started":"2024-07-26T19:44:03.297134Z","shell.execute_reply":"2024-07-26T19:44:03.301703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!wandb disabled","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:46:52.509188Z","iopub.execute_input":"2024-07-26T19:46:52.510159Z","iopub.status.idle":"2024-07-26T19:46:54.384882Z","shell.execute_reply.started":"2024-07-26T19:46:52.510121Z","shell.execute_reply":"2024-07-26T19:46:54.383830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = YOLO('yolov9c.pt')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:43:17.846630Z","iopub.execute_input":"2024-07-26T19:43:17.847212Z","iopub.status.idle":"2024-07-26T19:43:18.971712Z","shell.execute_reply.started":"2024-07-26T19:43:17.847177Z","shell.execute_reply":"2024-07-26T19:43:18.970784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = model.train(data=\"/kaggle/working/data.yaml\", epochs=50, device=[0, 1])","metadata":{"execution":{"iopub.status.busy":"2024-07-26T19:46:57.759940Z","iopub.execute_input":"2024-07-26T19:46:57.760377Z","iopub.status.idle":"2024-07-26T20:12:32.904110Z","shell.execute_reply.started":"2024-07-26T19:46:57.760341Z","shell.execute_reply":"2024-07-26T20:12:32.903264Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_save_dir = '/kaggle/working/runs/detect/train4'\n\nplt.figure(figsize=(20, 10))\nimg = cv2.imread(os.path.join(training_save_dir, 'results.png'))\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T20:25:32.559021Z","iopub.execute_input":"2024-07-26T20:25:32.559738Z","iopub.status.idle":"2024-07-26T20:25:33.397259Z","shell.execute_reply.started":"2024-07-26T20:25:32.559702Z","shell.execute_reply":"2024-07-26T20:25:33.396257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 10))\nimg = cv2.imread(os.path.join(training_save_dir, 'confusion_matrix.png'))\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T20:30:09.431190Z","iopub.execute_input":"2024-07-26T20:30:09.431654Z","iopub.status.idle":"2024-07-26T20:30:10.708104Z","shell.execute_reply.started":"2024-07-26T20:30:09.431615Z","shell.execute_reply":"2024-07-26T20:30:10.707127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 10))\nimg = cv2.imread(os.path.join(training_save_dir, 'val_batch0_pred.jpg'))\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T20:30:53.733980Z","iopub.execute_input":"2024-07-26T20:30:53.734915Z","iopub.status.idle":"2024-07-26T20:30:54.556326Z","shell.execute_reply.started":"2024-07-26T20:30:53.734872Z","shell.execute_reply":"2024-07-26T20:30:54.555389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 10))\nimg = cv2.imread(os.path.join(training_save_dir, 'val_batch1_pred.jpg'))\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T20:31:50.059490Z","iopub.execute_input":"2024-07-26T20:31:50.060158Z","iopub.status.idle":"2024-07-26T20:31:50.864505Z","shell.execute_reply.started":"2024-07-26T20:31:50.060124Z","shell.execute_reply":"2024-07-26T20:31:50.863522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trained_model = YOLO(training_save_dir + '/weights/best.pt')\npredictions = trained_model.predict(\n    source=\"/kaggle/input/brain-tumor-classification-mri/Testing/glioma_tumor\",\n    conf=0.4, save_txt=True, save_conf=True)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T20:35:27.396508Z","iopub.execute_input":"2024-07-26T20:35:27.396929Z","iopub.status.idle":"2024-07-26T20:35:33.117487Z","shell.execute_reply.started":"2024-07-26T20:35:27.396895Z","shell.execute_reply":"2024-07-26T20:35:33.116585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions_save_dir = '/kaggle/working/' + predictions[0].save_dir + '/labels'","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:10:45.778017Z","iopub.execute_input":"2024-07-26T21:10:45.778950Z","iopub.status.idle":"2024-07-26T21:10:45.783235Z","shell.execute_reply.started":"2024-07-26T21:10:45.778916Z","shell.execute_reply":"2024-07-26T21:10:45.782160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def draw_bbox(file_path, filename, img):\n    with open(os.path.join(file_path, f'{filename}.txt'),'r') as f:\n        labels = f.readlines()\n        labels = labels[0].split(' ')\n        f.close()\n\n    tumor_class, x, y, w, h = int(labels[0]), float(labels[1]), float(labels[2]), float(labels[3]), float(labels[4])\n    x_pt1 = int((x - w/2) * img.shape[1])\n    y_pt1 = int((y - h/2) * img.shape[0])\n    x_pt2 = int((x + w/2) * img.shape[1])\n    y_pt2 = int((y + h/2) * img.shape[0])\n\n    if tumor_class == 0:\n        colour = (255, 0, 0)\n        label = 'Negative'\n    else:\n        colour = (0, 255, 0)\n        label = 'Positive'\n    if len(labels) > 5:\n        prob = float(labels[5])\n        prob = round(prob, 1)\n        prob = str(prob)\n        label = label + ' ' + prob\n\n    cv2.rectangle(img, (x_pt1, y_pt1), (x_pt2, y_pt2), colour, 2)\n    cv2.putText(img, label, (x_pt1, y_pt1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.6, colour, 1)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:38:55.207404Z","iopub.execute_input":"2024-07-26T21:38:55.207826Z","iopub.status.idle":"2024-07-26T21:38:55.220702Z","shell.execute_reply.started":"2024-07-26T21:38:55.207795Z","shell.execute_reply":"2024-07-26T21:38:55.219612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"files = os.listdir(predictions_save_dir)\nrandom_file = random.sample(files, 16)\nfig, axes = plt.subplots(4, 4, figsize=(16, 16))\nfor i, file in enumerate(random_file):\n    row = i // 4\n    col = i % 4\n    \n    file_name = os.path.splitext(file)[0]\n\n    img_pred = cv2.imread(os.path.join('/kaggle/input/brain-tumor-classification-mri/Testing/glioma_tumor', f'{file_name}.jpg'), 1)\n    img_pred = cv2.cvtColor(img_pred, cv2.COLOR_BGR2RGB)\n    draw_bbox(predictions_save_dir, file_name, img_pred)\n\n    axes[row, col].imshow(img_pred)\n    axes[row, col].set_title(file)\n    axes[row, col].axis('off')\n\n# plt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:38:57.477927Z","iopub.execute_input":"2024-07-26T21:38:57.478451Z","iopub.status.idle":"2024-07-26T21:38:59.350460Z","shell.execute_reply.started":"2024-07-26T21:38:57.478408Z","shell.execute_reply":"2024-07-26T21:38:59.349271Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pydicom\ndef dicom_to_video(dicom_folder, output_video_path, frame_rate=10):\n    # Lấy danh sách các file DICOM trong thư mục\n    dicom_files = [f for f in os.listdir(dicom_folder) if f.endswith('.dcm')]\n    dicom_files.sort()  # Đảm bảo các file được sắp xếp theo thứ tự\n\n    # Đọc file DICOM đầu tiên để lấy kích thước ảnh\n    sample_dicom_path = os.path.join(dicom_folder, dicom_files[0])\n    sample_dicom = pydicom.dcmread(sample_dicom_path)\n    sample_image = sample_dicom.pixel_array\n    height, width = sample_image.shape\n\n    # Định nghĩa codec và tạo VideoWriter object\n    fourcc = cv2.VideoWriter_fourcc(*'XVID')\n    video_writer = cv2.VideoWriter(output_video_path, fourcc, frame_rate, (width, height), False)\n\n    # Đọc từng file DICOM và ghi vào video\n    for dicom_file in dicom_files:\n        dicom_path = os.path.join(dicom_folder, dicom_file)\n        dicom_data = pydicom.dcmread(dicom_path)\n        image = dicom_data.pixel_array\n        normalized_image = cv2.normalize(image, None, 0, 255, cv2.NORM_MINMAX)\n        uint8_image = normalized_image.astype('uint8')\n        video_writer.write(uint8_image)\n\n    # Giải phóng VideoWriter object\n    video_writer.release()\n    print(f'Video đã được lưu tại {output_video_path}')","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:11:13.062050Z","iopub.execute_input":"2024-07-26T21:11:13.062503Z","iopub.status.idle":"2024-07-26T21:11:13.071791Z","shell.execute_reply.started":"2024-07-26T21:11:13.062468Z","shell.execute_reply":"2024-07-26T21:11:13.070653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Sử dụng hàm\ndicom_folder = '/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/train/00000/FLAIR'  # Thay bằng đường dẫn tới folder chứa file DICOM\noutput_video_path = '/kaggle/working/output_video.avi'  # Đường dẫn tới file video xuất ra\ndicom_to_video(dicom_folder, output_video_path)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:13:26.347163Z","iopub.execute_input":"2024-07-26T21:13:26.348027Z","iopub.status.idle":"2024-07-26T21:13:27.901689Z","shell.execute_reply.started":"2024-07-26T21:13:26.347991Z","shell.execute_reply":"2024-07-26T21:13:27.900672Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install supervision","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:41:22.239684Z","iopub.execute_input":"2024-07-26T21:41:22.240385Z","iopub.status.idle":"2024-07-26T21:41:35.512462Z","shell.execute_reply.started":"2024-07-26T21:41:22.240349Z","shell.execute_reply":"2024-07-26T21:41:35.511242Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import supervision as sv","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:41:44.891837Z","iopub.execute_input":"2024-07-26T21:41:44.892344Z","iopub.status.idle":"2024-07-26T21:41:44.974264Z","shell.execute_reply.started":"2024-07-26T21:41:44.892306Z","shell.execute_reply":"2024-07-26T21:41:44.973494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"VIDEO_PATH = \"/kaggle/working/output_video.avi\"\ntrained_model = YOLO(training_save_dir + '/weights/best.pt')\ntrained_model.predict(source=\"/kaggle/working/output_video.avi\", conf=0.4, save_txt=True, save_conf=True)","metadata":{"execution":{"iopub.status.busy":"2024-07-26T21:52:17.961668Z","iopub.execute_input":"2024-07-26T21:52:17.962664Z","iopub.status.idle":"2024-07-26T21:52:33.028329Z","shell.execute_reply.started":"2024-07-26T21:52:17.962627Z","shell.execute_reply":"2024-07-26T21:52:33.027415Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict_video = os.listdir('/kaggle/working/runs/detect/predict2/labels')\nwith open(os.path.join('/kaggle/working/runs/detect/predict2/labels', random.choice(predict_video)), 'r') as f:\n    print(f'{f.name} {f.readlines()}')\n    f.close()","metadata":{"execution":{"iopub.status.busy":"2024-07-26T22:08:47.009232Z","iopub.execute_input":"2024-07-26T22:08:47.010187Z","iopub.status.idle":"2024-07-26T22:08:47.016884Z","shell.execute_reply.started":"2024-07-26T22:08:47.010150Z","shell.execute_reply":"2024-07-26T22:08:47.015694Z"},"trusted":true},"execution_count":null,"outputs":[]}]}