diff --git a/YOLO_+_Attention_Module.ipynb b/YOLO_+_Attention_Module.ipynb new file mode 100644 index 000000000000..65aaa2c11eb9 --- /dev/null +++ b/YOLO_+_Attention_Module.ipynb @@ -0,0 +1,6346 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "j9-s96CHWUNI", + "outputId": "c7136917-362e-41cd-ded6-253e5d8234f9" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Cloning into 'SMN-YOLOv5s'...\n", + "remote: Enumerating objects: 203, done.\u001b[K\n", + "remote: Counting objects: 100% (6/6), done.\u001b[K\n", + "remote: Compressing objects: 100% (6/6), done.\u001b[K\n", + "remote: Total 203 (delta 1), reused 1 (delta 0), pack-reused 197 (from 1)\u001b[K\n", + "Receiving objects: 100% (203/203), 55.39 MiB | 14.96 MiB/s, done.\n", + "Resolving deltas: 100% (81/81), done.\n" + ] + } + ], + "source": [ + "!git clone https://github.com/RethinkingCoding/SMN-YOLOv5s" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "tNzaduaVWaFB", + "outputId": "5a19f683-628b-43fd-ff83-015e5691c16a" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/content/SMN-YOLOv5s\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m33.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h" + ] + } + ], + "source": [ + "%cd SMN-YOLOv5s\n", + "%pip install -qr requirements.txt" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "gHtgfucyWcsl", + "outputId": "935e693e-d776-44bd-8d4e-59b4c046c501" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/content/SMN-YOLOv5s\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "print(os.getcwd())" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "GtN-pCX0Wg-I" + }, + "outputs": [], + "source": [ + "import random\n", + "\n", + "import numpy as np\n", + "import torch\n", + "\n", + "\n", + "def set_seed(seed=42):\n", + " random.seed(seed)\n", + " np.random.seed(seed)\n", + " torch.manual_seed(seed)\n", + " torch.cuda.manual_seed(seed)\n", + " torch.backends.cudnn.deterministic = True\n", + " torch.backends.cudnn.benchmark = False\n", + "\n", + "\n", + "set_seed(42)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "KtscwnpbWjD2", + "outputId": "a2625566-55cc-44b7-9ef0-90a6b7e57fc4" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting roboflow\n", + " Downloading roboflow-1.2.13-py3-none-any.whl.metadata (9.7 kB)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from roboflow) (2026.1.4)\n", + "Collecting idna==3.7 (from roboflow)\n", + " Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB)\n", + "Requirement already satisfied: cycler in /usr/local/lib/python3.12/dist-packages (from roboflow) (0.12.1)\n", + "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from roboflow) (1.4.9)\n", + "Requirement already satisfied: matplotlib in /usr/local/lib/python3.12/dist-packages (from roboflow) (3.10.0)\n", + "Requirement already satisfied: numpy>=1.18.5 in /usr/local/lib/python3.12/dist-packages (from roboflow) (2.0.2)\n", + "Collecting opencv-python-headless==4.10.0.84 (from roboflow)\n", + " Downloading opencv_python_headless-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)\n", + "Requirement already satisfied: Pillow>=7.1.2 in /usr/local/lib/python3.12/dist-packages (from roboflow) (11.3.0)\n", + "Collecting pillow-avif-plugin<2 (from roboflow)\n", + " Downloading pillow_avif_plugin-1.5.5-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (2.2 kB)\n", + "Requirement already satisfied: python-dateutil in /usr/local/lib/python3.12/dist-packages (from roboflow) (2.9.0.post0)\n", + "Requirement already satisfied: python-dotenv in /usr/local/lib/python3.12/dist-packages (from roboflow) (1.2.1)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from roboflow) (2.32.4)\n", + "Requirement already satisfied: six in /usr/local/lib/python3.12/dist-packages (from roboflow) (1.17.0)\n", + "Requirement already satisfied: urllib3>=1.26.6 in /usr/local/lib/python3.12/dist-packages (from roboflow) (2.5.0)\n", + "Requirement already satisfied: tqdm>=4.41.0 in /usr/local/lib/python3.12/dist-packages (from roboflow) (4.67.3)\n", + "Requirement already satisfied: PyYAML>=5.3.1 in /usr/local/lib/python3.12/dist-packages (from roboflow) (6.0.3)\n", + "Requirement already satisfied: requests-toolbelt in /usr/local/lib/python3.12/dist-packages (from roboflow) (1.0.0)\n", + "Collecting filetype (from roboflow)\n", + " Downloading filetype-1.2.0-py2.py3-none-any.whl.metadata (6.5 kB)\n", + "Collecting pi-heif<2 (from roboflow)\n", + " Downloading pi_heif-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (6.5 kB)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib->roboflow) (1.3.3)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib->roboflow) (4.61.1)\n", + "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib->roboflow) (26.0)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib->roboflow) (3.3.2)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->roboflow) (3.4.4)\n", + "Downloading roboflow-1.2.13-py3-none-any.whl (91 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m91.8/91.8 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading idna-3.7-py3-none-any.whl (66 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.8/66.8 kB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading opencv_python_headless-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.9/49.9 MB\u001b[0m \u001b[31m20.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading pi_heif-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.5/1.5 MB\u001b[0m \u001b[31m95.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading pillow_avif_plugin-1.5.5-cp312-cp312-manylinux_2_28_x86_64.whl (5.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.5/5.5 MB\u001b[0m \u001b[31m144.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading filetype-1.2.0-py2.py3-none-any.whl (19 kB)\n", + "Installing collected packages: pillow-avif-plugin, filetype, pi-heif, opencv-python-headless, idna, roboflow\n", + " Attempting uninstall: opencv-python-headless\n", + " Found existing installation: opencv-python-headless 4.13.0.92\n", + " Uninstalling opencv-python-headless-4.13.0.92:\n", + " Successfully uninstalled opencv-python-headless-4.13.0.92\n", + " Attempting uninstall: idna\n", + " Found existing installation: idna 3.11\n", + " Uninstalling idna-3.11:\n", + " Successfully uninstalled idna-3.11\n", + "Successfully installed filetype-1.2.0 idna-3.7 opencv-python-headless-4.10.0.84 pi-heif-1.2.0 pillow-avif-plugin-1.5.5 roboflow-1.2.13\n", + "loading Roboflow workspace...\n", + "loading Roboflow project...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Downloading Dataset Version Zip in potato-counting-1 to yolov5pytorch:: 100%|██████████| 771070/771070 [00:11<00:00, 67939.53it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "Extracting Dataset Version Zip to potato-counting-1 in yolov5pytorch:: 100%|██████████| 4838/4838 [00:04<00:00, 1090.83it/s]\n" + ] + } + ], + "source": [ + "!pip install roboflow\n", + "\n", + "from roboflow import Roboflow\n", + "\n", + "rf = Roboflow(api_key=\"SYLND05UAeOcirwZfGFJ\")\n", + "project = rf.workspace(\"potato-lxebf\").project(\"potato-counting\")\n", + "version = project.version(1)\n", + "dataset = version.download(\"yolov5\")" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "5e5MvNDtemul" + }, + "outputs": [], + "source": [ + "!WANDB_MODE=disabled WANDB_DISABLED=true" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "alZzV4VCWpK0", + "outputId": "58d96016-346a-4032-a7a7-cc43d10d4d30" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/125.7 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m125.7/125.7 kB\u001b[0m \u001b[31m8.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h" + ] + } + ], + "source": [ + "!pip -q uninstall -y albumentations\n", + "!pip -q install \"albumentations==1.3.1\"" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "FdnNtHxMfJVJ", + "outputId": "2174011c-99f0-49a8-c0dc-a24705dc664b" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Patched 4 file(s).\n", + " - /content/SMN-YOLOv5s/train.py\n", + " - /content/SMN-YOLOv5s/utils/general.py\n", + " - /content/SMN-YOLOv5s/segment/train.py\n", + " - /content/SMN-YOLOv5s/classify/train.py\n" + ] + } + ], + "source": [ + "# =========================\n", + "# PATCH — disable deterministic algorithms that crash with AdaptiveMaxPool2d (CBAM)\n", + "# =========================\n", + "import re\n", + "from pathlib import Path\n", + "\n", + "ROOT = Path(\"/content/SMN-YOLOv5s\") # adjust if your repo path differs\n", + "\n", + "py_files = list(ROOT.rglob(\"*.py\"))\n", + "patched = []\n", + "\n", + "for p in py_files:\n", + " txt = p.read_text(errors=\"ignore\")\n", + "\n", + " new = txt\n", + "\n", + " # 1) Disable strict deterministic algorithms\n", + " new = re.sub(r\"torch\\.use_deterministic_algorithms\\(\\s*True\\s*\\)\", \"torch.use_deterministic_algorithms(False)\", new)\n", + "\n", + " # 2) If init_seeds(..., deterministic=True) exists, flip it\n", + " new = re.sub(r\"(init_seeds\\([^)]*?)deterministic\\s*=\\s*True\", r\"\\1deterministic=False\", new)\n", + "\n", + " if new != txt:\n", + " p.write_text(new)\n", + " patched.append(str(p))\n", + "\n", + "print(f\"Patched {len(patched)} file(s).\")\n", + "for f in patched[:20]:\n", + " print(\" -\", f)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "mA245GCjWm5P", + "outputId": "c078998b-32ac-4899-d89a-46ed141311cf" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: WARNING ⚠️ wandb is deprecated and will be removed in a future release. See supported integrations at https://github.com/ultralytics/yolov5#integrations.\n", + "2026-02-15 09:10:02.901536: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", + "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", + "E0000 00:00:1771146602.922334 8916 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", + "E0000 00:00:1771146602.929322 8916 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", + "W0000 00:00:1771146602.948074 8916 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771146602.948102 8916 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771146602.948106 8916 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771146602.948112 8916 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (1) Create a W&B account\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (2) Use an existing W&B account\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (3) Don't visualize my results\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: Enter your choice: (30 second timeout) \n", + "\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m W&B disabled due to login timeout.\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: W&B API key is configured. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n", + "\u001b[34m\u001b[1mtrain: \u001b[0mweights=, cfg=/content/SMN-YOLOv5s/models/yolov5s-cbam.yaml, data=/content/SMN-YOLOv5s/potato-counting-1/data.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=10, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=ram, image_weights=False, device=0, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest\n", + "\u001b[34m\u001b[1mgithub: \u001b[0m⚠️ YOLOv5 is out of date by 2944 commits. Use 'git pull ultralytics master' or 'git clone https://github.com/ultralytics/yolov5' to update.\n", + "YOLOv5 🚀 704b81b1 Python-3.12.12 torch-2.9.0+cu128 CUDA:0 (Tesla T4, 14913MiB)\n", + "\n", + "\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0\n", + "\u001b[34m\u001b[1mComet: \u001b[0mrun 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet\n", + "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n", + "\n", + " from n params module arguments \n", + " 0 -1 1 3616 models.common.Conv [3, 32, 6, 2, 2] \n", + " 1 -1 1 18752 models.common.Conv [32, 64, 3, 2] \n", + " 2 -1 1 19392 models.common.C3 [64, 64, 1] \n", + " 3 -1 1 74368 models.common.Conv [64, 128, 3, 2] \n", + " 4 -1 2 117248 models.common.C3 [128, 128, 2] \n", + " 5 -1 1 296192 models.common.Conv [128, 256, 3, 2] \n", + " 6 -1 3 628992 models.common.C3 [256, 256, 3] \n", + " 7 -1 1 1182208 models.common.Conv [256, 512, 3, 2] \n", + " 8 -1 1 1187328 models.common.C3 [512, 512, 1] \n", + " 9 -1 1 32866 models.common.CBAM [512, 512] \n", + " 10 -1 1 659200 models.common.SPPF [512, 512, 5] \n", + " 11 -1 1 132352 models.common.Conv [512, 256, 1, 1] \n", + " 12 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n", + " 13 [-1, 6] 1 0 models.common.Concat [1] \n", + " 14 -1 1 364288 models.common.C3 [512, 256, 1, False] \n", + " 15 -1 1 33408 models.common.Conv [256, 128, 1, 1] \n", + " 16 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n", + " 17 [-1, 4] 1 0 models.common.Concat [1] \n", + " 18 -1 1 92032 models.common.C3 [256, 128, 1, False] \n", + " 19 -1 1 148096 models.common.Conv [128, 128, 3, 2] \n", + " 20 [-1, 15] 1 0 models.common.Concat [1] \n", + " 21 -1 1 298752 models.common.C3 [256, 256, 1, False] \n", + " 22 -1 1 591104 models.common.Conv [256, 256, 3, 2] \n", + " 23 [-1, 11] 1 0 models.common.Concat [1] \n", + " 24 -1 1 1187328 models.common.C3 [512, 512, 1, False] \n", + " 25 [18, 21, 24] 1 16182 models.yolo.Detect [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]\n", + "YOLOv5s-cbam summary: 281 layers, 7083704 parameters, 7083704 gradients, 16.0 GFLOPs\n", + "\n", + "/content/SMN-YOLOv5s/models/common.py:719: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n", + " with amp.autocast(autocast):\n", + "/content/SMN-YOLOv5s/models/common.py:719: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n", + " with amp.autocast(autocast):\n", + "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n", + "\u001b[34m\u001b[1moptimizer:\u001b[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 234 weight(decay=0.0005), 60 bias\n", + "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n", + "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /content/SMN-YOLOv5s/potato-counting-1/train/labels.cache... 2077 images, 78 backgrounds, 0 corrupt: 100% 2077/2077 [00:00\n", + " main(opt)\n", + " File \"/content/SMN-YOLOv5s/train.py\", line 536, in main\n", + " train(opt.hyp, opt, device, callbacks)\n", + " File \"/content/SMN-YOLOv5s/train.py\", line 423, in train\n", + " model=attempt_load(f, device).half(),\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/content/SMN-YOLOv5s/models/experimental.py\", line 79, in attempt_load\n", + " ckpt = torch.load(attempt_download(w), map_location='cpu') # load\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/local/lib/python3.12/dist-packages/torch/serialization.py\", line 1529, in load\n", + " raise pickle.UnpicklingError(_get_wo_message(str(e))) from None\n", + "_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, \u001b[1mdo those steps only if you trust the source of the checkpoint\u001b[0m. \n", + "\t(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.\n", + "\t(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.\n", + "\tWeightsUnpickler error: Unsupported global: GLOBAL models.yolo.DetectionModel was not an allowed global by default. Please use `torch.serialization.add_safe_globals([models.yolo.DetectionModel])` or the `torch.serialization.safe_globals([models.yolo.DetectionModel])` context manager to allowlist this global if you trust this class/function.\n", + "\n", + "Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.\n" + ] + } + ], + "source": [ + "!python train.py --img 640 --batch 16 --epochs 10 --data {dataset.location}/data.yaml --weights '' --cfg /content/SMN-YOLOv5s/models/yolov5s-cbam.yaml --cache" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "uJJqFZpDfJ27", + "outputId": "4d7b5074-62fc-48e6-f442-7b5145556394" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: WARNING ⚠️ wandb is deprecated and will be removed in a future release. See supported integrations at https://github.com/ultralytics/yolov5#integrations.\n", + "2026-02-15 09:23:11.834528: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", + "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", + "E0000 00:00:1771147391.855926 12413 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", + "E0000 00:00:1771147391.862975 12413 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", + "W0000 00:00:1771147391.880929 12413 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771147391.880954 12413 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771147391.880960 12413 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "W0000 00:00:1771147391.880964 12413 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (1) Create a W&B account\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (2) Use an existing W&B account\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: (3) Don't visualize my results\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: Enter your choice: (30 second timeout) \n", + "\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m W&B disabled due to login timeout.\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: W&B API key is configured. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n", + "\u001b[34m\u001b[1mtrain: \u001b[0mweights=, cfg=/content/SMN-YOLOv5s/models/yolov5s-c3se.yaml, data=/content/SMN-YOLOv5s/potato-counting-1/data.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=10, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=ram, image_weights=False, device=0, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest\n", + "\u001b[34m\u001b[1mgithub: \u001b[0m⚠️ YOLOv5 is out of date by 2944 commits. Use 'git pull ultralytics master' or 'git clone https://github.com/ultralytics/yolov5' to update.\n", + "YOLOv5 🚀 704b81b1 Python-3.12.12 torch-2.9.0+cu128 CUDA:0 (Tesla T4, 14913MiB)\n", + "\n", + "\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0\n", + "\u001b[34m\u001b[1mComet: \u001b[0mrun 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet\n", + "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n", + "\n", + " from n params module arguments \n", + " 0 -1 1 3616 models.common.Conv [3, 32, 6, 2, 2] \n", + " 1 -1 1 18752 models.common.Conv [32, 64, 3, 2] \n", + " 2 -1 1 14320 models.common.C3SE [64, 64] \n", + " 3 -1 1 74368 models.common.Conv [64, 128, 3, 2] \n", + " 4 -1 2 111040 models.common.C3SE [128, 128] \n", + " 5 -1 1 296192 models.common.Conv [128, 256, 3, 2] \n", + " 6 -1 3 655680 models.common.C3SE [256, 256] \n", + " 7 -1 1 1182208 models.common.Conv [256, 512, 3, 2] \n", + " 8 -1 1 867200 models.common.C3SE [512, 512] \n", + " 9 -1 1 659200 models.common.SPPF [512, 512, 5] \n", + " 10 -1 1 132352 models.common.Conv [512, 256, 1, 1] \n", + " 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n", + " 12 [-1, 6] 1 0 models.common.Concat [1] \n", + " 13 -1 1 364288 models.common.C3 [512, 256, 1, False] \n", + " 14 -1 1 33408 models.common.Conv [256, 128, 1, 1] \n", + " 15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n", + " 16 [-1, 4] 1 0 models.common.Concat [1] \n", + " 17 -1 1 92032 models.common.C3 [256, 128, 1, False] \n", + " 18 -1 1 148096 models.common.Conv [128, 128, 3, 2] \n", + " 19 [-1, 14] 1 0 models.common.Concat [1] \n", + " 20 -1 1 298752 models.common.C3 [256, 256, 1, False] \n", + " 21 -1 1 591104 models.common.Conv [256, 256, 3, 2] \n", + " 22 [-1, 10] 1 0 models.common.Concat [1] \n", + " 23 -1 1 1187328 models.common.C3 [512, 512, 1, False] \n", + " 24 [17, 20, 23] 1 16182 models.yolo.Detect [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]\n", + "YOLOv5s-c3se summary: 349 layers, 6746118 parameters, 6746118 gradients, 15.4 GFLOPs\n", + "\n", + "/content/SMN-YOLOv5s/models/common.py:719: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n", + " with amp.autocast(autocast):\n", + "/content/SMN-YOLOv5s/models/common.py:719: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n", + " with amp.autocast(autocast):\n", + "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n", + "\u001b[34m\u001b[1moptimizer:\u001b[0m SGD(lr=0.01) with parameter groups 66 weight(decay=0.0), 281 weight(decay=0.0005), 69 bias\n", + "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n", + "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /content/SMN-YOLOv5s/potato-counting-1/train/labels.cache... 2077 images, 78 backgrounds, 0 corrupt: 100% 2077/2077 [00:00\n", + " main(opt)\n", + " File \"/content/SMN-YOLOv5s/train.py\", line 536, in main\n", + " train(opt.hyp, opt, device, callbacks)\n", + " File \"/content/SMN-YOLOv5s/train.py\", line 423, in train\n", + " model=attempt_load(f, device).half(),\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/content/SMN-YOLOv5s/models/experimental.py\", line 79, in attempt_load\n", + " ckpt = torch.load(attempt_download(w), map_location='cpu') # load\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/local/lib/python3.12/dist-packages/torch/serialization.py\", line 1529, in load\n", + " raise pickle.UnpicklingError(_get_wo_message(str(e))) from None\n", + "_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, \u001b[1mdo those steps only if you trust the source of the checkpoint\u001b[0m. \n", + "\t(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.\n", + "\t(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.\n", + "\tWeightsUnpickler error: Unsupported global: GLOBAL models.yolo.DetectionModel was not an allowed global by default. Please use `torch.serialization.add_safe_globals([models.yolo.DetectionModel])` or the `torch.serialization.safe_globals([models.yolo.DetectionModel])` context manager to allowlist this global if you trust this class/function.\n", + "\n", + "Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.\n" + ] + } + ], + "source": [ + "!python train.py --img 640 --batch 16 --epochs 10 --data {dataset.location}/data.yaml --weights '' --cfg /content/SMN-YOLOv5s/models/yolov5s-c3se.yaml --cache" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "w4XrkoQsq3R6", + "outputId": "21f88754-f381-4a93-bb77-c42f61f70f80" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mdetect: \u001b[0mweights=['runs/train/exp8/weights/best.pt'], source=/content/SMN-YOLOv5s/potato-counting-1/test/images, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_csv=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1\n", + "YOLOv5 🚀 704b81b1 Python-3.12.12 torch-2.9.0+cu128 CUDA:0 (Tesla T4, 14913MiB)\n", + "\n", + "Fusing layers... \n", + "YOLOv5s-cbam summary: 224 layers, 7074200 parameters, 0 gradients, 15.8 GFLOPs\n", + "image 1/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0001_jpg.rf.e6eb44d08cce17b3d731fc3289476049.jpg: 384x640 24 kentangs, 58.4ms\n", + "image 2/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0023_jpg.rf.a6688cb1ed6fcb550d42248530abba77.jpg: 384x640 19 kentangs, 18.6ms\n", + "image 3/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0047_jpg.rf.f282e04cdbdf264ea2bca36739ab1c06.jpg: 384x640 24 kentangs, 12.0ms\n", + "image 4/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0010_jpg.rf.35a1f8e9d3b468697a346af8192c2f5e.jpg: 384x640 13 kentangs, 21.2ms\n", + "image 5/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0031_jpg.rf.b7aae0e45e4b6d345f3cb500c0b8351e.jpg: 384x640 17 kentangs, 11.8ms\n", + "image 6/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0043_jpg.rf.2bc115567701b6290beeb107a92dd14c.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 7/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0001_jpg.rf.63cc7c52e36253d92748ebee7d3a2b74.jpg: 384x640 18 kentangs, 11.7ms\n", + "image 8/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0007_jpg.rf.c16cf84c451aa0637489640658bf371f.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 9/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0016_jpg.rf.8a239cd42e4c9a09a2169bc0bde1cdd8.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 10/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0005_jpg.rf.cc17489b232716d28a31f640ddfa4500.jpg: 384x640 28 kentangs, 11.4ms\n", + "image 11/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0008_jpg.rf.6ea395755fb36e97300a0f0a7bf7b104.jpg: 384x640 26 kentangs, 11.4ms\n", + "image 12/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0017_jpg.rf.ae58af19aeaf53c3fb0d07f279817503.jpg: 384x640 20 kentangs, 11.3ms\n", + "image 13/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0001_jpg.rf.24f3bc14c84e165983b169281c29dca9.jpg: 384x640 22 kentangs, 12.2ms\n", + "image 14/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0032_jpg.rf.187dfc82c453ef2df043174092c71b03.jpg: 384x640 33 kentangs, 11.3ms\n", + "image 15/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0052_jpg.rf.96d8f2f440bf33b3a122503e42615bcc.jpg: 384x640 25 kentangs, 11.3ms\n", + "image 16/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0017_jpg.rf.80aa1a2ced3a3b47cc46b6b7591bd8ae.jpg: 384x640 15 kentangs, 11.4ms\n", + "image 17/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0047_jpg.rf.b342f6f011ad9f8944575c18b4f95d6c.jpg: 384x640 21 kentangs, 11.3ms\n", + "image 18/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0059_jpg.rf.58532654034538612d351cb84767febc.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 19/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0001_jpg.rf.e933754d7f74d3773738a2d1b9596b0b.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 20/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0017_jpg.rf.08fc856c440f010fcf5741f7e0d3dcb8.jpg: 384x640 24 kentangs, 11.4ms\n", + "image 21/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0025_jpg.rf.e6e55cf6299ee807fc54126439fec673.jpg: 384x640 28 kentangs, 11.3ms\n", + "image 22/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0001_jpg.rf.47189811dc38f844b1160d601fb1f001.jpg: 384x640 17 kentangs, 11.3ms\n", + "image 23/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0014_jpg.rf.96ec68bb5214bea404854664b213c188.jpg: 384x640 22 kentangs, 11.3ms\n", + "image 24/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0022_jpg.rf.de36633df84910b5560f799d1b05f4b7.jpg: 384x640 27 kentangs, 11.3ms\n", + "image 25/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0001_jpg.rf.22472ee39e65a19424b0ee6ac030a6c7.jpg: 384x640 29 kentangs, 14.5ms\n", + "image 26/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0029_jpg.rf.78009df3407cf93c18bc4948cdfae67a.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 27/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0065_jpg.rf.547cb80dec5b73ee4e10bd51aa4b11c3.jpg: 384x640 44 kentangs, 12.5ms\n", + "image 28/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0001_jpg.rf.9b8190377fa845ed3e86cc390262b71f.jpg: 384x640 33 kentangs, 11.4ms\n", + "image 29/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0014_jpg.rf.7a8899f462ad21554ae9aa465f0713d1.jpg: 384x640 35 kentangs, 13.6ms\n", + "image 30/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0029_jpg.rf.8326b0175ea922cd5282c7b5add376a3.jpg: 384x640 34 kentangs, 11.4ms\n", + "image 31/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0001_jpg.rf.5e3a33a8e14ef2fe0fe376c4cd718b71.jpg: 384x640 32 kentangs, 11.4ms\n", + "image 32/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0012_jpg.rf.0bc15ed35586a033e71c574a2e5b7690.jpg: 384x640 29 kentangs, 11.4ms\n", + "image 33/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0022_jpg.rf.fbd6b3da05f9790c6ff1522aba7ce405.jpg: 384x640 38 kentangs, 11.4ms\n", + "image 34/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0001_jpg.rf.a36cca51da3e045a5d436c680fb1d6fe.jpg: 384x640 38 kentangs, 11.4ms\n", + "image 35/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0008_jpg.rf.e880bd0675d40bfa7abad7da3eef31c5.jpg: 384x640 31 kentangs, 11.4ms\n", + "image 36/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0014_jpg.rf.f454b03d7e5f068e38947195745f8630.jpg: 384x640 37 kentangs, 11.4ms\n", + "image 37/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0001_jpg.rf.c0c5007b6b7d9ee70783e1a0c5f819e5.jpg: 384x640 46 kentangs, 11.4ms\n", + "image 38/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0002_jpg.rf.3d4763435fff98950bf57ba19c7887c7.jpg: 384x640 48 kentangs, 11.4ms\n", + "image 39/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0029_jpg.rf.8d29c35541b05ed34b26eae788a76ab7.jpg: 384x640 57 kentangs, 11.4ms\n", + "image 40/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0001_jpg.rf.a2530851cd2252912350773d298442a5.jpg: 384x640 43 kentangs, 11.4ms\n", + "image 41/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0015_jpg.rf.fe8e121c52e8fac05a0b1088d209485f.jpg: 384x640 46 kentangs, 11.4ms\n", + "image 42/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0029_jpg.rf.476d1c69ba2dc4eb007e2c62da58cd54.jpg: 384x640 58 kentangs, 11.4ms\n", + "image 43/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0001_jpg.rf.98ae4a736897aa564504db7cc5a0ec59.jpg: 384x640 62 kentangs, 11.4ms\n", + "image 44/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0009_jpg.rf.c9d75f53eaf49b30297ae8cbf9baa2e7.jpg: 384x640 63 kentangs, 11.4ms\n", + "image 45/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0020_jpg.rf.d5c9abb1d4b51cac15183929d5131d20.jpg: 384x640 86 kentangs, 13.1ms\n", + "image 46/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0001_jpg.rf.718d062c0dd51d19b14541393321ce13.jpg: 384x640 54 kentangs, 11.4ms\n", + "image 47/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0002_jpg.rf.534cf079959a749879b47c3a77b361ab.jpg: 384x640 54 kentangs, 11.4ms\n", + "image 48/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0011_jpg.rf.01560dd5f5101dda2394ba8a7bf51259.jpg: 384x640 64 kentangs, 11.6ms\n", + "image 49/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0001_jpg.rf.58ff164b3e4c73957574ddc54cfc3c40.jpg: 384x640 55 kentangs, 12.6ms\n", + "image 50/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0002_jpg.rf.48bb97033e272225e5aff17d313b92c9.jpg: 384x640 51 kentangs, 11.4ms\n", + "image 51/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0007_jpg.rf.d1d050714f5502b782f6f64a2589e9e6.jpg: 384x640 50 kentangs, 11.4ms\n", + "image 52/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0001_jpg.rf.888eb1919b58cb161646b083ede20ab5.jpg: 384x640 43 kentangs, 11.4ms\n", + "image 53/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0002_jpg.rf.6c73fb7ed7df2f0e95370eeba3a739db.jpg: 384x640 46 kentangs, 11.4ms\n", + "image 54/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0011_jpg.rf.5e3ee4f3a24b1fdabf2e83f8d7b2fbe7.jpg: 384x640 50 kentangs, 11.5ms\n", + "image 55/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0001_jpg.rf.4633e5d4ffb7c71d0a86fbe1208ce550.jpg: 384x640 64 kentangs, 11.4ms\n", + "image 56/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0003_jpg.rf.7d61297ca41f2fb9b3255eb1f92b7856.jpg: 384x640 65 kentangs, 11.4ms\n", + "image 57/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0007_jpg.rf.90e0fe8c043d0c691777d56aba2b5d5f.jpg: 384x640 54 kentangs, 11.4ms\n", + "image 58/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0001_jpg.rf.4f9f1471a246bdec09bc88f7160801a9.jpg: 384x640 77 kentangs, 11.4ms\n", + "image 59/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0005_jpg.rf.f787616b18864a6d9e6ac4dd5f1038cd.jpg: 384x640 76 kentangs, 13.2ms\n", + "image 60/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0008_jpg.rf.4bee184d41d506c303a4635399e9736a.jpg: 384x640 55 kentangs, 11.4ms\n", + "image 61/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0056_jpg.rf.63f37af9fbda63f5e08474bca7d7dbc8.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 62/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0081_jpg.rf.ddfdd4e3dbb22ecc994ca9a60b8e388e.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 63/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0101_jpg.rf.92a42347878dcb1b39cd50c65c24a129.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 64/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0001_jpg.rf.3842ba6d063f90dc9a85ab6b24813efd.jpg: 384x640 11 kentangs, 11.3ms\n", + "image 65/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0035_jpg.rf.6f65aa3a8d2345817abd6ed498a384ac.jpg: 384x640 24 kentangs, 11.4ms\n", + "image 66/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0050_jpg.rf.39437cdbfaa71da62a0771614e6a6c81.jpg: 384x640 22 kentangs, 12.3ms\n", + "image 67/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0018_jpg.rf.eeeab9cf18c348a22fd63ffc8f19d30e.jpg: 384x640 17 kentangs, 11.4ms\n", + "image 68/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0027_jpg.rf.8cabba09f2708f132c69eedb253a72ac.jpg: 384x640 26 kentangs, 11.4ms\n", + "image 69/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0033_jpg.rf.e356d17d51ca9a1b0d129926014ba76a.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 70/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0013_jpg.rf.1b961001171c343faf0a1c87b72e847c.jpg: 384x640 15 kentangs, 11.4ms\n", + "image 71/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0019_jpg.rf.7b5ec74fc10e34c4b4797659fc52d3df.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 72/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0024_jpg.rf.b8de672a3ac6c5bfa02f8f5734a6c599.jpg: 384x640 19 kentangs, 11.4ms\n", + "image 73/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0001_jpg.rf.36524bb9c12dcba5ffbfa7b55dd24f16.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 74/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0023_jpg.rf.9eeebf3d949a198242dfa9229075fb31.jpg: 384x640 19 kentangs, 11.4ms\n", + "image 75/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0051_jpg.rf.7b8ea41b59cc9299a4fb50da349d15ef.jpg: 384x640 26 kentangs, 11.4ms\n", + "image 76/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0008_jpg.rf.a88edd5deae76098a0110aff77a5e976.jpg: 384x640 13 kentangs, 11.7ms\n", + "image 77/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0032_jpg.rf.9a690255b263410ba2fe9bc41795620b.jpg: 384x640 19 kentangs, 12.0ms\n", + "image 78/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0046_jpg.rf.31eba01c47163680425a900a539b7568.jpg: 384x640 24 kentangs, 13.2ms\n", + "image 79/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0001_jpg.rf.98ce7380370eb6ce2556602538f1523b.jpg: 384x640 17 kentangs, 11.5ms\n", + "image 80/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0024_jpg.rf.55c18c32956cf051d11dc8ab0be27653.jpg: 384x640 19 kentangs, 19.0ms\n", + "image 81/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0032_jpg.rf.fe81ad2d1ee9c03ce41c833d70c44f13.jpg: 384x640 23 kentangs, 11.8ms\n", + "image 82/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0008_jpg.rf.943641cc10217c71f4ebc9bff5db8ca5.jpg: 384x640 14 kentangs, 15.9ms\n", + "image 83/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0016_jpg.rf.1c87322cf1fb4ffcca842908afc4fe63.jpg: 384x640 20 kentangs, 11.4ms\n", + "image 84/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0022_jpg.rf.1f49bdbfa4aae29d26f531068c5c6709.jpg: 384x640 23 kentangs, 11.4ms\n", + "image 85/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0053_jpg.rf.f6f69f98c11804c9dab6bc9847ba5328.jpg: 384x640 11 kentangs, 11.3ms\n", + "image 86/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0074_jpg.rf.f2823bb1b7a757c96204e8d6c5475e44.jpg: 384x640 16 kentangs, 11.3ms\n", + "image 87/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0093_jpg.rf.f739fcf09ed1d7aef061f437c2d39515.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 88/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0056_jpg.rf.81c87799f88a9590b840dea0b1932aa5.jpg: 384x640 12 kentangs, 11.3ms\n", + "image 89/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0069_jpg.rf.a655a0ec3dc5000688d69d0da1bca325.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 90/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0080_jpg.rf.0e325c0ced8268fdb2e517da918f5873.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 91/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0035_jpg.rf.114e05c12b9a747d3472cd9d25cbc16c.jpg: 384x640 11 kentangs, 11.4ms\n", + "image 92/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0043_jpg.rf.4176dfb24bdd00ba9aa142df52b2e07b.jpg: 384x640 14 kentangs, 12.2ms\n", + "image 93/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0047_jpg.rf.d13bca82bc2569f80878024d67c366cc.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 94/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0025_jpg.rf.e9d0aaa28b37b0257910b4e35c86b442.jpg: 384x640 13 kentangs, 11.4ms\n", + "image 95/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0030_jpg.rf.381ae89c4d4d21b271e99cc042e28dcf.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 96/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0036_jpg.rf.769c79e43290d3709ebcb3f3a01127c8.jpg: 384x640 16 kentangs, 11.3ms\n", + "image 97/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0050_jpg.rf.5e013e1743201317e3f6e21e659e76aa.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 98/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0074_jpg.rf.f519fc0223ba45bfc340dc5cf09cd653.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 99/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0098_jpg.rf.84aab28cb6c37d4c7d91466c72cb718d.jpg: 384x640 18 kentangs, 12.6ms\n", + "image 100/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0029_jpg.rf.5b1742cad26f047f63fb2133f63967d7.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 101/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0039_jpg.rf.92e94b8b19036a1b288614d5cca716a4.jpg: 384x640 19 kentangs, 12.3ms\n", + "image 102/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0050_jpg.rf.6471950e6b87e95fd28a5d6f09ace411.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 103/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0035_jpg.rf.d6a185c06cfeaa717458b04989a51965.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 104/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0044_jpg.rf.34be41c7033fa5a5da9958ae03aeee7c.jpg: 384x640 17 kentangs, 17.7ms\n", + "image 105/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0050_jpg.rf.1f32892a4daacb0e4c9d8385c1afc187.jpg: 384x640 22 kentangs, 22.5ms\n", + "image 106/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0032_jpg.rf.b2b55fb719381a371a41cadaae953d95.jpg: 384x640 11 kentangs, 18.2ms\n", + "image 107/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0038_jpg.rf.f16a2a5fc14bff6b1e9dc35e42799db5.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 108/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0044_jpg.rf.3eab04f85e2cc43c561dd1cd91aea91b.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 109/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0068_jpg.rf.872322922e3d2f173fe6c229d2083907.jpg: 384x640 21 kentangs, 11.4ms\n", + "image 110/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0092_jpg.rf.9857704f117735beb7e442a3291745ca.jpg: 384x640 26 kentangs, 26.5ms\n", + "image 111/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0112_jpg.rf.2f002108d8de825e3f21dc2af69f00f9.jpg: 384x640 33 kentangs, 25.7ms\n", + "image 112/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0033_jpg.rf.72dcd9e8062dca13197ed1f815854257.jpg: 384x640 23 kentangs, 21.6ms\n", + "image 113/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0047_jpg.rf.2fc52335e3175f9ace78a5c33bc13ecc.jpg: 384x640 29 kentangs, 23.8ms\n", + "image 114/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0059_jpg.rf.4982cc7d5468ad58f2a908ef3d64178c.jpg: 384x640 27 kentangs, 23.4ms\n", + "image 115/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0039_jpg.rf.72f4b05993a9a1f836691f115212840f.jpg: 384x640 25 kentangs, 11.9ms\n", + "image 116/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0047_jpg.rf.fc9714fbe7f36705c73f64ca6bd01477.jpg: 384x640 25 kentangs, 15.2ms\n", + "image 117/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0053_jpg.rf.7ff7e49dbc70cc636316005049ea0adc.jpg: 384x640 39 kentangs, 12.8ms\n", + "image 118/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0029_jpg.rf.350222b73536cd1b2fe00bb36046a311.jpg: 384x640 17 kentangs, 11.4ms\n", + "image 119/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0035_jpg.rf.3cc980ea61f7137aa2f0864fd7505fd1.jpg: 384x640 28 kentangs, 11.4ms\n", + "image 120/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0041_jpg.rf.68f7c106dafe1f8965aad9045b830fbb.jpg: 384x640 36 kentangs, 11.4ms\n", + "image 121/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0071_jpg.rf.2908d238dd69daefaab4eda8922bb6b9.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 122/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0092_jpg.rf.c7efb5b9aee29d3f54338d1a62b85947.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 123/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0116_jpg.rf.0ea8d758b4487b10ac3db3f34298e8ed.jpg: 384x640 31 kentangs, 11.4ms\n", + "image 124/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0041_jpg.rf.ec03e5f5629a2cc919746550bed78b88.jpg: 384x640 20 kentangs, 11.4ms\n", + "image 125/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0053_jpg.rf.f2ee934e099d8c96f0de51fd8748e8da.jpg: 384x640 24 kentangs, 11.4ms\n", + "image 126/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0062_jpg.rf.6a398a5ffa95d9cae8262c03f14725b3.jpg: 384x640 44 kentangs, 11.4ms\n", + "image 127/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0035_jpg.rf.a60af036b1819f722092f1b242b92166.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 128/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0043_jpg.rf.d61187ec02ee553e097c4e166c2c299f.jpg: 384x640 40 kentangs, 11.4ms\n", + "image 129/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0048_jpg.rf.384c68e485e38182b8e198fec264642c.jpg: 384x640 38 kentangs, 11.4ms\n", + "image 130/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0029_jpg.rf.404b8444d4f73d54f2f0d93ad24ab43e.jpg: 384x640 31 kentangs, 15.8ms\n", + "image 131/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0035_jpg.rf.f3d49a3ed44bd006e728a519be02f2b9.jpg: 384x640 34 kentangs, 13.2ms\n", + "image 132/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0039_jpg.rf.d7fbfde1e3e19ffadcf19da889cf8f42.jpg: 384x640 39 kentangs, 11.4ms\n", + "image 133/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0056_jpg.rf.9abe5ffdf392d2a05efd96f347fa29a9.jpg: 384x640 46 kentangs, 11.4ms\n", + "image 134/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0083_jpg.rf.9f3a500268fb067e985f5f35aa940c9b.jpg: 384x640 50 kentangs, 17.4ms\n", + "image 135/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0098_jpg.rf.a09d7ec02f5652094cb1dc3ecea22bf7.jpg: 384x640 73 kentangs, 11.4ms\n", + "image 136/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0038_jpg.rf.ee399e884732f4da301b0a3b7b877a57.jpg: 384x640 44 kentangs, 11.4ms\n", + "image 137/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0050_jpg.rf.20e23ce8af79323596c5fb7969784dbb.jpg: 384x640 62 kentangs, 11.4ms\n", + "image 138/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0062_jpg.rf.f4b8ded38a99c36d43c60bab45c5d4ae.jpg: 384x640 75 kentangs, 14.7ms\n", + "image 139/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0029_jpg.rf.424b4b0e34cb28623d1319e9cf69c0ad.jpg: 384x640 40 kentangs, 11.4ms\n", + "image 140/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0038_jpg.rf.10461adcfb3f35e5651305011a47c3fd.jpg: 384x640 46 kentangs, 12.2ms\n", + "image 141/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0046_jpg.rf.7e48f6964de2f89bbff9bfd4561fa368.jpg: 384x640 57 kentangs, 11.4ms\n", + "image 142/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0029_jpg.rf.a3f318473e0a3bf7332e3fa04adc33b8.jpg: 384x640 41 kentangs, 11.4ms\n", + "image 143/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0036_jpg.rf.420d68773ff2925f82219a432ef8deb3.jpg: 384x640 61 kentangs, 14.9ms\n", + "image 144/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0041_jpg.rf.07c32656e48f2ed188366960ca84a1dc.jpg: 384x640 60 kentangs, 11.4ms\n", + "image 145/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0074_jpg.rf.6e78d8e73520a136d760f0a8905f7c59.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 146/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0091_jpg.rf.8d3f1963e87f206c9ce3253cc05031b6.jpg: 384x640 20 kentangs, 11.4ms\n", + "image 147/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0116_jpg.rf.f0c68edbcaa5012f08852aaf1dafd268.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 148/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0046_jpg.rf.ad0825cefc9ce373244f53e0f7eee021.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 149/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0059_jpg.rf.967bba947479e93ac9f78799bfd46e3b.jpg: 384x640 20 kentangs, 11.4ms\n", + "image 150/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0070_jpg.rf.e3c29179b81e4f3aca8042c5c163b569.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 151/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0030_jpg.rf.e59757aec26cd62350cb8ed978be2a4b.jpg: 384x640 24 kentangs, 11.4ms\n", + "image 152/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0037_jpg.rf.75d12942063b579c9ef39a8ece093fec.jpg: 384x640 23 kentangs, 12.4ms\n", + "image 153/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0045_jpg.rf.d3e56945a1cd21ec7a6337c59b2842b1.jpg: 384x640 26 kentangs, 18.2ms\n", + "image 154/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0022_jpg.rf.dd3b01cdd0c575674f640fb3be62c053.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 155/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0028_jpg.rf.a4ab63ae0d84a7caf6821f03eac7a2d5.jpg: 384x640 16 kentangs, 11.4ms\n", + "image 156/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0033_jpg.rf.8e5ecec035558a40e969c7cc300b5184.jpg: 384x640 23 kentangs, 11.4ms\n", + "image 157/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0083_jpg.rf.8d18fbada24b45e3b552db2d2a8deda3.jpg: 384x640 22 kentangs, 11.4ms\n", + "image 158/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0113_jpg.rf.1e19874bfe3e746db59c6439f424dcaf.jpg: 384x640 23 kentangs, 11.4ms\n", + "image 159/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0137_jpg.rf.960f0bb36586da4a6381438703b9e79b.jpg: 384x640 20 kentangs, 11.4ms\n", + "image 160/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0059_jpg.rf.5be4bdc8cdab718417f1d41430d14d10.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 161/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0071_jpg.rf.b312b0d184b90e037e850f2efdd0ad24.jpg: 384x640 17 kentangs, 11.3ms\n", + "image 162/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0085_jpg.rf.d7a4a4ac9f84c4d9a68c2c40a5e1a8d5.jpg: 384x640 24 kentangs, 11.6ms\n", + "image 163/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0030_jpg.rf.3889a66fd378201754435c7100b4ce28.jpg: 384x640 12 kentangs, 11.4ms\n", + "image 164/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0039_jpg.rf.d783b43903a7e65e9366b035a3ffb1ab.jpg: 384x640 18 kentangs, 11.4ms\n", + "image 165/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0051_jpg.rf.8fc46e32f291ccc8c6a7676cbf2f8590.jpg: 384x640 25 kentangs, 11.4ms\n", + "image 166/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0016_jpg.rf.9c4b74e8da415a646a563784851a1b8f.jpg: 384x640 14 kentangs, 11.3ms\n", + "image 167/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0022_jpg.rf.ece1f9c0f378c65e908f8cc9231e561a.jpg: 384x640 25 kentangs, 11.3ms\n", + "image 168/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0029_jpg.rf.772fdbd4f561dd7af144233b34d2bedd.jpg: 384x640 16 kentangs, 11.3ms\n", + "Speed: 0.5ms pre-process, 12.7ms inference, 1.8ms NMS per image at shape (1, 3, 640, 640)\n", + "Results saved to \u001b[1mruns/detect/exp2\u001b[0m\n" + ] + } + ], + "source": [ + "!python detect.py --weights runs/train/exp8/weights/best.pt --img 640 --conf 0.1 --source {dataset.location}/test/images" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "fWvXEr0qgD-c", + "outputId": "0e6d24b9-04b8-4076-db3b-df63399bbb58" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mdetect: \u001b[0mweights=['runs/train/exp9/weights/best.pt'], source=/content/SMN-YOLOv5s/potato-counting-1/test/images, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_csv=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1\n", + "YOLOv5 🚀 704b81b1 Python-3.12.12 torch-2.9.0+cu128 CUDA:0 (Tesla T4, 14913MiB)\n", + "\n", + "Fusing layers... \n", + "YOLOv5s-c3se summary: 283 layers, 6735734 parameters, 0 gradients, 15.2 GFLOPs\n", + "image 1/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0001_jpg.rf.e6eb44d08cce17b3d731fc3289476049.jpg: 384x640 31 kentangs, 45.1ms\n", + "image 2/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0023_jpg.rf.a6688cb1ed6fcb550d42248530abba77.jpg: 384x640 33 kentangs, 12.8ms\n", + "image 3/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-25_0047_jpg.rf.f282e04cdbdf264ea2bca36739ab1c06.jpg: 384x640 34 kentangs, 12.8ms\n", + "image 4/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0010_jpg.rf.35a1f8e9d3b468697a346af8192c2f5e.jpg: 384x640 22 kentangs, 12.6ms\n", + "image 5/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0031_jpg.rf.b7aae0e45e4b6d345f3cb500c0b8351e.jpg: 384x640 34 kentangs, 14.2ms\n", + "image 6/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-5-1-_0043_jpg.rf.2bc115567701b6290beeb107a92dd14c.jpg: 384x640 24 kentangs, 12.9ms\n", + "image 7/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0001_jpg.rf.63cc7c52e36253d92748ebee7d3a2b74.jpg: 384x640 32 kentangs, 12.5ms\n", + "image 8/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0007_jpg.rf.c16cf84c451aa0637489640658bf371f.jpg: 384x640 26 kentangs, 13.8ms\n", + "image 9/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_0-75_0016_jpg.rf.8a239cd42e4c9a09a2169bc0bde1cdd8.jpg: 384x640 30 kentangs, 12.4ms\n", + "image 10/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0005_jpg.rf.cc17489b232716d28a31f640ddfa4500.jpg: 384x640 35 kentangs, 12.9ms\n", + "image 11/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0008_jpg.rf.6ea395755fb36e97300a0f0a7bf7b104.jpg: 384x640 30 kentangs, 12.6ms\n", + "image 12/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_100_1_0017_jpg.rf.ae58af19aeaf53c3fb0d07f279817503.jpg: 384x640 28 kentangs, 12.4ms\n", + "image 13/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0001_jpg.rf.24f3bc14c84e165983b169281c29dca9.jpg: 384x640 21 kentangs, 12.7ms\n", + "image 14/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0032_jpg.rf.187dfc82c453ef2df043174092c71b03.jpg: 384x640 34 kentangs, 12.9ms\n", + "image 15/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-25_0052_jpg.rf.96d8f2f440bf33b3a122503e42615bcc.jpg: 384x640 29 kentangs, 13.2ms\n", + "image 16/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0017_jpg.rf.80aa1a2ced3a3b47cc46b6b7591bd8ae.jpg: 384x640 19 kentangs, 12.6ms\n", + "image 17/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0047_jpg.rf.b342f6f011ad9f8944575c18b4f95d6c.jpg: 384x640 29 kentangs, 12.3ms\n", + "image 18/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-5-1-_0059_jpg.rf.58532654034538612d351cb84767febc.jpg: 384x640 32 kentangs, 19.4ms\n", + "image 19/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0001_jpg.rf.e933754d7f74d3773738a2d1b9596b0b.jpg: 384x640 30 kentangs, 12.7ms\n", + "image 20/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0017_jpg.rf.08fc856c440f010fcf5741f7e0d3dcb8.jpg: 384x640 44 kentangs, 12.8ms\n", + "image 21/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_0-75_0025_jpg.rf.e6e55cf6299ee807fc54126439fec673.jpg: 384x640 26 kentangs, 12.6ms\n", + "image 22/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0001_jpg.rf.47189811dc38f844b1160d601fb1f001.jpg: 384x640 20 kentangs, 12.7ms\n", + "image 23/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0014_jpg.rf.96ec68bb5214bea404854664b213c188.jpg: 384x640 32 kentangs, 12.6ms\n", + "image 24/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_110_1_0022_jpg.rf.de36633df84910b5560f799d1b05f4b7.jpg: 384x640 39 kentangs, 12.5ms\n", + "image 25/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0001_jpg.rf.22472ee39e65a19424b0ee6ac030a6c7.jpg: 384x640 38 kentangs, 12.9ms\n", + "image 26/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0029_jpg.rf.78009df3407cf93c18bc4948cdfae67a.jpg: 384x640 38 kentangs, 12.9ms\n", + "image 27/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-25_0065_jpg.rf.547cb80dec5b73ee4e10bd51aa4b11c3.jpg: 384x640 57 kentangs, 12.4ms\n", + "image 28/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0001_jpg.rf.9b8190377fa845ed3e86cc390262b71f.jpg: 384x640 38 kentangs, 12.7ms\n", + "image 29/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0014_jpg.rf.7a8899f462ad21554ae9aa465f0713d1.jpg: 384x640 47 kentangs, 14.5ms\n", + "image 30/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-5_0029_jpg.rf.8326b0175ea922cd5282c7b5add376a3.jpg: 384x640 57 kentangs, 12.5ms\n", + "image 31/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0001_jpg.rf.5e3a33a8e14ef2fe0fe376c4cd718b71.jpg: 384x640 44 kentangs, 12.3ms\n", + "image 32/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0012_jpg.rf.0bc15ed35586a033e71c574a2e5b7690.jpg: 384x640 48 kentangs, 12.3ms\n", + "image 33/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_0-75-2-_0022_jpg.rf.fbd6b3da05f9790c6ff1522aba7ce405.jpg: 384x640 54 kentangs, 12.3ms\n", + "image 34/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0001_jpg.rf.a36cca51da3e045a5d436c680fb1d6fe.jpg: 384x640 41 kentangs, 12.5ms\n", + "image 35/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0008_jpg.rf.e880bd0675d40bfa7abad7da3eef31c5.jpg: 384x640 55 kentangs, 12.8ms\n", + "image 36/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_120_1-2-_0014_jpg.rf.f454b03d7e5f068e38947195745f8630.jpg: 384x640 45 kentangs, 13.2ms\n", + "image 37/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0001_jpg.rf.c0c5007b6b7d9ee70783e1a0c5f819e5.jpg: 384x640 58 kentangs, 12.6ms\n", + "image 38/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0002_jpg.rf.3d4763435fff98950bf57ba19c7887c7.jpg: 384x640 61 kentangs, 12.6ms\n", + "image 39/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-25_0029_jpg.rf.8d29c35541b05ed34b26eae788a76ab7.jpg: 384x640 82 kentangs, 16.9ms\n", + "image 40/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0001_jpg.rf.a2530851cd2252912350773d298442a5.jpg: 384x640 55 kentangs, 12.8ms\n", + "image 41/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0015_jpg.rf.fe8e121c52e8fac05a0b1088d209485f.jpg: 384x640 61 kentangs, 12.5ms\n", + "image 42/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-5-2-_0029_jpg.rf.476d1c69ba2dc4eb007e2c62da58cd54.jpg: 384x640 62 kentangs, 14.3ms\n", + "image 43/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0001_jpg.rf.98ae4a736897aa564504db7cc5a0ec59.jpg: 384x640 52 kentangs, 12.7ms\n", + "image 44/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0009_jpg.rf.c9d75f53eaf49b30297ae8cbf9baa2e7.jpg: 384x640 79 kentangs, 16.2ms\n", + "image 45/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_0-75_0020_jpg.rf.d5c9abb1d4b51cac15183929d5131d20.jpg: 384x640 64 kentangs, 12.5ms\n", + "image 46/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0001_jpg.rf.718d062c0dd51d19b14541393321ce13.jpg: 384x640 72 kentangs, 12.6ms\n", + "image 47/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0002_jpg.rf.534cf079959a749879b47c3a77b361ab.jpg: 384x640 88 kentangs, 12.6ms\n", + "image 48/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_130_1_0011_jpg.rf.01560dd5f5101dda2394ba8a7bf51259.jpg: 384x640 73 kentangs, 12.5ms\n", + "image 49/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0001_jpg.rf.58ff164b3e4c73957574ddc54cfc3c40.jpg: 384x640 70 kentangs, 14.5ms\n", + "image 50/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0002_jpg.rf.48bb97033e272225e5aff17d313b92c9.jpg: 384x640 67 kentangs, 14.2ms\n", + "image 51/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-25_0007_jpg.rf.d1d050714f5502b782f6f64a2589e9e6.jpg: 384x640 60 kentangs, 12.9ms\n", + "image 52/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0001_jpg.rf.888eb1919b58cb161646b083ede20ab5.jpg: 384x640 70 kentangs, 12.8ms\n", + "image 53/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0002_jpg.rf.6c73fb7ed7df2f0e95370eeba3a739db.jpg: 384x640 75 kentangs, 14.1ms\n", + "image 54/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-5_0011_jpg.rf.5e3ee4f3a24b1fdabf2e83f8d7b2fbe7.jpg: 384x640 69 kentangs, 12.7ms\n", + "image 55/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0001_jpg.rf.4633e5d4ffb7c71d0a86fbe1208ce550.jpg: 384x640 72 kentangs, 12.4ms\n", + "image 56/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0003_jpg.rf.7d61297ca41f2fb9b3255eb1f92b7856.jpg: 384x640 67 kentangs, 12.5ms\n", + "image 57/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_0-75-2-_0007_jpg.rf.90e0fe8c043d0c691777d56aba2b5d5f.jpg: 384x640 73 kentangs, 12.1ms\n", + "image 58/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0001_jpg.rf.4f9f1471a246bdec09bc88f7160801a9.jpg: 384x640 80 kentangs, 12.3ms\n", + "image 59/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0005_jpg.rf.f787616b18864a6d9e6ac4dd5f1038cd.jpg: 384x640 66 kentangs, 13.5ms\n", + "image 60/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_140_1_0008_jpg.rf.4bee184d41d506c303a4635399e9736a.jpg: 384x640 61 kentangs, 12.4ms\n", + "image 61/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0056_jpg.rf.63f37af9fbda63f5e08474bca7d7dbc8.jpg: 384x640 13 kentangs, 12.0ms\n", + "image 62/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0081_jpg.rf.ddfdd4e3dbb22ecc994ca9a60b8e388e.jpg: 384x640 16 kentangs, 12.0ms\n", + "image 63/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-25_0101_jpg.rf.92a42347878dcb1b39cd50c65c24a129.jpg: 384x640 25 kentangs, 12.7ms\n", + "image 64/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0001_jpg.rf.3842ba6d063f90dc9a85ab6b24813efd.jpg: 384x640 14 kentangs, 12.4ms\n", + "image 65/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0035_jpg.rf.6f65aa3a8d2345817abd6ed498a384ac.jpg: 384x640 27 kentangs, 12.6ms\n", + "image 66/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-5_0050_jpg.rf.39437cdbfaa71da62a0771614e6a6c81.jpg: 384x640 28 kentangs, 13.2ms\n", + "image 67/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0018_jpg.rf.eeeab9cf18c348a22fd63ffc8f19d30e.jpg: 384x640 17 kentangs, 12.5ms\n", + "image 68/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0027_jpg.rf.8cabba09f2708f132c69eedb253a72ac.jpg: 384x640 24 kentangs, 12.0ms\n", + "image 69/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_0-75-1-_0033_jpg.rf.e356d17d51ca9a1b0d129926014ba76a.jpg: 384x640 22 kentangs, 12.2ms\n", + "image 70/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0013_jpg.rf.1b961001171c343faf0a1c87b72e847c.jpg: 384x640 17 kentangs, 12.0ms\n", + "image 71/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0019_jpg.rf.7b5ec74fc10e34c4b4797659fc52d3df.jpg: 384x640 24 kentangs, 21.7ms\n", + "image 72/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_80_1_0024_jpg.rf.b8de672a3ac6c5bfa02f8f5734a6c599.jpg: 384x640 20 kentangs, 12.4ms\n", + "image 73/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0001_jpg.rf.36524bb9c12dcba5ffbfa7b55dd24f16.jpg: 384x640 14 kentangs, 21.0ms\n", + "image 74/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0023_jpg.rf.9eeebf3d949a198242dfa9229075fb31.jpg: 384x640 19 kentangs, 18.2ms\n", + "image 75/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-25_0051_jpg.rf.7b8ea41b59cc9299a4fb50da349d15ef.jpg: 384x640 23 kentangs, 15.9ms\n", + "image 76/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0008_jpg.rf.a88edd5deae76098a0110aff77a5e976.jpg: 384x640 13 kentangs, 16.7ms\n", + "image 77/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0032_jpg.rf.9a690255b263410ba2fe9bc41795620b.jpg: 384x640 18 kentangs, 16.5ms\n", + "image 78/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-5_0046_jpg.rf.31eba01c47163680425a900a539b7568.jpg: 384x640 23 kentangs, 21.1ms\n", + "image 79/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0001_jpg.rf.98ce7380370eb6ce2556602538f1523b.jpg: 384x640 15 kentangs, 19.6ms\n", + "image 80/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0024_jpg.rf.55c18c32956cf051d11dc8ab0be27653.jpg: 384x640 19 kentangs, 16.6ms\n", + "image 81/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_0-75-1-_0032_jpg.rf.fe81ad2d1ee9c03ce41c833d70c44f13.jpg: 384x640 25 kentangs, 16.6ms\n", + "image 82/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0008_jpg.rf.943641cc10217c71f4ebc9bff5db8ca5.jpg: 384x640 16 kentangs, 17.5ms\n", + "image 83/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0016_jpg.rf.1c87322cf1fb4ffcca842908afc4fe63.jpg: 384x640 25 kentangs, 16.9ms\n", + "image 84/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/80_90_1_0022_jpg.rf.1f49bdbfa4aae29d26f531068c5c6709.jpg: 384x640 21 kentangs, 16.8ms\n", + "image 85/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0053_jpg.rf.f6f69f98c11804c9dab6bc9847ba5328.jpg: 384x640 10 kentangs, 17.4ms\n", + "image 86/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0074_jpg.rf.f2823bb1b7a757c96204e8d6c5475e44.jpg: 384x640 18 kentangs, 15.7ms\n", + "image 87/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-25_0093_jpg.rf.f739fcf09ed1d7aef061f437c2d39515.jpg: 384x640 20 kentangs, 18.7ms\n", + "image 88/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0056_jpg.rf.81c87799f88a9590b840dea0b1932aa5.jpg: 384x640 11 kentangs, 21.2ms\n", + "image 89/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0069_jpg.rf.a655a0ec3dc5000688d69d0da1bca325.jpg: 384x640 16 kentangs, 15.9ms\n", + "image 90/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-5_0080_jpg.rf.0e325c0ced8268fdb2e517da918f5873.jpg: 384x640 17 kentangs, 15.9ms\n", + "image 91/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0035_jpg.rf.114e05c12b9a747d3472cd9d25cbc16c.jpg: 384x640 12 kentangs, 16.1ms\n", + "image 92/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0043_jpg.rf.4176dfb24bdd00ba9aa142df52b2e07b.jpg: 384x640 17 kentangs, 16.1ms\n", + "image 93/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_0-75_0047_jpg.rf.d13bca82bc2569f80878024d67c366cc.jpg: 384x640 21 kentangs, 21.4ms\n", + "image 94/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0025_jpg.rf.e9d0aaa28b37b0257910b4e35c86b442.jpg: 384x640 13 kentangs, 22.4ms\n", + "image 95/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0030_jpg.rf.381ae89c4d4d21b271e99cc042e28dcf.jpg: 384x640 21 kentangs, 18.8ms\n", + "image 96/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_100_1_0036_jpg.rf.769c79e43290d3709ebcb3f3a01127c8.jpg: 384x640 17 kentangs, 17.3ms\n", + "image 97/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0050_jpg.rf.5e013e1743201317e3f6e21e659e76aa.jpg: 384x640 21 kentangs, 18.5ms\n", + "image 98/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0074_jpg.rf.f519fc0223ba45bfc340dc5cf09cd653.jpg: 384x640 18 kentangs, 22.7ms\n", + "image 99/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-25_0098_jpg.rf.84aab28cb6c37d4c7d91466c72cb718d.jpg: 384x640 23 kentangs, 20.9ms\n", + "image 100/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0029_jpg.rf.5b1742cad26f047f63fb2133f63967d7.jpg: 384x640 12 kentangs, 34.8ms\n", + "image 101/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0039_jpg.rf.92e94b8b19036a1b288614d5cca716a4.jpg: 384x640 17 kentangs, 25.7ms\n", + "image 102/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-5_0050_jpg.rf.6471950e6b87e95fd28a5d6f09ace411.jpg: 384x640 18 kentangs, 20.6ms\n", + "image 103/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0035_jpg.rf.d6a185c06cfeaa717458b04989a51965.jpg: 384x640 18 kentangs, 22.6ms\n", + "image 104/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0044_jpg.rf.34be41c7033fa5a5da9958ae03aeee7c.jpg: 384x640 18 kentangs, 23.4ms\n", + "image 105/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_0-75-1-_0050_jpg.rf.1f32892a4daacb0e4c9d8385c1afc187.jpg: 384x640 26 kentangs, 12.7ms\n", + "image 106/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0032_jpg.rf.b2b55fb719381a371a41cadaae953d95.jpg: 384x640 16 kentangs, 12.7ms\n", + "image 107/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0038_jpg.rf.f16a2a5fc14bff6b1e9dc35e42799db5.jpg: 384x640 20 kentangs, 12.4ms\n", + "image 108/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_110_1-3-_0044_jpg.rf.3eab04f85e2cc43c561dd1cd91aea91b.jpg: 384x640 20 kentangs, 13.7ms\n", + "image 109/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0068_jpg.rf.872322922e3d2f173fe6c229d2083907.jpg: 384x640 27 kentangs, 12.6ms\n", + "image 110/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0092_jpg.rf.9857704f117735beb7e442a3291745ca.jpg: 384x640 36 kentangs, 16.9ms\n", + "image 111/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-25_0112_jpg.rf.2f002108d8de825e3f21dc2af69f00f9.jpg: 384x640 50 kentangs, 12.5ms\n", + "image 112/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0033_jpg.rf.72dcd9e8062dca13197ed1f815854257.jpg: 384x640 31 kentangs, 12.6ms\n", + "image 113/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0047_jpg.rf.2fc52335e3175f9ace78a5c33bc13ecc.jpg: 384x640 33 kentangs, 12.3ms\n", + "image 114/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-5_0059_jpg.rf.4982cc7d5468ad58f2a908ef3d64178c.jpg: 384x640 48 kentangs, 13.0ms\n", + "image 115/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0039_jpg.rf.72f4b05993a9a1f836691f115212840f.jpg: 384x640 43 kentangs, 13.0ms\n", + "image 116/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0047_jpg.rf.fc9714fbe7f36705c73f64ca6bd01477.jpg: 384x640 36 kentangs, 13.1ms\n", + "image 117/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_0-75_0053_jpg.rf.7ff7e49dbc70cc636316005049ea0adc.jpg: 384x640 42 kentangs, 12.6ms\n", + "image 118/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0029_jpg.rf.350222b73536cd1b2fe00bb36046a311.jpg: 384x640 27 kentangs, 12.7ms\n", + "image 119/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0035_jpg.rf.3cc980ea61f7137aa2f0864fd7505fd1.jpg: 384x640 37 kentangs, 13.7ms\n", + "image 120/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_120_1_0041_jpg.rf.68f7c106dafe1f8965aad9045b830fbb.jpg: 384x640 43 kentangs, 15.6ms\n", + "image 121/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0071_jpg.rf.2908d238dd69daefaab4eda8922bb6b9.jpg: 384x640 22 kentangs, 14.7ms\n", + "image 122/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0092_jpg.rf.c7efb5b9aee29d3f54338d1a62b85947.jpg: 384x640 42 kentangs, 15.4ms\n", + "image 123/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-25_0116_jpg.rf.0ea8d758b4487b10ac3db3f34298e8ed.jpg: 384x640 62 kentangs, 15.4ms\n", + "image 124/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0041_jpg.rf.ec03e5f5629a2cc919746550bed78b88.jpg: 384x640 21 kentangs, 13.2ms\n", + "image 125/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0053_jpg.rf.f2ee934e099d8c96f0de51fd8748e8da.jpg: 384x640 31 kentangs, 12.7ms\n", + "image 126/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-5_0062_jpg.rf.6a398a5ffa95d9cae8262c03f14725b3.jpg: 384x640 47 kentangs, 13.2ms\n", + "image 127/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0035_jpg.rf.a60af036b1819f722092f1b242b92166.jpg: 384x640 33 kentangs, 12.6ms\n", + "image 128/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0043_jpg.rf.d61187ec02ee553e097c4e166c2c299f.jpg: 384x640 53 kentangs, 17.4ms\n", + "image 129/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_0-75_0048_jpg.rf.384c68e485e38182b8e198fec264642c.jpg: 384x640 68 kentangs, 12.1ms\n", + "image 130/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0029_jpg.rf.404b8444d4f73d54f2f0d93ad24ab43e.jpg: 384x640 40 kentangs, 15.8ms\n", + "image 131/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0035_jpg.rf.f3d49a3ed44bd006e728a519be02f2b9.jpg: 384x640 42 kentangs, 12.3ms\n", + "image 132/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_130_1_0039_jpg.rf.d7fbfde1e3e19ffadcf19da889cf8f42.jpg: 384x640 59 kentangs, 12.2ms\n", + "image 133/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0056_jpg.rf.9abe5ffdf392d2a05efd96f347fa29a9.jpg: 384x640 43 kentangs, 12.9ms\n", + "image 134/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0083_jpg.rf.9f3a500268fb067e985f5f35aa940c9b.jpg: 384x640 77 kentangs, 12.4ms\n", + "image 135/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-25_0098_jpg.rf.a09d7ec02f5652094cb1dc3ecea22bf7.jpg: 384x640 68 kentangs, 12.9ms\n", + "image 136/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0038_jpg.rf.ee399e884732f4da301b0a3b7b877a57.jpg: 384x640 55 kentangs, 13.9ms\n", + "image 137/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0050_jpg.rf.20e23ce8af79323596c5fb7969784dbb.jpg: 384x640 68 kentangs, 14.0ms\n", + "image 138/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-5_0062_jpg.rf.f4b8ded38a99c36d43c60bab45c5d4ae.jpg: 384x640 66 kentangs, 12.5ms\n", + "image 139/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0029_jpg.rf.424b4b0e34cb28623d1319e9cf69c0ad.jpg: 384x640 40 kentangs, 12.7ms\n", + "image 140/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0038_jpg.rf.10461adcfb3f35e5651305011a47c3fd.jpg: 384x640 52 kentangs, 19.1ms\n", + "image 141/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_0-75_0046_jpg.rf.7e48f6964de2f89bbff9bfd4561fa368.jpg: 384x640 67 kentangs, 12.4ms\n", + "image 142/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0029_jpg.rf.a3f318473e0a3bf7332e3fa04adc33b8.jpg: 384x640 47 kentangs, 12.4ms\n", + "image 143/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0036_jpg.rf.420d68773ff2925f82219a432ef8deb3.jpg: 384x640 54 kentangs, 12.4ms\n", + "image 144/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_140_1_0041_jpg.rf.07c32656e48f2ed188366960ca84a1dc.jpg: 384x640 78 kentangs, 12.6ms\n", + "image 145/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0074_jpg.rf.6e78d8e73520a136d760f0a8905f7c59.jpg: 384x640 12 kentangs, 12.5ms\n", + "image 146/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0091_jpg.rf.8d3f1963e87f206c9ce3253cc05031b6.jpg: 384x640 20 kentangs, 12.4ms\n", + "image 147/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-25_0116_jpg.rf.f0c68edbcaa5012f08852aaf1dafd268.jpg: 384x640 23 kentangs, 13.1ms\n", + "image 148/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0046_jpg.rf.ad0825cefc9ce373244f53e0f7eee021.jpg: 384x640 11 kentangs, 12.8ms\n", + "image 149/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0059_jpg.rf.967bba947479e93ac9f78799bfd46e3b.jpg: 384x640 17 kentangs, 14.4ms\n", + "image 150/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-5_0070_jpg.rf.e3c29179b81e4f3aca8042c5c163b569.jpg: 384x640 15 kentangs, 12.6ms\n", + "image 151/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0030_jpg.rf.e59757aec26cd62350cb8ed978be2a4b.jpg: 384x640 18 kentangs, 13.1ms\n", + "image 152/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0037_jpg.rf.75d12942063b579c9ef39a8ece093fec.jpg: 384x640 23 kentangs, 12.2ms\n", + "image 153/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_0-75-1-_0045_jpg.rf.d3e56945a1cd21ec7a6337c59b2842b1.jpg: 384x640 30 kentangs, 12.4ms\n", + "image 154/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0022_jpg.rf.dd3b01cdd0c575674f640fb3be62c053.jpg: 384x640 11 kentangs, 12.4ms\n", + "image 155/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0028_jpg.rf.a4ab63ae0d84a7caf6821f03eac7a2d5.jpg: 384x640 19 kentangs, 12.4ms\n", + "image 156/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_80_1_0033_jpg.rf.8e5ecec035558a40e969c7cc300b5184.jpg: 384x640 18 kentangs, 12.7ms\n", + "image 157/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0083_jpg.rf.8d18fbada24b45e3b552db2d2a8deda3.jpg: 384x640 26 kentangs, 12.3ms\n", + "image 158/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0113_jpg.rf.1e19874bfe3e746db59c6439f424dcaf.jpg: 384x640 19 kentangs, 12.6ms\n", + "image 159/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-25_0137_jpg.rf.960f0bb36586da4a6381438703b9e79b.jpg: 384x640 17 kentangs, 12.3ms\n", + "image 160/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0059_jpg.rf.5be4bdc8cdab718417f1d41430d14d10.jpg: 384x640 15 kentangs, 15.8ms\n", + "image 161/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0071_jpg.rf.b312b0d184b90e037e850f2efdd0ad24.jpg: 384x640 19 kentangs, 12.5ms\n", + "image 162/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-5_0085_jpg.rf.d7a4a4ac9f84c4d9a68c2c40a5e1a8d5.jpg: 384x640 21 kentangs, 12.9ms\n", + "image 163/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0030_jpg.rf.3889a66fd378201754435c7100b4ce28.jpg: 384x640 11 kentangs, 12.6ms\n", + "image 164/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0039_jpg.rf.d783b43903a7e65e9366b035a3ffb1ab.jpg: 384x640 18 kentangs, 12.4ms\n", + "image 165/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_0-75_0051_jpg.rf.8fc46e32f291ccc8c6a7676cbf2f8590.jpg: 384x640 24 kentangs, 12.1ms\n", + "image 166/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0016_jpg.rf.9c4b74e8da415a646a563784851a1b8f.jpg: 384x640 12 kentangs, 15.9ms\n", + "image 167/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0022_jpg.rf.ece1f9c0f378c65e908f8cc9231e561a.jpg: 384x640 22 kentangs, 12.7ms\n", + "image 168/168 /content/SMN-YOLOv5s/potato-counting-1/test/images/90_90_1_0029_jpg.rf.772fdbd4f561dd7af144233b34d2bedd.jpg: 384x640 17 kentangs, 12.6ms\n", + "Speed: 0.5ms pre-process, 14.5ms inference, 1.7ms NMS per image at shape (1, 3, 640, 640)\n", + "Results saved to \u001b[1mruns/detect/exp3\u001b[0m\n" + ] + } + ], + "source": [ + "!python detect.py --weights runs/train/exp9/weights/best.pt --img 640 --conf 0.1 --source {dataset.location}/test/images" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "id": "epN0BtjQr4JM" + }, + "outputs": [], + "source": [ + "from IPython.display import Image" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 816 + }, + "id": "X2Dl2pFlr4l9", + "outputId": "bc23766f-6690-41ad-e549-9dd543c181f0" + }, + "outputs": [ + { + "ename": "FileNotFoundError", + "evalue": "No such file or directory: '/kaggle/working/SMN-YOLOv5s/runs/train/exp8/confusion_matrix.png'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_data_and_metadata\u001b[0;34m(self, always_both)\u001b[0m\n\u001b[1;32m 1299\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1300\u001b[0;31m \u001b[0mb64_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mb2a_base64\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ascii'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1301\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: a bytes-like object is required, not 'str'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/formatters.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, obj, include, exclude)\u001b[0m\n\u001b[1;32m 968\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 969\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 970\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minclude\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minclude\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexclude\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mexclude\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 971\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 972\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_repr_mimebundle_\u001b[0;34m(self, include, exclude)\u001b[0m\n\u001b[1;32m 1288\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0membed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1289\u001b[0m \u001b[0mmimetype\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_mimetype\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1290\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_data_and_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0malways_both\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1291\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1292\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mmimetype\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_data_and_metadata\u001b[0;34m(self, always_both)\u001b[0m\n\u001b[1;32m 1300\u001b[0m \u001b[0mb64_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mb2a_base64\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ascii'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1301\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1302\u001b[0;31m raise FileNotFoundError(\n\u001b[0m\u001b[1;32m 1303\u001b[0m \"No such file or directory: '%s'\" % (self.data))\n\u001b[1;32m 1304\u001b[0m \u001b[0mmd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mFileNotFoundError\u001b[0m: No such file or directory: '/kaggle/working/SMN-YOLOv5s/runs/train/exp8/confusion_matrix.png'" + ] + }, + { + "ename": "FileNotFoundError", + "evalue": "No such file or directory: '/kaggle/working/SMN-YOLOv5s/runs/train/exp8/confusion_matrix.png'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_data_and_metadata\u001b[0;34m(self, always_both)\u001b[0m\n\u001b[1;32m 1299\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1300\u001b[0;31m \u001b[0mb64_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mb2a_base64\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ascii'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1301\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: a bytes-like object is required, not 'str'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/formatters.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, obj)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_real_method\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprint_method\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 344\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 345\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 346\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 347\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_repr_png_\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1318\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_repr_png_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1319\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0membed\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_FMT_PNG\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1320\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_data_and_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1321\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1322\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_repr_jpeg_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.12/dist-packages/IPython/core/display.py\u001b[0m in \u001b[0;36m_data_and_metadata\u001b[0;34m(self, always_both)\u001b[0m\n\u001b[1;32m 1300\u001b[0m \u001b[0mb64_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mb2a_base64\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ascii'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1301\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1302\u001b[0;31m raise FileNotFoundError(\n\u001b[0m\u001b[1;32m 1303\u001b[0m \"No such file or directory: '%s'\" % (self.data))\n\u001b[1;32m 1304\u001b[0m \u001b[0mmd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mFileNotFoundError\u001b[0m: No such file or directory: '/kaggle/working/SMN-YOLOv5s/runs/train/exp8/confusion_matrix.png'" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Image(\"/kaggle/working/SMN-YOLOv5s/runs/train/exp8/confusion_matrix.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "pW41VmqBr9Du" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "authorship_tag": "ABX9TyODci/IrsEqDNtNK1qO+UrK", + "gpuType": "T4", + "include_colab_link": true, + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/detect.py b/detect.py index 535e196fcd21..0fcfb881949c 100644 --- a/detect.py +++ b/detect.py @@ -72,8 +72,8 @@ def run( source=ROOT / "data/images", # file/dir/URL/glob/screen/0(webcam) data=ROOT / "data/coco128.yaml", # dataset.yaml path imgsz=(640, 640), # inference size (height, width) - conf_thres=0.25, # confidence threshold - iou_thres=0.45, # NMS IOU threshold + conf_thres=0.3, # confidence threshold + iou_thres=0.1, # NMS IOU threshold max_det=1000, # maximum detections per image device="", # cuda device, i.e. 0 or 0,1,2,3 or cpu view_img=False, # show results diff --git a/models/common.py b/models/common.py index 8bb9ca56d340..b5cfbbeae021 100644 --- a/models/common.py +++ b/models/common.py @@ -1109,3 +1109,137 @@ def forward(self, x): if isinstance(x, list): x = torch.cat(x, 1) return self.linear(self.drop(self.pool(self.conv(x)).flatten(1))) + + +class SE(nn.Module): + """Squeeze-and-Excitation (SE) block.""" + + def __init__(self, channels: int, reduction: int = 16): + super().__init__() + mid = max(1, channels // reduction) + self.avg_pool = nn.AdaptiveAvgPool2d(1) + self.fc = nn.Sequential( + nn.Linear(channels, mid, bias=False), + nn.ReLU(inplace=True), + nn.Linear(mid, channels, bias=False), + nn.Sigmoid(), + ) + + def forward(self, x): + b, c, _, _ = x.size() + y = self.avg_pool(x).view(b, c) + y = self.fc(y).view(b, c, 1, 1) + return x * y + + +class SEBottleneck(nn.Module): + """Bottleneck + SE. Aman dipakai di dalam C3SE karena biasanya c1 == c2 (hidden channels). Signature mengikuti + Bottleneck: (c1, c2, shortcut, g, e). + """ + + def __init__(self, c1, c2, shortcut=True, g=1, e=0.5, se_reduction=16): + super().__init__() + c_ = int(c2 * e) + self.cv1 = Conv(c1, c_, 1, 1) + self.cv2 = Conv(c_, c2, 3, 1, g=g) + self.add = shortcut and c1 == c2 + self.se = SE(c2, reduction=se_reduction) + + def forward(self, x): + y = self.cv2(self.cv1(x)) + y = self.se(y) + return x + y if self.add else y + + +class C3SE(C3): + """C3 module with SEBottleneck() inside (drop-in replacement for C3).""" + + def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5, se_reduction=16): + super().__init__(c1, c2, n, shortcut, g, e) + c_ = int(c2 * e) + self.m = nn.Sequential(*(SEBottleneck(c_, c_, shortcut, g, e=1.0, se_reduction=se_reduction) for _ in range(n))) + + +class ChannelAttention(nn.Module): + """CBAM Channel Attention.""" + + def __init__(self, in_planes: int, ratio: int = 16): + super().__init__() + mid = max(1, in_planes // ratio) + self.avg_pool = nn.AdaptiveAvgPool2d(1) + self.max_pool = nn.AdaptiveMaxPool2d(1) + self.f1 = nn.Conv2d(in_planes, mid, 1, bias=False) + self.relu = nn.ReLU(inplace=True) + self.f2 = nn.Conv2d(mid, in_planes, 1, bias=False) + self.sigmoid = nn.Sigmoid() + + def forward(self, x): + avg_out = self.f2(self.relu(self.f1(self.avg_pool(x)))) + max_out = self.f2(self.relu(self.f1(self.max_pool(x)))) + return self.sigmoid(avg_out + max_out) + + +class SpatialAttention(nn.Module): + """CBAM Spatial Attention.""" + + def __init__(self, kernel_size: int = 7): + super().__init__() + assert kernel_size in (3, 7), "kernel_size must be 3 or 7" + padding = 3 if kernel_size == 7 else 1 + self.conv = nn.Conv2d(2, 1, kernel_size, padding=padding, bias=False) + self.sigmoid = nn.Sigmoid() + + def forward(self, x): + avg_out = torch.mean(x, dim=1, keepdim=True) + max_out, _ = torch.max(x, dim=1, keepdim=True) + x = torch.cat([avg_out, max_out], dim=1) + x = self.conv(x) + return self.sigmoid(x) + + +class CBAM(nn.Module): + """CBAM block as a standalone layer (can be inserted in YAML). Signature dibuat kompatibel dengan pola YOLOv5: (c1, + c2, ...) Umumnya dipakai dengan c1 == c2. + """ + + def __init__(self, c1, c2=None, ratio=16, kernel_size=7): + super().__init__() + c2 = c1 if c2 is None else c2 + assert c1 == c2, "CBAM layer expects c1 == c2 (no channel change)." + self.ca = ChannelAttention(c1, ratio=ratio) + self.sa = SpatialAttention(kernel_size=kernel_size) + + def forward(self, x): + x = self.ca(x) * x + x = self.sa(x) * x + return x + + +class CBAMBottleneck(nn.Module): + """Bottleneck + CBAM (used inside C3CBAM).""" + + def __init__(self, c1, c2, shortcut=True, g=1, e=0.5, ratio=16, kernel_size=7): + super().__init__() + c_ = int(c2 * e) + self.cv1 = Conv(c1, c_, 1, 1) + self.cv2 = Conv(c_, c2, 3, 1, g=g) + self.add = shortcut and c1 == c2 + self.ca = ChannelAttention(c2, ratio=ratio) + self.sa = SpatialAttention(kernel_size=kernel_size) + + def forward(self, x): + y = self.cv2(self.cv1(x)) + y = self.ca(y) * y + y = self.sa(y) * y + return x + y if self.add else y + + +class C3CBAM(C3): + """C3 module with CBAMBottleneck() inside (drop-in replacement for C3).""" + + def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5, ratio=16, kernel_size=7): + super().__init__(c1, c2, n, shortcut, g, e) + c_ = int(c2 * e) + self.m = nn.Sequential( + *(CBAMBottleneck(c_, c_, shortcut, g, e=1.0, ratio=ratio, kernel_size=kernel_size) for _ in range(n)) + ) diff --git a/models/yolo.py b/models/yolo.py index 576e6a3621fe..820d9efc387e 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -27,14 +27,19 @@ from models.common import ( C3, + C3CBAM, + C3SE, C3SPP, C3TR, + CBAM, + SE, SPP, SPPF, Bottleneck, BottleneckCSP, C3Ghost, C3x, + CBAMBottleneck, Classify, Concat, Contract, @@ -48,6 +53,7 @@ GhostBottleneck, GhostConv, Proto, + SEBottleneck, ) from models.experimental import MixConv2d from utils.autoanchor import check_anchor_order @@ -421,6 +427,12 @@ def parse_model(d, ch): nn.ConvTranspose2d, DWConvTranspose2d, C3x, + SE, + SEBottleneck, + C3SE, + CBAM, + CBAMBottleneck, + C3CBAM, }: c1, c2 = ch[f], args[0] if c2 != no: # if not output diff --git a/models/yolov5s-c3se-backbone.yaml b/models/yolov5s-c3se-backbone.yaml new file mode 100644 index 000000000000..6df23db41cdd --- /dev/null +++ b/models/yolov5s-c3se-backbone.yaml @@ -0,0 +1,41 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Parameters +nc: 1 # number of classes +depth_multiple: 0.33 # model depth multiple +width_multiple: 0.50 # layer channel multiple +anchors: + - [10,13, 16,30, 33,23] # P3/8 + - [30,61, 62,45, 59,119] # P4/16 + - [116,90, 156,198, 373,326] # P5/32 +# YOLOv5 v6.0 backbone +backbone: + # [from, number, module, args] +  [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 +   [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 +   [-1, 3, C3SE, [128]], +   [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 +   [-1, 6, C3SE, [256]], +   [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 +   [-1, 9, C3SE, [512]], +   [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 +   [-1, 3, C3SE, [1024]], +   [-1, 1, SPPF, [1024, 5]], # 9 +  ] +# YOLOv5 v6.0 head +head: +  [[-1, 1, Conv, [512, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 6], 1, Concat, [1]], # cat backbone P4 +   [-1, 3, C3, [512, False]], # 13+1 +   [-1, 1, Conv, [256, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 4], 1, Concat, [1]], # cat backbone P3 +   [-1, 3, C3, [256, False]], # 17+1 (P3/8-small) +   [-1, 1, Conv, [256, 3, 2]], +   [[-1, 14], 1, Concat, [1]], # cat head P4 +   [-1, 3, C3, [512, False]], # 20+1 (P4/16-medium) +   [-1, 1, Conv, [512, 3, 2]], +   [[-1, 10], 1, Concat, [1]], # cat head P5 +   [-1, 3, C3, [1024, False]], # 23+1 (P5/32-large) +   [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) +  ] diff --git a/models/yolov5s-c3se.yaml b/models/yolov5s-c3se.yaml new file mode 100644 index 000000000000..fd57e95d447c --- /dev/null +++ b/models/yolov5s-c3se.yaml @@ -0,0 +1,41 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Parameters +nc: 1 # number of classes +depth_multiple: 0.33 # model depth multiple +width_multiple: 0.50 # layer channel multiple +anchors: + - [10,13, 16,30, 33,23] # P3/8 + - [30,61, 62,45, 59,119] # P4/16 + - [116,90, 156,198, 373,326] # P5/32 +# YOLOv5 v6.0 backbone +backbone: + # [from, number, module, args] +  [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 +   [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 +   [-1, 3, C3, [128]], +   [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 +   [-1, 6, C3, [256]], +   [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 +   [-1, 9, C3, [512]], +   [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 +   [-1, 3, C3SE, [1024]], +   [-1, 1, SPPF, [1024, 5]], # 9 +  ] +# YOLOv5 v6.0 head +head: +  [[-1, 1, Conv, [512, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 6], 1, Concat, [1]], # cat backbone P4 +   [-1, 3, C3, [512, False]], # 13+1 +   [-1, 1, Conv, [256, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 4], 1, Concat, [1]], # cat backbone P3 +   [-1, 3, C3, [256, False]], # 17+1 (P3/8-small) +   [-1, 1, Conv, [256, 3, 2]], +   [[-1, 14], 1, Concat, [1]], # cat head P4 +   [-1, 3, C3, [512, False]], # 20+1 (P4/16-medium) +   [-1, 1, Conv, [512, 3, 2]], +   [[-1, 10], 1, Concat, [1]], # cat head P5 +   [-1, 3, C3, [1024, False]], # 23+1 (P5/32-large) +   [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) +  ] diff --git a/models/yolov5s-cbam.yaml b/models/yolov5s-cbam.yaml new file mode 100644 index 000000000000..26bc71955324 --- /dev/null +++ b/models/yolov5s-cbam.yaml @@ -0,0 +1,42 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Parameters +nc: 1 # number of classes +depth_multiple: 0.33 # model depth multiple +width_multiple: 0.50 # layer channel multiple +anchors: + - [10,13, 16,30, 33,23] # P3/8 + - [30,61, 62,45, 59,119] # P4/16 + - [116,90, 156,198, 373,326] # P5/32 +# YOLOv5 v6.0 backbone +backbone: + # [from, number, module, args] +  [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 +   [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 +   [-1, 3, C3, [128]], +   [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 +   [-1, 6, C3, [256]], +   [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 +   [-1, 9, C3, [512]], +   [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 +   [-1, 3, C3, [1024]], +   [-1, 1, CBAM, [1024]], +   [-1, 1, SPPF, [1024, 5]], # 9+1 +  ] +# YOLOv5 v6.0 head +head: +  [[-1, 1, Conv, [512, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 6], 1, Concat, [1]], # cat backbone P4 +   [-1, 3, C3, [512, False]], # 13+1 +   [-1, 1, Conv, [256, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 4], 1, Concat, [1]], # cat backbone P3 +   [-1, 3, C3, [256, False]], # 17+1 (P3/8-small) +   [-1, 1, Conv, [256, 3, 2]], +   [[-1, 15], 1, Concat, [1]], # cat head P4 +   [-1, 3, C3, [512, False]], # 20+1 (P4/16-medium) +   [-1, 1, Conv, [512, 3, 2]], +   [[-1, 11], 1, Concat, [1]], # cat head P5 +   [-1, 3, C3, [1024, False]], # 23+1 (P5/32-large) +   [[18, 21, 24], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) +  ] diff --git a/models/yolov5s-se.yaml b/models/yolov5s-se.yaml new file mode 100644 index 000000000000..05bf91ec4867 --- /dev/null +++ b/models/yolov5s-se.yaml @@ -0,0 +1,42 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Parameters +nc: 1 # number of classes +depth_multiple: 0.33 # model depth multiple +width_multiple: 0.50 # layer channel multiple +anchors: + - [10,13, 16,30, 33,23] # P3/8 + - [30,61, 62,45, 59,119] # P4/16 + - [116,90, 156,198, 373,326] # P5/32 +# YOLOv5 v6.0 backbone +backbone: + # [from, number, module, args] +  [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 +   [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 +   [-1, 3, C3, [128]], +   [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 +   [-1, 6, C3, [256]], +   [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 +   [-1, 9, C3, [512]], +   [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 +   [-1, 3, C3, [1024]], +   [-1, 1, SE, [1024]], +   [-1, 1, SPPF, [1024, 5]], # 9+1 +  ] +# YOLOv5 v6.0 head +head: +  [[-1, 1, Conv, [512, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 6], 1, Concat, [1]], # cat backbone P4 +   [-1, 3, C3, [512, False]], # 13+1 +   [-1, 1, Conv, [256, 1, 1]], +   [-1, 1, nn.Upsample, [None, 2, 'nearest']], +   [[-1, 4], 1, Concat, [1]], # cat backbone P3 +   [-1, 3, C3, [256, False]], # 17+1 (P3/8-small) +   [-1, 1, Conv, [256, 3, 2]], +   [[-1, 15], 1, Concat, [1]], # cat head P4 +   [-1, 3, C3, [512, False]], # 20+1 (P4/16-medium) +   [-1, 1, Conv, [512, 3, 2]], +   [[-1, 11], 1, Concat, [1]], # cat head P5 +   [-1, 3, C3, [1024, False]], # 23+1 (P5/32-large) +   [[18, 21, 24], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) +  ] diff --git a/utils/metrics.py b/utils/metrics.py index e9b266e12a5f..974165a9525b 100644 --- a/utils/metrics.py +++ b/utils/metrics.py @@ -197,7 +197,7 @@ def tp_fp(self): return tp[:-1], fp[:-1] # remove background class @TryExcept("WARNING ⚠️ ConfusionMatrix plot failure") - def plot(self, normalize=True, save_dir="", names=()): + def plot(self, normalize=False, save_dir="", names=()): """Plots confusion matrix using seaborn, optional normalization; can save plot to specified directory.""" import seaborn as sn diff --git a/utils/plots.py b/utils/plots.py index 9324c5577446..cac6d19819ed 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -208,7 +208,7 @@ def plot_images(images, targets, paths=None, fname="images.jpg", names=None): color = colors(cls) cls = names[cls] if names else cls if labels or conf[j] > 0.25: # 0.25 conf thresh - label = f"{cls}" if labels else f"{cls} {conf[j]:.1f}" + label = f"{cls}" if labels else f"{cls} {conf[j]:.2f}" annotator.box_label(box, label, color=color) annotator.im.save(fname) # save diff --git a/val.py b/val.py index acbf687e9aab..50def20ab410 100644 --- a/val.py +++ b/val.py @@ -5,18 +5,13 @@ Usage: $ python val.py --weights yolov5s.pt --data coco128.yaml --img 640 -Usage - formats: - $ python val.py --weights yolov5s.pt # PyTorch - yolov5s.torchscript # TorchScript - yolov5s.onnx # ONNX Runtime or OpenCV DNN with --dnn - yolov5s_openvino_model # OpenVINO - yolov5s.engine # TensorRT - yolov5s.mlpackage # CoreML (macOS-only) - yolov5s_saved_model # TensorFlow SavedModel - yolov5s.pb # TensorFlow GraphDef - yolov5s.tflite # TensorFlow Lite - yolov5s_edgetpu.tflite # TensorFlow Edge TPU - yolov5s_paddle_model # PaddlePaddle +This revised version adds: + --save-per-image Save 1 visualization JPG per image (pred + labels) + --save-per-image-limit Limit number of images saved (default -1 = all) + +Outputs (when --save-per-image is used): + runs/val/exp*/per_image/pred/.jpg + runs/val/exp*/per_image/labels/.jpg """ import argparse @@ -62,29 +57,7 @@ def save_one_txt(predn, save_conf, shape, file): - """Saves one detection result to a txt file in normalized xywh format, optionally including confidence. - - Args: - predn (torch.Tensor): Predicted bounding boxes and associated confidence scores and classes in xyxy format, - tensor of shape (N, 6) where N is the number of detections. - save_conf (bool): If True, saves the confidence scores along with the bounding box coordinates. - shape (tuple): Shape of the original image as (height, width). - file (str | Path): File path where the result will be saved. - - Returns: - None - - Examples: - ```python - predn = torch.tensor([[10, 20, 30, 40, 0.9, 1]]) # example prediction - save_one_txt(predn, save_conf=True, shape=(640, 480), file="output.txt") - ``` - - Notes: - The xyxy bounding box format represents the coordinates (xmin, ymin, xmax, ymax). - The xywh format represents the coordinates (center_x, center_y, width, height) and is normalized by the width and - height of the image. - """ + """Saves one detection result to a txt file in normalized xywh format, optionally including confidence.""" gn = torch.tensor(shape)[[1, 0, 1, 0]] # normalization gain whwh for *xyxy, conf, cls in predn.tolist(): xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh @@ -94,37 +67,7 @@ def save_one_txt(predn, save_conf, shape, file): def save_one_json(predn, jdict, path, class_map): - """Saves a single JSON detection result, including image ID, category ID, bounding box, and confidence score. - - Args: - predn (torch.Tensor): Predicted detections in xyxy format with shape (n, 6) where n is the number of detections. - The tensor should contain [x_min, y_min, x_max, y_max, confidence, class_id] for each detection. - jdict (list[dict]): List to collect JSON formatted detection results. - path (pathlib.Path): Path object of the image file, used to extract image_id. - class_map (dict[int, int]): Mapping from model class indices to dataset-specific category IDs. - - Returns: - None: Appends detection results as dictionaries to `jdict` list in-place. - - Examples: - ```python - predn = torch.tensor([[100, 50, 200, 150, 0.9, 0], [50, 30, 100, 80, 0.8, 1]]) - jdict = [] - path = Path("42.jpg") - class_map = {0: 18, 1: 19} - save_one_json(predn, jdict, path, class_map) - ``` - This will append to `jdict`: - ``` - [ - {'image_id': 42, 'category_id': 18, 'bbox': [125.0, 75.0, 100.0, 100.0], 'score': 0.9}, - {'image_id': 42, 'category_id': 19, 'bbox': [75.0, 55.0, 50.0, 50.0], 'score': 0.8} - ] - ``` - - Notes: - The `bbox` values are formatted as [x, y, width, height], where x and y represent the top-left corner of the box. - """ + """Saves a single JSON detection result, including image ID, category ID, bounding box, and confidence score.""" image_id = int(path.stem) if path.stem.isnumeric() else path.stem box = xyxy2xywh(predn[:, :4]) # xywh box[:, :2] -= box[:, 2:] / 2 # xy center to top-left corner @@ -140,31 +83,7 @@ def save_one_json(predn, jdict, path, class_map): def process_batch(detections, labels, iouv): - """Return a correct prediction matrix given detections and labels at various IoU thresholds. - - Args: - detections (np.ndarray): Array of shape (N, 6) where each row corresponds to a detection with format [x1, y1, - x2, y2, conf, class]. - labels (np.ndarray): Array of shape (M, 5) where each row corresponds to a ground truth label with format - [class, x1, y1, x2, y2]. - iouv (np.ndarray): Array of IoU thresholds to evaluate at. - - Returns: - correct (np.ndarray): A binary array of shape (N, len(iouv)) indicating whether each detection is a true - positive for each IoU threshold. There are 10 IoU levels used in the evaluation. - - Examples: - ```python - detections = np.array([[50, 50, 200, 200, 0.9, 1], [30, 30, 150, 150, 0.7, 0]]) - labels = np.array([[1, 50, 50, 200, 200]]) - iouv = np.linspace(0.5, 0.95, 10) - correct = process_batch(detections, labels, iouv) - ``` - - Notes: - - This function is used as part of the evaluation pipeline for object detection models. - - IoU (Intersection over Union) is a common evaluation metric for object detection performance. - """ + """Return a correct prediction matrix given detections and labels at various IoU thresholds.""" correct = np.zeros((detections.shape[0], iouv.shape[0])).astype(bool) iou = box_iou(labels[:, 1:], detections[:, :4]) correct_class = labels[:, 0:1] == detections[:, 5] @@ -175,7 +94,6 @@ def process_batch(detections, labels, iouv): if x[0].shape[0] > 1: matches = matches[matches[:, 2].argsort()[::-1]] matches = matches[np.unique(matches[:, 1], return_index=True)[1]] - # matches = matches[matches[:, 2].argsort()[::-1]] matches = matches[np.unique(matches[:, 0], return_index=True)[1]] correct[matches[:, 1].astype(int), i] = True return torch.tensor(correct, dtype=torch.bool, device=iouv.device) @@ -211,93 +129,65 @@ def run( plots=True, callbacks=Callbacks(), compute_loss=None, + # NEW: + save_per_image=False, + save_per_image_limit=-1, ): - """Evaluates a YOLOv5 model on a dataset and logs performance metrics. - - Args: - data (str | dict): Path to a dataset YAML file or a dataset dictionary. - weights (str | list[str], optional): Path to the model weights file(s). Supports various formats including - PyTorch, TorchScript, ONNX, OpenVINO, TensorRT, CoreML, TensorFlow SavedModel, TensorFlow GraphDef, - TensorFlow Lite, TensorFlow Edge TPU, and PaddlePaddle. - batch_size (int, optional): Batch size for inference. Default is 32. - imgsz (int, optional): Input image size (pixels). Default is 640. - conf_thres (float, optional): Confidence threshold for object detection. Default is 0.001. - iou_thres (float, optional): IoU threshold for Non-Maximum Suppression (NMS). Default is 0.6. - max_det (int, optional): Maximum number of detections per image. Default is 300. - task (str, optional): Task type - 'train', 'val', 'test', 'speed', or 'study'. Default is 'val'. - device (str, optional): Device to use for computation, e.g., '0' or '0,1,2,3' for CUDA or 'cpu' for CPU. Default - is ''. - workers (int, optional): Number of dataloader workers. Default is 8. - single_cls (bool, optional): Treat dataset as a single class. Default is False. - augment (bool, optional): Enable augmented inference. Default is False. - verbose (bool, optional): Enable verbose output. Default is False. - save_txt (bool, optional): Save results to *.txt files. Default is False. - save_hybrid (bool, optional): Save label and prediction hybrid results to *.txt files. Default is False. - save_conf (bool, optional): Save confidences in --save-txt labels. Default is False. - save_json (bool, optional): Save a COCO-JSON results file. Default is False. - project (str | Path, optional): Directory to save results. Default is ROOT/'runs/val'. - name (str, optional): Name of the run. Default is 'exp'. - exist_ok (bool, optional): Overwrite existing project/name without incrementing. Default is False. - half (bool, optional): Use FP16 half-precision inference. Default is True. - dnn (bool, optional): Use OpenCV DNN for ONNX inference. Default is False. - model (torch.nn.Module, optional): Model object for training. Default is None. - dataloader (torch.utils.data.DataLoader, optional): Dataloader object. Default is None. - save_dir (Path, optional): Directory to save results. Default is Path(''). - plots (bool, optional): Plot validation images and metrics. Default is True. - callbacks (utils.callbacks.Callbacks, optional): Callbacks for logging and monitoring. Default is Callbacks(). - compute_loss (function, optional): Loss function for training. Default is None. - - Returns: - dict: Contains performance metrics including precision, recall, mAP50, and mAP50-95. - """ - # Initialize/load model and set device + """Evaluates a YOLOv5 model on a dataset and logs performance metrics.""" training = model is not None if training: # called by train.py - device, pt, jit, engine = next(model.parameters()).device, True, False, False # get model device, PyTorch model - half &= device.type != "cpu" # half precision only supported on CUDA + device, pt, jit, engine = next(model.parameters()).device, True, False, False + half &= device.type != "cpu" model.half() if half else model.float() else: # called directly device = select_device(device, batch_size=batch_size) # Directories - save_dir = increment_path(Path(project) / name, exist_ok=exist_ok) # increment run - (save_dir / "labels" if save_txt else save_dir).mkdir(parents=True, exist_ok=True) # make dir + save_dir = increment_path(Path(project) / name, exist_ok=exist_ok) + (save_dir / "labels" if save_txt else save_dir).mkdir(parents=True, exist_ok=True) + + # NEW: per-image visualization folders + per_img_pred_dir = save_dir / "per_image" / "pred" + per_img_lbl_dir = save_dir / "per_image" / "labels" + if save_per_image: + per_img_pred_dir.mkdir(parents=True, exist_ok=True) + per_img_lbl_dir.mkdir(parents=True, exist_ok=True) # Load model model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data, fp16=half) stride, pt, jit, engine = model.stride, model.pt, model.jit, model.engine - imgsz = check_img_size(imgsz, s=stride) # check image size - half = model.fp16 # FP16 supported on limited backends with CUDA + imgsz = check_img_size(imgsz, s=stride) + half = model.fp16 if engine: batch_size = model.batch_size else: device = model.device if not (pt or jit): - batch_size = 1 # export.py models default to batch-size 1 + batch_size = 1 LOGGER.info(f"Forcing --batch-size 1 square inference (1,3,{imgsz},{imgsz}) for non-PyTorch models") # Data - data = check_dataset(data) # check + data = check_dataset(data) # Configure model.eval() cuda = device.type != "cpu" - is_coco = isinstance(data.get("val"), str) and data["val"].endswith(f"coco{os.sep}val2017.txt") # COCO dataset - nc = 1 if single_cls else int(data["nc"]) # number of classes - iouv = torch.linspace(0.5, 0.95, 10, device=device) # iou vector for mAP@0.5:0.95 + is_coco = isinstance(data.get("val"), str) and data["val"].endswith(f"coco{os.sep}val2017.txt") + nc = 1 if single_cls else int(data["nc"]) + iouv = torch.linspace(0.5, 0.95, 10, device=device) niou = iouv.numel() # Dataloader if not training: - if pt and not single_cls: # check --weights are trained on --data + if pt and not single_cls: ncm = model.model.nc assert ncm == nc, ( - f"{weights} ({ncm} classes) trained on different --data than what you passed ({nc} " - f"classes). Pass correct combination of --weights and --data that are trained together." + f"{weights} ({ncm} classes) trained on different --data than what you passed ({nc} classes). " + f"Pass correct combination of --weights and --data that are trained together." ) - model.warmup(imgsz=(1 if pt else batch_size, 3, imgsz, imgsz)) # warmup - pad, rect = (0.0, False) if task == "speed" else (0.5, pt) # square inference for benchmarks - task = task if task in ("train", "val", "test") else "val" # path to train/val/test images + model.warmup(imgsz=(1 if pt else batch_size, 3, imgsz, imgsz)) + pad, rect = (0.0, False) if task == "speed" else (0.5, pt) + task = task if task in ("train", "val", "test") else "val" dataloader = create_dataloader( data[task], imgsz, @@ -312,26 +202,30 @@ def run( seen = 0 confusion_matrix = ConfusionMatrix(nc=nc) - names = model.names if hasattr(model, "names") else model.module.names # get class names - if isinstance(names, (list, tuple)): # old format + names = model.names if hasattr(model, "names") else model.module.names + if isinstance(names, (list, tuple)): names = dict(enumerate(names)) class_map = coco80_to_coco91_class() if is_coco else list(range(1000)) s = ("%22s" + "%11s" * 6) % ("Class", "Images", "Instances", "P", "R", "mAP50", "mAP50-95") tp, fp, p, r, f1, mp, mr, map50, ap50, map = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 - dt = Profile(device=device), Profile(device=device), Profile(device=device) # profiling times + dt = Profile(device=device), Profile(device=device), Profile(device=device) loss = torch.zeros(3, device=device) jdict, stats, ap, ap_class = [], [], [], [] callbacks.run("on_val_start") - pbar = tqdm(dataloader, desc=s, bar_format=TQDM_BAR_FORMAT) # progress bar + pbar = tqdm(dataloader, desc=s, bar_format=TQDM_BAR_FORMAT) + + # NEW: counter for how many images already saved (per-image mode) + per_image_saved = 0 + for batch_i, (im, targets, paths, shapes) in enumerate(pbar): callbacks.run("on_val_batch_start") with dt[0]: if cuda: im = im.to(device, non_blocking=True) targets = targets.to(device) - im = im.half() if half else im.float() # uint8 to fp16/32 - im /= 255 # 0 - 255 to 0.0 - 1.0 - nb, _, height, width = im.shape # batch size, channels, height, width + im = im.half() if half else im.float() + im /= 255 + nb, _, height, width = im.shape # Inference with dt[1]: @@ -339,11 +233,11 @@ def run( # Loss if compute_loss: - loss += compute_loss(train_out, targets)[1] # box, obj, cls + loss += compute_loss(train_out, targets)[1] # NMS - targets[:, 2:] *= torch.tensor((width, height, width, height), device=device) # to pixels - lb = [targets[targets[:, 0] == i, 1:] for i in range(nb)] if save_hybrid else [] # for autolabelling + targets[:, 2:] *= torch.tensor((width, height, width, height), device=device) + lb = [targets[targets[:, 0] == i, 1:] for i in range(nb)] if save_hybrid else [] with dt[2]: preds = non_max_suppression( preds, conf_thres, iou_thres, labels=lb, multi_label=True, agnostic=single_cls, max_det=max_det @@ -352,9 +246,9 @@ def run( # Metrics for si, pred in enumerate(preds): labels = targets[targets[:, 0] == si, 1:] - nl, npr = labels.shape[0], pred.shape[0] # number of labels, predictions + nl, npr = labels.shape[0], pred.shape[0] path, shape = Path(paths[si]), shapes[si][0] - correct = torch.zeros(npr, niou, dtype=torch.bool, device=device) # init + correct = torch.zeros(npr, niou, dtype=torch.bool, device=device) seen += 1 if npr == 0: @@ -362,49 +256,80 @@ def run( stats.append((correct, *torch.zeros((2, 0), device=device), labels[:, 0])) if plots: confusion_matrix.process_batch(detections=None, labels=labels[:, 0]) + # Even if no predictions, we still may want to save label-only image in per-image mode + if plots and save_per_image: + if save_per_image_limit < 0 or per_image_saved < save_per_image_limit: + im1 = im[si : si + 1] + t1 = targets[targets[:, 0] == si].clone() + if len(t1): + t1[:, 0] = 0 + plot_images(im1, t1, [str(path)], per_img_lbl_dir / f"{path.stem}.jpg", names) + # pred image (no detections) – still saved for parity + plot_images( + im1, output_to_target([pred]), [str(path)], per_img_pred_dir / f"{path.stem}.jpg", names + ) + per_image_saved += 1 continue # Predictions if single_cls: pred[:, 5] = 0 predn = pred.clone() - scale_boxes(im[si].shape[1:], predn[:, :4], shape, shapes[si][1]) # native-space pred + scale_boxes(im[si].shape[1:], predn[:, :4], shape, shapes[si][1]) # Evaluate if nl: - tbox = xywh2xyxy(labels[:, 1:5]) # target boxes - scale_boxes(im[si].shape[1:], tbox, shape, shapes[si][1]) # native-space labels - labelsn = torch.cat((labels[:, 0:1], tbox), 1) # native-space labels + tbox = xywh2xyxy(labels[:, 1:5]) + scale_boxes(im[si].shape[1:], tbox, shape, shapes[si][1]) + labelsn = torch.cat((labels[:, 0:1], tbox), 1) correct = process_batch(predn, labelsn, iouv) if plots: confusion_matrix.process_batch(predn, labelsn) - stats.append((correct, pred[:, 4], pred[:, 5], labels[:, 0])) # (correct, conf, pcls, tcls) + + stats.append((correct, pred[:, 4], pred[:, 5], labels[:, 0])) # Save/log if save_txt: (save_dir / "labels").mkdir(parents=True, exist_ok=True) save_one_txt(predn, save_conf, shape, file=save_dir / "labels" / f"{path.stem}.txt") if save_json: - save_one_json(predn, jdict, path, class_map) # append to COCO-JSON dictionary + save_one_json(predn, jdict, path, class_map) callbacks.run("on_val_image_end", pred, predn, path, names, im[si]) - # Plot images - if plots and batch_i < 3: - plot_images(im, targets, paths, save_dir / f"val_batch{batch_i}_labels.jpg", names) # labels - plot_images(im, output_to_target(preds), paths, save_dir / f"val_batch{batch_i}_pred.jpg", names) # pred + # NEW: Save per-image visualization (1 JPG per image) + if plots and save_per_image: + if save_per_image_limit < 0 or per_image_saved < save_per_image_limit: + im1 = im[si : si + 1] + t1 = targets[targets[:, 0] == si].clone() + if len(t1): + t1[:, 0] = 0 # reset index for single-image batch + + # Save GT overlay + plot_images(im1, t1, [str(path)], per_img_lbl_dir / f"{path.stem}.jpg", names) + # Save prediction overlay + plot_images( + im1, output_to_target([pred]), [str(path)], per_img_pred_dir / f"{path.stem}.jpg", names + ) + + per_image_saved += 1 + + # Batch grid plots (keep original behavior ONLY if not using per-image) + if plots and (not save_per_image) and batch_i < 3: + plot_images(im, targets, paths, save_dir / f"val_batch{batch_i}_labels.jpg", names) + plot_images(im, output_to_target(preds), paths, save_dir / f"val_batch{batch_i}_pred.jpg", names) callbacks.run("on_val_batch_end", batch_i, im, targets, paths, shapes, preds) # Compute metrics - stats = [torch.cat(x, 0).cpu().numpy() for x in zip(*stats)] # to numpy + stats = [torch.cat(x, 0).cpu().numpy() for x in zip(*stats)] if len(stats) and stats[0].any(): tp, fp, p, r, f1, ap, ap_class = ap_per_class(*stats, plot=plots, save_dir=save_dir, names=names) - ap50, ap = ap[:, 0], ap.mean(1) # AP@0.5, AP@0.5:0.95 + ap50, ap = ap[:, 0], ap.mean(1) mp, mr, map50, map = p.mean(), r.mean(), ap50.mean(), ap.mean() - nt = np.bincount(stats[3].astype(int), minlength=nc) # number of targets per class + nt = np.bincount(stats[3].astype(int), minlength=nc) # Print results - pf = "%22s" + "%11i" * 2 + "%11.3g" * 4 # print format + pf = "%22s" + "%11i" * 2 + "%11.3g" * 4 LOGGER.info(pf % ("all", seen, nt.sum(), mp, mr, map50, map)) if nt.sum() == 0: LOGGER.warning(f"WARNING ⚠️ no labels found in {task} set, can not compute metrics without labels") @@ -415,7 +340,7 @@ def run( LOGGER.info(pf % (names[c], seen, nt[c], p[i], r[i], ap50[i], ap[i])) # Print speeds - t = tuple(x.t / seen * 1e3 for x in dt) # speeds per image + t = tuple(x.t / seen * 1e3 for x in dt) if not training: shape = (batch_size, 3, imgsz, imgsz) LOGGER.info(f"Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {shape}" % t) @@ -427,37 +352,41 @@ def run( # Save JSON if save_json and len(jdict): - w = Path(weights[0] if isinstance(weights, list) else weights).stem if weights is not None else "" # weights - anno_json = str(Path("../datasets/coco/annotations/instances_val2017.json")) # annotations + w = Path(weights[0] if isinstance(weights, list) else weights).stem if weights is not None else "" + anno_json = str(Path("../datasets/coco/annotations/instances_val2017.json")) if not os.path.exists(anno_json): anno_json = os.path.join(data["path"], "annotations", "instances_val2017.json") - pred_json = str(save_dir / f"{w}_predictions.json") # predictions + pred_json = str(save_dir / f"{w}_predictions.json") LOGGER.info(f"\nEvaluating pycocotools mAP... saving {pred_json}...") with open(pred_json, "w") as f: json.dump(jdict, f) - try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb + try: check_requirements("pycocotools>=2.0.6") from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval - anno = COCO(anno_json) # init annotations api - pred = anno.loadRes(pred_json) # init predictions api + anno = COCO(anno_json) + pred = anno.loadRes(pred_json) eval = COCOeval(anno, pred, "bbox") if is_coco: - eval.params.imgIds = [int(Path(x).stem) for x in dataloader.dataset.im_files] # image IDs to evaluate + eval.params.imgIds = [int(Path(x).stem) for x in dataloader.dataset.im_files] eval.evaluate() eval.accumulate() eval.summarize() - map, map50 = eval.stats[:2] # update results (mAP@0.5:0.95, mAP@0.5) + map, map50 = eval.stats[:2] except Exception as e: LOGGER.info(f"pycocotools unable to run: {e}") # Return results - model.float() # for training + model.float() if not training: - s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else "" - LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}{s}") + s2 = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else "" + extra = "" + if save_per_image: + extra = f"\nPer-image visualizations saved to {save_dir / 'per_image'} (pred/labels)" + LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}{s2}{extra}") + maps = np.zeros(nc) + map for i, c in enumerate(ap_class): maps[c] = ap[i] @@ -465,52 +394,7 @@ def run( def parse_opt(): - """Parse command-line options for configuring YOLOv5 model inference. - - Args: - data (str, optional): Path to the dataset YAML file. Default is 'data/coco128.yaml'. - weights (list[str], optional): List of paths to model weight files. Default is 'yolov5s.pt'. - batch_size (int, optional): Batch size for inference. Default is 32. - imgsz (int, optional): Inference image size in pixels. Default is 640. - conf_thres (float, optional): Confidence threshold for predictions. Default is 0.001. - iou_thres (float, optional): IoU threshold for Non-Max Suppression (NMS). Default is 0.6. - max_det (int, optional): Maximum number of detections per image. Default is 300. - task (str, optional): Task type - options are 'train', 'val', 'test', 'speed', or 'study'. Default is 'val'. - device (str, optional): Device to run the model on. e.g., '0' or '0,1,2,3' or 'cpu'. Default is empty to let the - system choose automatically. - workers (int, optional): Maximum number of dataloader workers per rank in DDP mode. Default is 8. - single_cls (bool, optional): If set, treats the dataset as a single-class dataset. Default is False. - augment (bool, optional): If set, performs augmented inference. Default is False. - verbose (bool, optional): If set, reports mAP by class. Default is False. - save_txt (bool, optional): If set, saves results to *.txt files. Default is False. - save_hybrid (bool, optional): If set, saves label+prediction hybrid results to *.txt files. Default is False. - save_conf (bool, optional): If set, saves confidences in --save-txt labels. Default is False. - save_json (bool, optional): If set, saves results to a COCO-JSON file. Default is False. - project (str, optional): Project directory to save results to. Default is 'runs/val'. - name (str, optional): Name of the directory to save results to. Default is 'exp'. - exist_ok (bool, optional): If set, existing directory will not be incremented. Default is False. - half (bool, optional): If set, uses FP16 half-precision inference. Default is False. - dnn (bool, optional): If set, uses OpenCV DNN for ONNX inference. Default is False. - - Returns: - argparse.Namespace: Parsed command-line options. - - Examples: - To validate a trained YOLOv5 model on a COCO dataset: - ```python - $ python val.py --weights yolov5s.pt --data coco128.yaml --img 640 - ``` - Different model formats could be used instead of `yolov5s.pt`: - ```python - $ python val.py --weights yolov5s.pt yolov5s.torchscript yolov5s.onnx yolov5s_openvino_model yolov5s.engine - ``` - Additional options include saving results in different formats, selecting devices, and more. - - Notes: - - The '--data' parameter is checked to ensure it ends with 'coco.yaml' if '--save-json' is set. - - The '--save-txt' option is set to True if '--save-hybrid' is enabled. - - Args are printed using `print_args` to facilitate debugging. - """ + """Parse command-line options for configuring YOLOv5 validation.""" parser = argparse.ArgumentParser() parser.add_argument("--data", type=str, default=ROOT / "data/coco128.yaml", help="dataset.yaml path") parser.add_argument("--weights", nargs="+", type=str, default=ROOT / "yolov5s.pt", help="model path(s)") @@ -534,8 +418,22 @@ def parse_opt(): parser.add_argument("--exist-ok", action="store_true", help="existing project/name ok, do not increment") parser.add_argument("--half", action="store_true", help="use FP16 half-precision inference") parser.add_argument("--dnn", action="store_true", help="use OpenCV DNN for ONNX inference") + + # NEW: + parser.add_argument( + "--save-per-image", + action="store_true", + help="save per-image visualization (1 jpg per image) for predictions and labels", + ) + parser.add_argument( + "--save-per-image-limit", + type=int, + default=-1, + help="limit number of images saved (default=-1 means all)", + ) + opt = parser.parse_args() - opt.data = check_yaml(opt.data) # check YAML + opt.data = check_yaml(opt.data) opt.save_json |= opt.data.endswith("coco.yaml") opt.save_txt |= opt.save_hybrid print_args(vars(opt)) @@ -544,52 +442,33 @@ def parse_opt(): def main(opt): """Executes YOLOv5 tasks like training, validation, testing, speed, and study benchmarks based on provided options. - - Args: - opt (argparse.Namespace): Parsed command-line options. This includes values for parameters like 'data', - 'weights', 'batch_size', 'imgsz', 'conf_thres', 'iou_thres', 'max_det', 'task', 'device', 'workers', - 'single_cls', 'augment', 'verbose', 'save_txt', 'save_hybrid', 'save_conf', 'save_json', 'project', 'name', - 'exist_ok', 'half', and 'dnn', essential for configuring the YOLOv5 tasks. - - Returns: - None - - Examples: - To validate a trained YOLOv5 model on the COCO dataset with a specific weights file, use: - ```python - $ python val.py --weights yolov5s.pt --data coco128.yaml --img 640 - ``` """ check_requirements(ROOT / "requirements.txt", exclude=("tensorboard", "thop")) - if opt.task in ("train", "val", "test"): # run normally - if opt.conf_thres > 0.001: # https://github.com/ultralytics/yolov5/issues/1466 + if opt.task in ("train", "val", "test"): + if opt.conf_thres > 0.001: LOGGER.info(f"WARNING ⚠️ confidence threshold {opt.conf_thres} > 0.001 produces invalid results") if opt.save_hybrid: LOGGER.info("WARNING ⚠️ --save-hybrid will return high mAP from hybrid labels, not from predictions alone") run(**vars(opt)) - else: weights = opt.weights if isinstance(opt.weights, list) else [opt.weights] - opt.half = torch.cuda.is_available() and opt.device != "cpu" # FP16 for fastest results - if opt.task == "speed": # speed benchmarks - # python val.py --task speed --data coco.yaml --batch 1 --weights yolov5n.pt yolov5s.pt... + opt.half = torch.cuda.is_available() and opt.device != "cpu" + if opt.task == "speed": opt.conf_thres, opt.iou_thres, opt.save_json = 0.25, 0.45, False for opt.weights in weights: run(**vars(opt), plots=False) - - elif opt.task == "study": # speed vs mAP benchmarks - # python val.py --task study --data coco.yaml --iou 0.7 --weights yolov5n.pt yolov5s.pt... + elif opt.task == "study": for opt.weights in weights: - f = f"study_{Path(opt.data).stem}_{Path(opt.weights).stem}.txt" # filename to save to - x, y = list(range(256, 1536 + 128, 128)), [] # x axis (image sizes), y axis - for opt.imgsz in x: # img-size + f = f"study_{Path(opt.data).stem}_{Path(opt.weights).stem}.txt" + x, y = list(range(256, 1536 + 128, 128)), [] + for opt.imgsz in x: LOGGER.info(f"\nRunning {f} --imgsz {opt.imgsz}...") r, _, t = run(**vars(opt), plots=False) - y.append(r + t) # results and times - np.savetxt(f, y, fmt="%10.4g") # save + y.append(r + t) + np.savetxt(f, y, fmt="%10.4g") subprocess.run(["zip", "-r", "study.zip", "study_*.txt"]) - plot_val_study(x=x) # plot + plot_val_study(x=x) else: raise NotImplementedError(f'--task {opt.task} not in ("train", "val", "test", "speed", "study")')