{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":29876,"databundleVersionId":2468249,"sourceType":"competition"}],"dockerImageVersionId":31041,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"%cd /kaggle\n%ls","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:29:13.509844Z","iopub.execute_input":"2025-07-04T10:29:13.510361Z","iopub.status.idle":"2025-07-04T10:29:13.637608Z","shell.execute_reply.started":"2025-07-04T10:29:13.51032Z","shell.execute_reply":"2025-07-04T10:29:13.636673Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!mkdir training\n%cd training","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:29:13.731414Z","iopub.execute_input":"2025-07-04T10:29:13.731946Z","iopub.status.idle":"2025-07-04T10:29:13.853749Z","shell.execute_reply.started":"2025-07-04T10:29:13.731894Z","shell.execute_reply":"2025-07-04T10:29:13.852884Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git clone https://github.com/ultralytics/yolov5\n%cd yolov5\n!pip install -r requirements.txt\n!pip install torch==2.5.1 torchvision==0.20.1\n\nimport torch\nimport torchvision\n\nprint(f\"Setup complete. Using torch {torch.__version__}, torchvision {torchvision.__version__}\\\n({torch.cuda.get_device_properties(0).name if torch.cuda.is_available() else 'CPU'})\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:29:14.196771Z","iopub.execute_input":"2025-07-04T10:29:14.197048Z","iopub.status.idle":"2025-07-04T10:31:57.671311Z","shell.execute_reply.started":"2025-07-04T10:29:14.197018Z","shell.execute_reply":"2025-07-04T10:31:57.670652Z"},"collapsed":true,"jupyter":{"outputs_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nfrom tqdm import tqdm\nimport json\nimport yaml\nfrom shutil import copyfile\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:32:19.029913Z","iopub.execute_input":"2025-07-04T10:32:19.030362Z","iopub.status.idle":"2025-07-04T10:32:20.589217Z","shell.execute_reply.started":"2025-07-04T10:32:19.030333Z","shell.execute_reply":"2025-07-04T10:32:20.58866Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Install W&B \n%pip install -q --upgrade wandb\n# Login with token, follow with the guide\nimport wandb\nwandb.login(key='fe40802ec2afa866689bc12dd17c766df9326b29')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:32:22.669192Z","iopub.execute_input":"2025-07-04T10:32:22.66964Z","iopub.status.idle":"2025-07-04T10:32:50.544606Z","shell.execute_reply.started":"2025-07-04T10:32:22.669617Z","shell.execute_reply":"2025-07-04T10:32:50.544004Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"json_file_path = '/kaggle/input/cowboyoutfits/train.json'\ndata = json.load(open(json_file_path, 'r'))\n\nyolo_anno_path = '/kaggle/training/yolo_anno/'\nif not os.path.exists(yolo_anno_path):\n    os.makedirs(yolo_anno_path)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:11.483772Z","iopub.execute_input":"2025-07-04T10:33:11.484332Z","iopub.status.idle":"2025-07-04T10:33:11.540271Z","shell.execute_reply.started":"2025-07-04T10:33:11.484301Z","shell.execute_reply":"2025-07-04T10:33:11.539682Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data['categories'] # ['info', 'images'(3062),\n                         # 'annotations'(5594), 'categories'(5)]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:13.355206Z","iopub.execute_input":"2025-07-04T10:33:13.355492Z","iopub.status.idle":"2025-07-04T10:33:13.36075Z","shell.execute_reply.started":"2025-07-04T10:33:13.35547Z","shell.execute_reply":"2025-07-04T10:33:13.359965Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cate_id_map = {}\nfor i, cate in enumerate(data['categories']):\n    cate_id_map[cate['id']] = i\ncate_id_map","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:13.555676Z","iopub.execute_input":"2025-07-04T10:33:13.555888Z","iopub.status.idle":"2025-07-04T10:33:13.560658Z","shell.execute_reply.started":"2025-07-04T10:33:13.555869Z","shell.execute_reply":"2025-07-04T10:33:13.560103Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data['annotations'][0] # ['info', 'images'(3062),\n                         # 'annotations'(5594), 'categories'(5)]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:14.15333Z","iopub.execute_input":"2025-07-04T10:33:14.153573Z","iopub.status.idle":"2025-07-04T10:33:14.158524Z","shell.execute_reply.started":"2025-07-04T10:33:14.153554Z","shell.execute_reply":"2025-07-04T10:33:14.15778Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def cc2yolo_bbox(img_width, img_height, bbox):\n    # cc [x_min, y_min, w, h] --> yolo [x_center, y_center, w, h]%\n    dw = 1 / img_width\n    dh = 1 / img_height\n    x = bbox[0] + bbox[2] / 2\n    y = bbox[1] + bbox[3] / 2\n\n    return (x * dw, y * dh, bbox[2] * dw, bbox[3] * dh)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:14.525759Z","iopub.execute_input":"2025-07-04T10:33:14.526031Z","iopub.status.idle":"2025-07-04T10:33:14.530229Z","shell.execute_reply.started":"2025-07-04T10:33:14.526012Z","shell.execute_reply":"2025-07-04T10:33:14.529677Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data['images'][0] # ['info', 'images'(3062),\n                         # 'annotations'(5594), 'categories'(5)]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:16.324066Z","iopub.execute_input":"2025-07-04T10:33:16.324375Z","iopub.status.idle":"2025-07-04T10:33:16.329686Z","shell.execute_reply.started":"2025-07-04T10:33:16.324354Z","shell.execute_reply":"2025-07-04T10:33:16.32889Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"f = open('/kaggle/training/train.csv','w')\nf.write('id,file_name\\n')\nfor i in tqdm(range(len(data['images']))):\n    filename = data['images'][i]['file_name']\n    img_width = data['images'][i]['width']\n    img_height = data['images'][i]['height']\n    img_id = data['images'][i]['id']\n    yolo_txt_name = filename.split('.')[0] + '.txt'\n    \n    f.write('{},{}\\n'.format(img_id, filename))\n    yolo_txt_file = open(os.path.join(yolo_anno_path, yolo_txt_name), 'w')\n    \n    for anno in data['annotations']:\n        if anno['image_id'] == img_id:\n            yolo_bbox = cc2yolo_bbox(img_width, img_height, anno['bbox'])\n            yolo_txt_file.write(f'{cate_id_map[anno[\"category_id\"]]} {yolo_bbox[0]} {yolo_bbox[1]} {yolo_bbox[2]} {yolo_bbox[3]}\\n')\n    yolo_txt_file.close()\nf.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:16.501404Z","iopub.execute_input":"2025-07-04T10:33:16.501608Z","iopub.status.idle":"2025-07-04T10:33:18.391054Z","shell.execute_reply.started":"2025-07-04T10:33:16.501592Z","shell.execute_reply":"2025-07-04T10:33:18.390499Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/training/train.csv')\ntrain.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:20.206977Z","iopub.execute_input":"2025-07-04T10:33:20.207276Z","iopub.status.idle":"2025-07-04T10:33:20.245209Z","shell.execute_reply.started":"2025-07-04T10:33:20.20722Z","shell.execute_reply":"2025-07-04T10:33:20.24463Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df, valid_df = train_test_split(train, test_size=0.1, random_state=233)\n\nprint(f\"total images: {len(train)}, train images: {len(train_df)}, valid images: {len(valid_df)}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:20.369092Z","iopub.execute_input":"2025-07-04T10:33:20.369578Z","iopub.status.idle":"2025-07-04T10:33:20.378931Z","shell.execute_reply.started":"2025-07-04T10:33:20.369556Z","shell.execute_reply":"2025-07-04T10:33:20.378218Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.loc[:, 'split'] = \"train\"\nvalid_df.loc[:, 'split'] = \"valid\"\ndf = pd.concat([train_df, valid_df]).reset_index(drop=True)\ndf.sample(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:20.546577Z","iopub.execute_input":"2025-07-04T10:33:20.546752Z","iopub.status.idle":"2025-07-04T10:33:20.561868Z","shell.execute_reply.started":"2025-07-04T10:33:20.546738Z","shell.execute_reply":"2025-07-04T10:33:20.56117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/training\nos.makedirs('/kaggle/training/cowboy/images/train', exist_ok=True)\nos.makedirs('/kaggle/training/cowboy/images/valid', exist_ok=True)\n\nos.makedirs('/kaggle/training/cowboy/labels/train', exist_ok=True)\nos.makedirs('/kaggle/training/cowboy/labels/valid', exist_ok=True)\n%ls","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:21.487388Z","iopub.execute_input":"2025-07-04T10:33:21.48765Z","iopub.status.idle":"2025-07-04T10:33:21.639859Z","shell.execute_reply.started":"2025-07-04T10:33:21.48763Z","shell.execute_reply":"2025-07-04T10:33:21.638902Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for index, row in tqdm(df.iterrows()):\n    name = row['file_name'].split('.')[0]\n    is_train = row['split']\n    copyfile(f\"/kaggle/input/cowboyoutfits/images/{name}.jpg\",\n             f\"/kaggle/training/cowboy/images/{is_train}/{name}.jpg\")\n    copyfile(f\"/kaggle/training/yolo_anno/{name}.txt\",\n             f\"/kaggle/training/cowboy/labels/{is_train}/{name}.txt\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:33:21.964375Z","iopub.execute_input":"2025-07-04T10:33:21.964642Z","iopub.status.idle":"2025-07-04T10:33:59.031535Z","shell.execute_reply.started":"2025-07-04T10:33:21.964617Z","shell.execute_reply":"2025-07-04T10:33:59.030798Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_yaml = dict(\n    train = '../cowboy/images/train',\n    val = '../cowboy/images/valid',\n    nc = 5,\n    names = ['belt', 'sunglasses', 'boot', 'cowboy_hat', 'jacket']\n)\n\nwith open('/kaggle/training/yolov5/data/data.yaml', 'w') as outfile:\n    yaml.dump(data_yaml, outfile, default_flow_style=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T10:34:20.635961Z","iopub.execute_input":"2025-07-04T10:34:20.636608Z","iopub.status.idle":"2025-07-04T10:34:20.641837Z","shell.execute_reply.started":"2025-07-04T10:34:20.636582Z","shell.execute_reply":"2025-07-04T10:34:20.641116Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model3_yaml = dict(\n    nc = 5,  # number of classes\n    depth_multiple = 0.67,  # model depth multiple\n    width_multiple = 0.75,  # layer channel multiple\n    anchors = 3,  # 这里把默认的anchors配置改成了3以启用autoanchor, 获取针对自己训练时的img_size的更优质的anchor size\n    \n    # YOLOv5 backbone\n    backbone =\n      # [from, number, module, args]\n      [\n        [-1, 1, 'Conv', [64, 6, 2, 2]], # 0-P1/2\n        [-1, 1, 'Conv', [128, 3, 2]], # 1-P2/4\n        [-1, 3, 'C3', [128]],\n        [-1, 1, 'Conv', [256, 3, 2]], # 3-P3/8\n        [-1, 6, 'C3', [256]],\n        [-1, 1, 'Conv', [512, 3, 2]], # 5-P4/16\n        [-1, 9, 'C3', [512]],\n        [-1, 1, 'Conv', [1024, 3, 2]], # 7-P5/32\n        [-1, 3, 'C3TR', [1024]],\n        [-1, 1, 'SPPF', [1024, 5]], # 9\n      ],\n\n    # YOLOv5 head\n    head =\n      [\n        [-1, 1, 'Conv', [512, 1, 1]],\n        [-1, 1, 'nn.Upsample', [None, 2, \"nearest\"]],\n        [[-1, 6], 1, 'Concat', [1]], # cat backbone P4\n        [-1, 3, 'C3', [512, False]], # 13\n    \n        [-1, 1, 'Conv', [256, 1, 1]],\n        [-1, 1, 'nn.Upsample', [None, 2, \"nearest\"]],\n        [[-1, 4], 1, 'Concat', [1]], # cat backbone P3\n        [-1, 3, 'C3', [256, False]], # 17 (P3/8-small)\n    \n        [-1, 1, 'Conv', [256, 3, 2]],\n        [[-1, 14], 1, 'Concat', [1]], # cat head P4\n        [-1, 3, 'C3', [512, False]], # 20 (P4/16-medium)\n    \n        [-1, 1, 'Conv', [512, 3, 2]],\n        [[-1, 10], 1, 'Concat', [1]], # cat head P5\n        [-1, 3, 'C3', [1024, False]], # 23 (P5/32-large)\n    \n        [[17, 20, 23], 1, 'Detect', ['nc', 'anchors']], # Detect(P3, P4, P5)\n      ],\n    )\nwith open('/kaggle/training/yolov5/models/yolov5m-transformer.yaml', 'w') as f:\n    yaml.dump(model3_yaml, f, default_flow_style=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T12:03:20.349589Z","iopub.execute_input":"2025-07-04T12:03:20.350169Z","iopub.status.idle":"2025-07-04T12:03:20.361011Z","shell.execute_reply.started":"2025-07-04T12:03:20.350142Z","shell.execute_reply":"2025-07-04T12:03:20.360426Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"hyp_yaml = dict(\n    lr0 = 0.01,  # initial learning rate (SGD=1E-2, Adam=1E-3)\n    lrf = 0.16,  # final OneCycleLR learning rate (lr0 * lrf)\n    momentum = 0.937,  # SGD momentum/Adam beta1\n    weight_decay = 0.0005,  # optimizer weight decay 5e-4\n    warmup_epochs = 3.0,  # warmup epochs (fractions ok)\n    warmup_momentum = 0.8,  # warmup initial momentum\n    warmup_bias_lr = 0.1,  # warmup initial bias lr\n    box = 0.05,  # box loss gain\n    cls = 0.3,  # cls loss gain\n    cls_pw = 1.0,  # cls BCELoss positive_weight\n    obj = 0.7,  # obj loss gain (scale with pixels)\n    obj_pw = 1.0,  # obj BCELoss positive_weight\n    iou_t = 0.20,  # IoU training threshold\n    anchor_t = 4.0,  # anchor-multiple threshold\n    fl_gamma = 0.0,  # focal loss gamma (efficientDet default gamma=1.5)\n    hsv_h = 0.015,  # image HSV-Hue augmentation (fraction)\n    hsv_s = 0.7,  # image HSV-Saturation augmentation (fraction)\n    hsv_v = 0.4,  # image HSV-Value augmentation (fraction)\n    degrees = 0.0,  # image rotation (+/- deg)\n    translate = 0.1,  # image translation (+/- fraction)\n    scale = 0.9,  # image scale (+/- gain)\n    shear = 0.0,  # image shear (+/- deg)\n    perspective = 0.0,  # image perspective (+/- fraction), range 0-0.001\n    flipud = 0.0,  # image flip up-down (probability)\n    fliplr = 0.5,  # image flip left-right (probability)\n    mosaic = 1.0,  # image mosaic (probability)\n    mixup = 0.1,  # image mixup (probability)\n    copy_paste = 0.1  # segment copy-paste (probability)\n    )\n\n\nwith open('/kaggle/training/yolov5/data/hyps/my_hyp_config.yaml', 'w') as f:\n    yaml.dump(hyp_yaml, f, default_flow_style=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T11:50:11.497184Z","iopub.execute_input":"2025-07-04T11:50:11.497501Z","iopub.status.idle":"2025-07-04T11:50:11.504842Z","shell.execute_reply.started":"2025-07-04T11:50:11.497478Z","shell.execute_reply":"2025-07-04T11:50:11.50421Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"BATCH_SIZE = 16\nEPOCHS = 64\nMODEL = 'yolov5m.pt'\nworkers = 4\npath = f'{MODEL}_BS_{BATCH_SIZE}_EP_{EPOCHS}'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T12:03:28.736125Z","iopub.execute_input":"2025-07-04T12:03:28.736803Z","iopub.status.idle":"2025-07-04T12:03:28.740489Z","shell.execute_reply.started":"2025-07-04T12:03:28.736779Z","shell.execute_reply":"2025-07-04T12:03:28.739763Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/training/yolov5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T11:50:15.84101Z","iopub.execute_input":"2025-07-04T11:50:15.841316Z","iopub.status.idle":"2025-07-04T11:50:15.846027Z","shell.execute_reply.started":"2025-07-04T11:50:15.841294Z","shell.execute_reply":"2025-07-04T11:50:15.845443Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --weights {MODEL} \\\n                 --data data.yaml \\\n                 --batch-size {BATCH_SIZE} \\\n                 --cfg yolov5m.yaml \\\n                 --hyp data/hyps/my_hyp_config.yaml \\\n                 --save-period 4 \\\n                 --project /kaggle/working/kaggle-cowboy \\\n                 --name {path} \\\n                 --cache --exist-ok --multi-scale \\\n                 --workers {workers}  --epochs {EPOCHS} ","metadata":{"trusted":true,"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"valid_df = pd.read_csv('/kaggle/input/cowboyoutfits/valid.csv')\ntest_df = pd.read_csv('/kaggle/input/cowboyoutfits/test.csv')\nvalid_df.head()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"os.makedirs('/kaggle/inference/valid', exist_ok=True)\nos.makedirs('/kaggle/inference/test', exist_ok=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:43:42.200551Z","iopub.execute_input":"2025-07-04T08:43:42.201289Z","iopub.status.idle":"2025-07-04T08:43:42.205152Z","shell.execute_reply.started":"2025-07-04T08:43:42.201265Z","shell.execute_reply":"2025-07-04T08:43:42.204639Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in tqdm(range(len(valid_df))):\n    row = valid_df.loc[i]\n    name = row.file_name.split('.')[0]\n    copyfile(f'/kaggle/input/cowboyoutfits/images/{name}.jpg', f'/kaggle/inference/valid/{name}.jpg')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:44:15.491805Z","iopub.execute_input":"2025-07-04T08:44:15.49209Z","iopub.status.idle":"2025-07-04T08:44:28.126313Z","shell.execute_reply.started":"2025-07-04T08:44:15.492068Z","shell.execute_reply":"2025-07-04T08:44:28.125569Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in tqdm(range(len(test_df))):\n    row = valid_df.loc[i]\n    name = row.file_name.split('.')[0]\n    copyfile(f'/kaggle/input/cowboyoutfits/images/{name}.jpg', f'/kaggle/inference/test/{name}.jpg')","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"VALID_PATH = '/kaggle/inference/valid/'\nTEST_PATH = '/kaggle/inference/test/'\nMODEL_PATH = f'/kaggle/working/kaggle-cowboy/{path}/weights/best.pt'\nIMAGE_PATH = '/kaggle/input/cowboyoutfits/images/'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:51:00.48609Z","iopub.execute_input":"2025-07-04T08:51:00.486819Z","iopub.status.idle":"2025-07-04T08:51:00.490284Z","shell.execute_reply.started":"2025-07-04T08:51:00.486794Z","shell.execute_reply":"2025-07-04T08:51:00.489339Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# !python detect.py --weights {MODEL_PATH} \\\n#                   --source {VALID_PATH} \\\n#                   --conf 0.546 \\\n#                   --iou-thres 0.5 \\\n#                   --save-txt \\\n#                   --save-conf \\\n#                   --augment","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:51:13.056044Z","iopub.execute_input":"2025-07-04T08:51:13.056754Z","iopub.status.idle":"2025-07-04T08:52:39.336034Z","shell.execute_reply.started":"2025-07-04T08:51:13.056732Z","shell.execute_reply":"2025-07-04T08:52:39.335295Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python detect.py --weights {MODEL_PATH} \\\n                  --source {TEST_PATH} \\\n                  --conf 0.546 \\\n                  --iou-thres 0.5 \\\n                  --save-txt \\\n                  --save-conf \\\n                  --augment","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%ls /kaggle/training/yolov5/runs/detect/exp | wc -w","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:53:11.872972Z","iopub.execute_input":"2025-07-04T08:53:11.873273Z","iopub.status.idle":"2025-07-04T08:53:12.050891Z","shell.execute_reply.started":"2025-07-04T08:53:11.873246Z","shell.execute_reply":"2025-07-04T08:53:12.050121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!zip -r /kaggle/working/detect.zip /kaggle/training/yolov5/runs/detect/exp","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T08:58:58.225088Z","iopub.execute_input":"2025-07-04T08:58:58.225777Z","iopub.status.idle":"2025-07-04T08:59:08.197338Z","shell.execute_reply.started":"2025-07-04T08:58:58.225744Z","shell.execute_reply":"2025-07-04T08:59:08.196432Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# with open('/kaggle/training/yolov5/runs/detect/exp/labels/6b2cd5ad88a78e45.txt', 'r') as file:\n#     for line in file:\n#         print(line)\n        \n# from PIL import Image\n# Image.open('/kaggle/training/yolov5/runs/detect/exp/6b2cd5ad88a78e45.jpg')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-07-04T09:33:14.727129Z","iopub.execute_input":"2025-07-04T09:33:14.727698Z","iopub.status.idle":"2025-07-04T09:33:14.843416Z","shell.execute_reply.started":"2025-07-04T09:33:14.727673Z","shell.execute_reply":"2025-07-04T09:33:14.842694Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# PRED_PATH = '/kaggle/training/yolov5/runs/detect/exp2/labels/'\n# prediction_files = os.listdir(PRED_PATH)\n# print('Number of test images with detections: ', len(prediction_files))","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}