{"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":71549,"databundleVersionId":8561470,"sourceType":"competition"},{"sourceId":9195731,"sourceType":"datasetVersion","datasetId":5559249},{"sourceId":193161758,"sourceType":"kernelVersion"}],"dockerImageVersionId":30747,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport pandas as pd\nimport numpy as np\nimport pydicom\nfrom tqdm.auto import tqdm\nimport matplotlib.pyplot as plt\nimport cv2\nimport glob","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-08-29T08:07:48.451024Z","iopub.execute_input":"2024-08-29T08:07:48.451421Z","iopub.status.idle":"2024-08-29T08:07:48.458389Z","shell.execute_reply.started":"2024-08-29T08:07:48.451389Z","shell.execute_reply":"2024-08-29T08:07:48.457053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMG_DIR = \"/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_images\"","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.460907Z","iopub.execute_input":"2024-08-29T08:07:48.461254Z","iopub.status.idle":"2024-08-29T08:07:48.478085Z","shell.execute_reply.started":"2024-08-29T08:07:48.461225Z","shell.execute_reply":"2024-08-29T08:07:48.476742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"FOLDS = [0,1,2,3,4]\nOD_INPUT_SIZE = 384\nSTD_BOX_SIZE = 20\nSAMPLE = None\nCONDITIONS = ['Left Subarticular Stenosis', 'Right Subarticular Stenosis']\nSEVERITIES = ['Normal/Mild', 'Moderate', 'Severe']\nLEVELS = ['l1_l2', 'l2_l3', 'l3_l4', 'l4_l5', 'l5_s1']\n","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.479615Z","iopub.execute_input":"2024-08-29T08:07:48.480037Z","iopub.status.idle":"2024-08-29T08:07:48.489845Z","shell.execute_reply.started":"2024-08-29T08:07:48.479994Z","shell.execute_reply":"2024-08-29T08:07:48.488553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# rm -rf val_fold0","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.491435Z","iopub.execute_input":"2024-08-29T08:07:48.491896Z","iopub.status.idle":"2024-08-29T08:07:48.501924Z","shell.execute_reply.started":"2024-08-29T08:07:48.491864Z","shell.execute_reply":"2024-08-29T08:07:48.500621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_val_df = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\ntrain_xy = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_label_coordinates.csv')\ntrain_des = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_series_descriptions.csv')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.506163Z","iopub.execute_input":"2024-08-29T08:07:48.507208Z","iopub.status.idle":"2024-08-29T08:07:48.617616Z","shell.execute_reply.started":"2024-08-29T08:07:48.507159Z","shell.execute_reply":"2024-08-29T08:07:48.616054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if SAMPLE:\n    train_val_df = train_val_df.sample(SAMPLE, random_state=2698)","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.619384Z","iopub.execute_input":"2024-08-29T08:07:48.620385Z","iopub.status.idle":"2024-08-29T08:07:48.626935Z","shell.execute_reply.started":"2024-08-29T08:07:48.620351Z","shell.execute_reply":"2024-08-29T08:07:48.625561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fold_df = pd.read_csv('/kaggle/input/lsdc-fold-split/5folds.csv')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.628681Z","iopub.execute_input":"2024-08-29T08:07:48.628989Z","iopub.status.idle":"2024-08-29T08:07:48.641849Z","shell.execute_reply.started":"2024-08-29T08:07:48.628963Z","shell.execute_reply":"2024-08-29T08:07:48.640047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_xy.head(3)","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.644401Z","iopub.execute_input":"2024-08-29T08:07:48.644934Z","iopub.status.idle":"2024-08-29T08:07:48.660349Z","shell.execute_reply.started":"2024-08-29T08:07:48.644893Z","shell.execute_reply":"2024-08-29T08:07:48.658923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_level(text):\n    for lev in ['l1_l2', 'l2_l3', 'l3_l4', 'l4_l5', 'l5_s1']:\n        if lev in text:\n            split = lev.split('_')\n            split[0] = split[0].capitalize()\n            split[1] = split[1].capitalize()\n            return '/'.join(split)\n    raise ValueError('Level not found '+ lev)\n    \ndef get_condition(text):\n    split = text.split('_')\n    for i in range(len(split)):\n        split[i] = split[i].capitalize()\n    split = split[:-2]\n    return ' '.join(split)\n#     raise ValueError('Condition not found '+ lev)","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.662165Z","iopub.execute_input":"2024-08-29T08:07:48.662555Z","iopub.status.idle":"2024-08-29T08:07:48.671836Z","shell.execute_reply.started":"2024-08-29T08:07:48.662517Z","shell.execute_reply":"2024-08-29T08:07:48.670735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_xy['condition'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.673626Z","iopub.execute_input":"2024-08-29T08:07:48.674356Z","iopub.status.idle":"2024-08-29T08:07:48.693273Z","shell.execute_reply.started":"2024-08-29T08:07:48.674308Z","shell.execute_reply":"2024-08-29T08:07:48.691829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# train_df = train_df.dropna()","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.695007Z","iopub.execute_input":"2024-08-29T08:07:48.695440Z","iopub.status.idle":"2024-08-29T08:07:48.701677Z","shell.execute_reply.started":"2024-08-29T08:07:48.695408Z","shell.execute_reply":"2024-08-29T08:07:48.700358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_df = {'study_id':[], 'condition': [], 'level':[], 'label':[]}\n\nfor i, row in train_val_df.iterrows():\n    study_id = row['study_id']\n    for k, label in row.iloc[1:].to_dict().items():\n        level = get_level(k)\n        condition = get_condition(k)\n        label_df['study_id'].append(study_id)\n        label_df['condition'].append(condition)\n        label_df['level'].append(level)\n        label_df['label'].append(label)\n#         break\n#     break\n\nlabel_df = pd.DataFrame(label_df)\nlabel_df = label_df.merge(fold_df, on='study_id')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.707644Z","iopub.execute_input":"2024-08-29T08:07:48.708642Z","iopub.status.idle":"2024-08-29T08:07:48.727506Z","shell.execute_reply.started":"2024-08-29T08:07:48.708602Z","shell.execute_reply":"2024-08-29T08:07:48.725851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_xy = train_xy.merge(train_des, how='inner', on=['study_id', 'series_id'])\nlabel_df = label_df.merge(train_xy, how='inner', on=['study_id', 'condition', 'level'])","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.729255Z","iopub.execute_input":"2024-08-29T08:07:48.729805Z","iopub.status.idle":"2024-08-29T08:07:48.780385Z","shell.execute_reply.started":"2024-08-29T08:07:48.729748Z","shell.execute_reply":"2024-08-29T08:07:48.779306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# cnt[cnt>1]","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.781883Z","iopub.execute_input":"2024-08-29T08:07:48.782218Z","iopub.status.idle":"2024-08-29T08:07:48.787525Z","shell.execute_reply.started":"2024-08-29T08:07:48.782189Z","shell.execute_reply":"2024-08-29T08:07:48.786139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def query_train_xy_row(study_id, series_id=None, instance_num=None):\n    if series_id is not None and instance_num is not None:\n        return label_df[(label_df.study_id==study_id) & (label_df.series_id==series_id) &\n            (label_df.instance_number==instance_num)]\n    elif series_id is None and instance_num is None:\n        return label_df[(label_df.study_id==study_id)]\n    else:\n        return label_df[(train_xy.study_id==study_id) & (label_df.series_id==series_id)]","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.789127Z","iopub.execute_input":"2024-08-29T08:07:48.789695Z","iopub.status.idle":"2024-08-29T08:07:48.800941Z","shell.execute_reply.started":"2024-08-29T08:07:48.789658Z","shell.execute_reply":"2024-08-29T08:07:48.799719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import os\n\n# def count_dcm_files(directory):\n#     dcm_count = 0\n#     for root, dirs, files in os.walk(directory):\n#         for file in files:\n#             if file.endswith('.dcm'):\n#                 dcm_count += 1\n#     return dcm_count\n\n# dcm_files_count = count_dcm_files(IMG_DIR)\n\n# print(f\"Number of .dcm files: {dcm_files_count}\")","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.802298Z","iopub.execute_input":"2024-08-29T08:07:48.802638Z","iopub.status.idle":"2024-08-29T08:07:48.813269Z","shell.execute_reply.started":"2024-08-29T08:07:48.802611Z","shell.execute_reply":"2024-08-29T08:07:48.811978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def read_dcm(src_path):\n    dicom_data = pydicom.dcmread(src_path)\n    image = dicom_data.pixel_array\n    image = (image - image.min()) / (image.max() - image.min() +1e-6) * 255\n    image = np.stack([image]*3, axis=-1).astype('uint8')\n    return image\n\ndef get_accronym(text):\n    split = text.split(' ')\n    return ''.join([x[0] for x in split])","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.814625Z","iopub.execute_input":"2024-08-29T08:07:48.814946Z","iopub.status.idle":"2024-08-29T08:07:48.826037Z","shell.execute_reply.started":"2024-08-29T08:07:48.814920Z","shell.execute_reply":"2024-08-29T08:07:48.824800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# study_id = 4003253 \n# series_id = 2448190387\n# instance_num = 28\n\nex = label_df.sample(1).iloc[0]\nstudy_id = ex.study_id\nseries_id = ex.series_id\ninstance_num = ex.instance_number\n\nWIDTH = 10\n\npath = os.path.join(IMG_DIR, str(study_id), str(series_id), f'{instance_num}.dcm')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.827681Z","iopub.execute_input":"2024-08-29T08:07:48.828041Z","iopub.status.idle":"2024-08-29T08:07:48.839636Z","shell.execute_reply.started":"2024-08-29T08:07:48.828013Z","shell.execute_reply":"2024-08-29T08:07:48.838425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = read_dcm(path)\n\ntmp_df = query_train_xy_row(study_id, series_id, instance_num)\nfor i, row in tmp_df.iterrows():\n    lbl = f\"{get_accronym(row['condition'])}_{row['level']}\"\n    x, y = row['x'], row['y']\n    x1 = int(x - WIDTH)\n    x2 = int(x + WIDTH)\n    y1 = int(y - WIDTH)\n    y2 = int(y + WIDTH)\n    color = None\n    if row['label'] == 'Normal/Mild':\n        color =  (0, 255, 0)\n    elif row['label'] == 'Moderate':\n        color = (255,255,0) \n    elif row['label'] == 'Severe':\n        color = (255,0,0)\n        \n    fontFace = cv2.FONT_HERSHEY_SIMPLEX\n    fontScale = 0.5\n    thickness = 1\n    cv2.rectangle(img, (x1,y1), (x2,y2), color, 2)\n    cv2.putText(img, lbl, (x1,y1), fontFace, fontScale, color, thickness, cv2.LINE_AA)\n\ntmp_df","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.840769Z","iopub.execute_input":"2024-08-29T08:07:48.841088Z","iopub.status.idle":"2024-08-29T08:07:48.880148Z","shell.execute_reply.started":"2024-08-29T08:07:48.841061Z","shell.execute_reply":"2024-08-29T08:07:48.878978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:48.881692Z","iopub.execute_input":"2024-08-29T08:07:48.882015Z","iopub.status.idle":"2024-08-29T08:07:49.162055Z","shell.execute_reply.started":"2024-08-29T08:07:48.881989Z","shell.execute_reply":"2024-08-29T08:07:49.160830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# label_df[['study_id', 'series_id']].drop_duplicates()","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.163657Z","iopub.execute_input":"2024-08-29T08:07:49.164075Z","iopub.status.idle":"2024-08-29T08:07:49.169581Z","shell.execute_reply.started":"2024-08-29T08:07:49.164038Z","shell.execute_reply":"2024-08-29T08:07:49.168230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def read_dcm(src_path):\n    dicom_data = pydicom.dcmread(src_path)\n    image = dicom_data.pixel_array\n    image = (image - image.min()) / (image.max() - image.min() +1e-6) * 255\n    image = np.stack([image]*3, axis=-1).astype('uint8')\n    return image","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.171178Z","iopub.execute_input":"2024-08-29T08:07:49.171581Z","iopub.status.idle":"2024-08-29T08:07:49.181068Z","shell.execute_reply.started":"2024-08-29T08:07:49.171551Z","shell.execute_reply":"2024-08-29T08:07:49.179874Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"filtered_df = label_df[label_df.condition.map(lambda x: x in CONDITIONS)]","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.182721Z","iopub.execute_input":"2024-08-29T08:07:49.183152Z","iopub.status.idle":"2024-08-29T08:07:49.193931Z","shell.execute_reply.started":"2024-08-29T08:07:49.183119Z","shell.execute_reply":"2024-08-29T08:07:49.192909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label2id = {}\nid2label = {}\ni = 0\nfor cond in CONDITIONS:\n    for level in LEVELS:\n        for severity in SEVERITIES:\n            cls_ = f\"{cond.lower().replace(' ', '_')}_{level}_{severity.lower()}\"\n            label2id[cls_] = i\n            id2label[i] = cls_\n            i+=1","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.195615Z","iopub.execute_input":"2024-08-29T08:07:49.196022Z","iopub.status.idle":"2024-08-29T08:07:49.206019Z","shell.execute_reply.started":"2024-08-29T08:07:49.195985Z","shell.execute_reply":"2024-08-29T08:07:49.204882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"id2label","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.207355Z","iopub.execute_input":"2024-08-29T08:07:49.207762Z","iopub.status.idle":"2024-08-29T08:07:49.220134Z","shell.execute_reply.started":"2024-08-29T08:07:49.207732Z","shell.execute_reply":"2024-08-29T08:07:49.218830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def gen_yolo_format(ann_df, phase='train'):\n    for name, group in tqdm(ann_df.groupby(['study_id', 'series_id', 'instance_number'])):\n        study_id, series_id, instance_num = name[0], name[1], name[2]\n        path = f'{IMG_DIR}/{study_id}/{series_id}/{instance_num}.dcm'\n        img = read_dcm(path)\n        H, W = img.shape[:2]\n\n        img_dir = os.path.join(OUT_DIR, 'images', phase)\n        os.makedirs(img_dir, exist_ok=True)\n        img_path = os.path.join(img_dir, f'{study_id}_{series_id}_{instance_num}.jpg')\n        cv2.imwrite(img_path, img)\n\n        ann_dir = os.path.join(OUT_DIR, 'labels', phase)\n        os.makedirs(ann_dir, exist_ok=True)\n        ann_path = os.path.join(ann_dir, f'{study_id}_{series_id}_{instance_num}.txt')\n        \n        contain_nulls = False\n        \n        with open(ann_path, 'w') as f:\n            for i, row in group.iterrows():\n                cond = row['condition']\n                level = row['level']\n                severity = row['label']\n                if pd.isnull(severity):\n                    contain_nulls = True\n                    break\n                class_label = f\"{cond.lower().replace(' ', '_')}_{level.lower().replace('/', '_')}_{severity.lower()}\"\n                class_id = label2id[class_label]\n                x_center = row['x'] / W\n                y_center = row['y'] / H\n                width = W / OD_INPUT_SIZE * STD_BOX_SIZE / W\n                height = H /  OD_INPUT_SIZE * STD_BOX_SIZE / H\n                f.write(f'{class_id} {x_center} {y_center} {width} {height}\\n')\n        \n        if not contain_nulls:\n            cv2.imwrite(img_path, img)\n#         break","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.221449Z","iopub.execute_input":"2024-08-29T08:07:49.221867Z","iopub.status.idle":"2024-08-29T08:07:49.235331Z","shell.execute_reply.started":"2024-08-29T08:07:49.221837Z","shell.execute_reply":"2024-08-29T08:07:49.234150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for FOLD in FOLDS:\n    print('Gen data fold', FOLD)\n    OUT_DIR = f'data_fold{FOLD}'\n    os.makedirs(OUT_DIR, exist_ok=True)\n    \n    train_df = filtered_df[filtered_df.fold != FOLD]\n    val_df = filtered_df[filtered_df.fold == FOLD]\n    \n    gen_yolo_format(train_df, phase='train')\n    gen_yolo_format(val_df, phase='val')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:49.236926Z","iopub.execute_input":"2024-08-29T08:07:49.237888Z","iopub.status.idle":"2024-08-29T08:07:50.938216Z","shell.execute_reply.started":"2024-08-29T08:07:49.237856Z","shell.execute_reply":"2024-08-29T08:07:50.937051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# cat  train_fold0/labels/4646740_3666319702_9.txt","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:50.939687Z","iopub.execute_input":"2024-08-29T08:07:50.940037Z","iopub.status.idle":"2024-08-29T08:07:50.945130Z","shell.execute_reply.started":"2024-08-29T08:07:50.940009Z","shell.execute_reply":"2024-08-29T08:07:50.943898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# cat val_fold0/labels/4003253_702807833_8.txt","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:50.946739Z","iopub.execute_input":"2024-08-29T08:07:50.947172Z","iopub.status.idle":"2024-08-29T08:07:50.956742Z","shell.execute_reply.started":"2024-08-29T08:07:50.947134Z","shell.execute_reply":"2024-08-29T08:07:50.955460Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # test generated annotations\n\n_IM_DIR = f'{OUT_DIR}/images/train'\n_ANN_DIR = f'{OUT_DIR}/labels/train'\nname = np.random.choice(os.listdir(_IM_DIR))[:-4]\n\nim = plt.imread(os.path.join(_IM_DIR, name+'.jpg')).copy()\nH,W = im.shape[:2]\nanns = np.loadtxt(os.path.join(_ANN_DIR, name+'.txt')).reshape(-1, 5)\n\nfor _cls, x,y,w,h in anns.tolist():\n    x *= W\n    y *= H\n    w *= W\n    h *= H\n    x1 = int(x-w/2)\n    x2 = int(x+w/2)\n    y1 = int(y-h/2)\n    y2 = int(y+h/2)\n    label = id2label[_cls]\n    \n#     if _cls == 0:\n#         c = (255,0,0)\n#     elif _cls == 1:\n#         c = (0,255,0)\n#     else:\n#         c = (255,255,0)\n    c = (0,255,255)\n\n    im = cv2.rectangle(im, (x1,y1), (x2,y2), c, 2)\n    cv2.putText(im, label, (x1,y1), fontFace, 0.3, c, 1, cv2.LINE_AA)\n\n\nplt.imshow(im)","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:50.958279Z","iopub.execute_input":"2024-08-29T08:07:50.958692Z","iopub.status.idle":"2024-08-29T08:07:51.361366Z","shell.execute_reply.started":"2024-08-29T08:07:50.958661Z","shell.execute_reply":"2024-08-29T08:07:51.360264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ls data_fold0/labels/val","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:51.362865Z","iopub.execute_input":"2024-08-29T08:07:51.363275Z","iopub.status.idle":"2024-08-29T08:07:51.368243Z","shell.execute_reply.started":"2024-08-29T08:07:51.363238Z","shell.execute_reply":"2024-08-29T08:07:51.367046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# os.path.join(_ANN_DIR, name+'.txt')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:51.374445Z","iopub.execute_input":"2024-08-29T08:07:51.374865Z","iopub.status.idle":"2024-08-29T08:07:51.379697Z","shell.execute_reply.started":"2024-08-29T08:07:51.374834Z","shell.execute_reply":"2024-08-29T08:07:51.378438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# cat 'train_fold0/labels/404602713_1230697721_12.txt'","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:51.381522Z","iopub.execute_input":"2024-08-29T08:07:51.381869Z","iopub.status.idle":"2024-08-29T08:07:51.390155Z","shell.execute_reply.started":"2024-08-29T08:07:51.381841Z","shell.execute_reply":"2024-08-29T08:07:51.388977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for k, v in id2label.items():\n    print(f'{k}: {v}')","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:51.391887Z","iopub.execute_input":"2024-08-29T08:07:51.392330Z","iopub.status.idle":"2024-08-29T08:07:51.402122Z","shell.execute_reply.started":"2024-08-29T08:07:51.392292Z","shell.execute_reply":"2024-08-29T08:07:51.400999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!zip -r -q data_fold0.zip data_fold0\n!zip -r -q data_fold1.zip data_fold1\n!zip -r -q data_fold2.zip data_fold2\n!zip -r -q data_fold3.zip data_fold3\n!zip -r -q data_fold4.zip data_fold4","metadata":{"execution":{"iopub.status.busy":"2024-08-29T08:07:51.403355Z","iopub.execute_input":"2024-08-29T08:07:51.403784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!rm -rf data_fold0\n!rm -rf data_fold1\n!rm -rf data_fold2\n!rm -rf data_fold3\n!rm -rf data_fold4","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}