Spaces:
Runtime error
Runtime error
File size: 42,591 Bytes
43a87b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"source": [
"## 1. 掛載雲端硬碟"
],
"metadata": {
"id": "JvFnrA5V65pO"
}
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vu6SEPk764ES",
"outputId": "98defb30-9be6-45bb-d950-d1d861639033"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 2. 安裝套件"
],
"metadata": {
"id": "eOlb0q627EZI"
}
},
{
"cell_type": "code",
"source": [
"!pip install --upgrade pyyaml==5.3.1"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "5SCKBEDB7EFG",
"outputId": "2fde67ff-35e0-47d9-89c8-2d353c58b93e"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting pyyaml==5.3.1\n",
" Downloading PyYAML-5.3.1.tar.gz (269 kB)\n",
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/269.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m \u001b[32m266.2/269.4 kB\u001b[0m \u001b[31m9.0 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m269.4/269.4 kB\u001b[0m \u001b[31m7.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h \u001b[1;31merror\u001b[0m: \u001b[1msubprocess-exited-with-error\u001b[0m\n",
" \n",
" \u001b[31m×\u001b[0m \u001b[32mpython setup.py egg_info\u001b[0m did not run successfully.\n",
" \u001b[31m│\u001b[0m exit code: \u001b[1;36m1\u001b[0m\n",
" \u001b[31m╰─>\u001b[0m See above for output.\n",
" \n",
" \u001b[1;35mnote\u001b[0m: This error originates from a subprocess, and is likely not a problem with pip.\n",
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25herror\n",
"\u001b[1;31merror\u001b[0m: \u001b[1mmetadata-generation-failed\u001b[0m\n",
"\n",
"\u001b[31m×\u001b[0m Encountered error while generating package metadata.\n",
"\u001b[31m╰─>\u001b[0m See above for output.\n",
"\n",
"\u001b[1;35mnote\u001b[0m: This is an issue with the package mentioned above, not pip.\n",
"\u001b[1;36mhint\u001b[0m: See above for details.\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 3. 下載程式碼"
],
"metadata": {
"id": "ngH7Q6Kx6f7m"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QA5CaOZY6aMM",
"outputId": "fbc42cd6-ac25-4351-bed7-2f433781a1ed"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/example/yolov7\n",
"/content/drive/MyDrive/example\n"
]
}
],
"source": [
"#顯示當前目錄\n",
"!pwd\n",
"\n",
"#切換目錄\n",
"%cd /content/drive/MyDrive/example"
]
},
{
"cell_type": "code",
"source": [
"# 從git上面下載程式碼(只要執行一次)\n",
"!git clone https://github.com/WongKinYiu/yolov7.git"
],
"metadata": {
"id": "VGe25V0bVkdb",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "6f897937-b800-4c81-8e43-4f4b58ded23c"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"fatal: destination path 'yolov7' already exists and is not an empty directory.\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 4. 下載已經使用coco dataset預先訓練好的權重\n",
"* 從 https://github.com/WongKinYiu/yolov7.git 上面去尋找連結"
],
"metadata": {
"id": "zdM561AuAUZc"
}
},
{
"cell_type": "code",
"source": [
"!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ffh4H-2E6eEo",
"outputId": "39d575b3-6988-4046-866c-e71e31552bf1"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"--2024-06-04 07:39:18-- https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt\n",
"Resolving github.com (github.com)... 20.205.243.166\n",
"Connecting to github.com (github.com)|20.205.243.166|:443... connected.\n",
"HTTP request sent, awaiting response... 302 Found\n",
"Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/511187726/b0243edf-9fb0-4337-95e1-42555f1b37cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240604%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240604T073918Z&X-Amz-Expires=300&X-Amz-Signature=a8e26a0d2ba27ab8566423ded52aeb9976e2fee7a53483137b1bee72606a3ad5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=511187726&response-content-disposition=attachment%3B%20filename%3Dyolov7.pt&response-content-type=application%2Foctet-stream [following]\n",
"--2024-06-04 07:39:18-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/511187726/b0243edf-9fb0-4337-95e1-42555f1b37cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240604%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240604T073918Z&X-Amz-Expires=300&X-Amz-Signature=a8e26a0d2ba27ab8566423ded52aeb9976e2fee7a53483137b1bee72606a3ad5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=511187726&response-content-disposition=attachment%3B%20filename%3Dyolov7.pt&response-content-type=application%2Foctet-stream\n",
"Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n",
"Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 75587165 (72M) [application/octet-stream]\n",
"Saving to: ‘yolov7.pt’\n",
"\n",
"yolov7.pt 100%[===================>] 72.08M 59.9MB/s in 1.2s \n",
"\n",
"2024-06-04 07:39:20 (59.9 MB/s) - ‘yolov7.pt’ saved [75587165/75587165]\n",
"\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 5. 上傳資料與新增設定檔"
],
"metadata": {
"id": "usnmC9u8AtTw"
}
},
{
"cell_type": "code",
"source": [
"#切換目錄到剛下載的git專案\n",
"%cd yolov7"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0FaLnNRP6eB9",
"outputId": "d99a8520-445f-4194-dbea-5e6eb7905b03"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/example/yolov7\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 6-1. 在./yolo/data/目錄底下手動建立資料夾 [project名稱]\n",
"## 6-2. 上傳訓練資料到./yolo/data/train跟 ./yolo/data/val/\n",
"## 6-3. 複製data目錄底下的coco.yaml, 改名為[project名稱].yaml\n",
"## 6-4. 編輯[project名稱].yaml裡面的參數\n",
"* train: ./data/[project名稱]/train\n",
"* val: ./data/[project名稱]/val\n",
"* test: ./data/[project名稱]/test\n",
"* nc: [總共有多少類別]\n",
"* names: [每個類別代表的英文名稱]\n",
"\n",
"## 6-5. 複製cfg/training目錄底下的yolov7.yaml 並改名為yolov7_[project名稱].yaml\n",
"## 6-6. 編輯yolov7_[project名稱].yaml\n",
"* nc: [總共有多少類別]"
],
"metadata": {
"id": "px5Ui1z691Gf"
}
},
{
"cell_type": "markdown",
"source": [
"## 7. 訓練模型"
],
"metadata": {
"id": "o1qlx6w0BIY4"
}
},
{
"cell_type": "code",
"source": [
"!pwd\n",
"\n",
"%cd /content/drive/MyDrive/example/yolov7"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Z-vgRl_mVUGk",
"outputId": "f9885773-741b-4c25-9c35-15e5519fc554"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/example/yolov7\n",
"/content/drive/MyDrive/example/yolov7\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!python train.py --device 0 \\\n",
"--batch-size 16 --epochs 20 \\\n",
"--data data/crosswalk.yaml --img 640 640 \\\n",
"--hyp data/hyp.scratch.custom.yaml --cfg cfg/training/yolov7.yaml \\\n",
"--weights 'yolov7.pt' --name yolov7-crosswalk"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "TtHOAGy56c2Q",
"outputId": "5ce0a0a8-d37f-46f2-f0b8-b1d8fcbc30d0"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"2024-06-04 08:36:55.417279: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
"2024-06-04 08:36:55.417338: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
"2024-06-04 08:36:55.418662: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
"2024-06-04 08:36:55.426203: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
"To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2024-06-04 08:36:56.637540: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n",
"YOLOR 🚀 v0.1-128-ga207844 torch 2.3.0+cu121 CUDA:0 (Tesla T4, 15102.0625MB)\n",
"\n",
"Namespace(weights='yolov7.pt', cfg='cfg/training/yolov7.yaml', data='data/crosswalk.yaml', hyp='data/hyp.scratch.custom.yaml', epochs=20, batch_size=16, img_size=[640, 640], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='0', multi_scale=False, single_cls=False, adam=False, sync_bn=False, local_rank=-1, workers=8, project='runs/train', entity=None, name='yolov7-crosswalk', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs/train/yolov7-crosswalk5', total_batch_size=16)\n",
"\u001b[34m\u001b[1mtensorboard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n",
"\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.1, 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.3, cls_pw=1.0, obj=0.7, 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.2, 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, paste_in=0.0, loss_ota=1\n",
"\u001b[34m\u001b[1mwandb: \u001b[0mInstall Weights & Biases for YOLOR logging with 'pip install wandb' (recommended)\n",
"\n",
" from n params module arguments \n",
" 0 -1 1 928 models.common.Conv [3, 32, 3, 1] \n",
" 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] \n",
" 2 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] \n",
" 4 -1 1 8320 models.common.Conv [128, 64, 1, 1] \n",
" 5 -2 1 8320 models.common.Conv [128, 64, 1, 1] \n",
" 6 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 7 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 8 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 9 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 10 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n",
" 11 -1 1 66048 models.common.Conv [256, 256, 1, 1] \n",
" 12 -1 1 0 models.common.MP [] \n",
" 13 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 14 -3 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 15 -1 1 147712 models.common.Conv [128, 128, 3, 2] \n",
" 16 [-1, -3] 1 0 models.common.Concat [1] \n",
" 17 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 18 -2 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 19 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 20 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 21 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 22 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 23 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n",
" 24 -1 1 263168 models.common.Conv [512, 512, 1, 1] \n",
" 25 -1 1 0 models.common.MP [] \n",
" 26 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 27 -3 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 28 -1 1 590336 models.common.Conv [256, 256, 3, 2] \n",
" 29 [-1, -3] 1 0 models.common.Concat [1] \n",
" 30 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 31 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 32 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 33 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 34 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 35 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 36 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n",
" 37 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1] \n",
" 38 -1 1 0 models.common.MP [] \n",
" 39 -1 1 525312 models.common.Conv [1024, 512, 1, 1] \n",
" 40 -3 1 525312 models.common.Conv [1024, 512, 1, 1] \n",
" 41 -1 1 2360320 models.common.Conv [512, 512, 3, 2] \n",
" 42 [-1, -3] 1 0 models.common.Concat [1] \n",
" 43 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n",
" 44 -2 1 262656 models.common.Conv [1024, 256, 1, 1] \n",
" 45 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 46 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 47 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 48 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 49 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n",
" 50 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1] \n",
" 51 -1 1 7609344 models.common.SPPCSPC [1024, 512, 1] \n",
" 52 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 53 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 54 37 1 262656 models.common.Conv [1024, 256, 1, 1] \n",
" 55 [-1, -2] 1 0 models.common.Concat [1] \n",
" 56 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 57 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 58 -1 1 295168 models.common.Conv [256, 128, 3, 1] \n",
" 59 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 60 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 61 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 62[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n",
" 63 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n",
" 64 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 65 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 66 24 1 65792 models.common.Conv [512, 128, 1, 1] \n",
" 67 [-1, -2] 1 0 models.common.Concat [1] \n",
" 68 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 69 -2 1 33024 models.common.Conv [256, 128, 1, 1] \n",
" 70 -1 1 73856 models.common.Conv [128, 64, 3, 1] \n",
" 71 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 72 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 73 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n",
" 74[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n",
" 75 -1 1 65792 models.common.Conv [512, 128, 1, 1] \n",
" 76 -1 1 0 models.common.MP [] \n",
" 77 -1 1 16640 models.common.Conv [128, 128, 1, 1] \n",
" 78 -3 1 16640 models.common.Conv [128, 128, 1, 1] \n",
" 79 -1 1 147712 models.common.Conv [128, 128, 3, 2] \n",
" 80 [-1, -3, 63] 1 0 models.common.Concat [1] \n",
" 81 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 82 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n",
" 83 -1 1 295168 models.common.Conv [256, 128, 3, 1] \n",
" 84 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 85 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 86 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n",
" 87[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n",
" 88 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n",
" 89 -1 1 0 models.common.MP [] \n",
" 90 -1 1 66048 models.common.Conv [256, 256, 1, 1] \n",
" 91 -3 1 66048 models.common.Conv [256, 256, 1, 1] \n",
" 92 -1 1 590336 models.common.Conv [256, 256, 3, 2] \n",
" 93 [-1, -3, 51] 1 0 models.common.Concat [1] \n",
" 94 -1 1 525312 models.common.Conv [1024, 512, 1, 1] \n",
" 95 -2 1 525312 models.common.Conv [1024, 512, 1, 1] \n",
" 96 -1 1 1180160 models.common.Conv [512, 256, 3, 1] \n",
" 97 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 98 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
" 99 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n",
"100[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n",
"101 -1 1 1049600 models.common.Conv [2048, 512, 1, 1] \n",
"102 75 1 328704 models.common.RepConv [128, 256, 3, 1] \n",
"103 88 1 1312768 models.common.RepConv [256, 512, 3, 1] \n",
"104 101 1 5246976 models.common.RepConv [512, 1024, 3, 1] \n",
"105 [102, 103, 104] 1 34156 models.yolo.IDetect [1, [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]], [256, 512, 1024]]\n",
"Model Summary: 415 layers, 37196556 parameters, 37196556 gradients\n",
"\n",
"Transferred 552/566 items from yolov7.pt\n",
"Scaled weight_decay = 0.0005\n",
"Optimizer groups: 95 .bias, 95 conv.weight, 98 other\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mScanning '/content/drive/MyDrive/example/dataset1/train/labels' images and labels... 354 found, 0 missing, 1 empty, 0 corrupted: 100% 354/354 [04:01<00:00, 1.47it/s]\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mNew cache created: /content/drive/MyDrive/example/dataset1/train/labels.cache\n",
"/usr/lib/python3.10/multiprocessing/popen_fork.py:66: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.\n",
" self.pid = os.fork()\n",
"\u001b[34m\u001b[1mval: \u001b[0mScanning '/content/drive/MyDrive/example/dataset1/valid/labels' images and labels... 101 found, 0 missing, 0 empty, 0 corrupted: 100% 101/101 [01:07<00:00, 1.50it/s]\n",
"\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /content/drive/MyDrive/example/dataset1/valid/labels.cache\n",
"\n",
"\u001b[34m\u001b[1mautoanchor: \u001b[0mAnalyzing anchors... anchors/target = 2.86, Best Possible Recall (BPR) = 0.9856\n",
"Image sizes 640 train, 640 test\n",
"Using 2 dataloader workers\n",
"Logging results to runs/train/yolov7-crosswalk5\n",
"Starting training for 20 epochs...\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 0/19 1G 0.07408 0.01941 0 0.0935 5 640: 100% 23/23 [00:57<00:00, 2.52s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 0% 0/4 [00:00<?, ?it/s]/usr/local/lib/python3.10/dist-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)\n",
" return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:11<00:00, 2.96s/it]\n",
" all 101 145 0.0261 0.0828 0.00967 0.00165\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 1/19 13G 0.06503 0.01499 0 0.08002 7 640: 100% 23/23 [00:34<00:00, 1.49s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.19s/it]\n",
" all 101 145 0.0327 0.262 0.016 0.00269\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 2/19 12.2G 0.05957 0.01349 0 0.07305 5 640: 100% 23/23 [00:29<00:00, 1.29s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.04s/it]\n",
" all 101 145 0.0773 0.131 0.0305 0.00698\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 3/19 12.2G 0.05641 0.01217 0 0.06859 5 640: 100% 23/23 [00:29<00:00, 1.27s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.16s/it]\n",
" all 101 145 0.144 0.172 0.0614 0.0174\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 4/19 12.2G 0.0603 0.01195 0 0.07224 8 640: 100% 23/23 [00:29<00:00, 1.30s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:05<00:00, 1.49s/it]\n",
" all 101 145 0.262 0.314 0.132 0.0444\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 5/19 12.2G 0.05356 0.01149 0 0.06505 6 640: 100% 23/23 [00:30<00:00, 1.33s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.21s/it]\n",
" all 101 145 0.484 0.441 0.351 0.146\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 6/19 12.2G 0.0552 0.009911 0 0.06511 4 640: 100% 23/23 [00:31<00:00, 1.37s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:05<00:00, 1.31s/it]\n",
" all 101 145 0.517 0.4 0.359 0.143\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 7/19 12.2G 0.05493 0.009802 0 0.06473 7 640: 100% 23/23 [00:29<00:00, 1.28s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.07s/it]\n",
" all 101 145 0.533 0.441 0.37 0.142\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 8/19 12.3G 0.0562 0.009743 0 0.06594 7 640: 100% 23/23 [00:29<00:00, 1.27s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.17it/s]\n",
" all 101 145 0.501 0.476 0.401 0.146\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 9/19 12.3G 0.05401 0.009289 0 0.0633 6 640: 100% 23/23 [00:30<00:00, 1.34s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.29it/s]\n",
" all 101 145 0.467 0.379 0.36 0.148\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 10/19 12.3G 0.05595 0.009192 0 0.06514 3 640: 100% 23/23 [00:29<00:00, 1.29s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:02<00:00, 1.40it/s]\n",
" all 101 145 0.532 0.392 0.386 0.16\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 11/19 12.3G 0.05449 0.009189 0 0.06368 3 640: 100% 23/23 [00:29<00:00, 1.30s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.16it/s]\n",
" all 101 145 0.483 0.297 0.297 0.106\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 12/19 12.3G 0.05591 0.009251 0 0.06516 4 640: 100% 23/23 [00:30<00:00, 1.34s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:02<00:00, 1.35it/s]\n",
" all 101 145 0.353 0.289 0.253 0.0839\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 13/19 12.3G 0.05664 0.009008 0 0.06565 7 640: 100% 23/23 [00:31<00:00, 1.38s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.33it/s]\n",
" all 101 145 0.671 0.428 0.463 0.2\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 14/19 12.3G 0.05176 0.009181 0 0.06094 7 640: 100% 23/23 [00:32<00:00, 1.41s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:02<00:00, 1.38it/s]\n",
" all 101 145 0.484 0.483 0.446 0.201\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 15/19 12.3G 0.04926 0.009321 0 0.05858 4 640: 100% 23/23 [00:32<00:00, 1.41s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.32it/s]\n",
" all 101 145 0.493 0.509 0.445 0.186\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 16/19 12.3G 0.05073 0.009481 0 0.06021 8 640: 100% 23/23 [00:29<00:00, 1.29s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:04<00:00, 1.03s/it]\n",
" all 101 145 0.581 0.49 0.491 0.236\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 17/19 12.3G 0.052 0.009147 0 0.06115 4 640: 100% 23/23 [00:31<00:00, 1.37s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:03<00:00, 1.13it/s]\n",
" all 101 145 0.54 0.586 0.525 0.23\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 18/19 12.3G 0.04705 0.009325 0 0.05638 6 640: 100% 23/23 [00:34<00:00, 1.48s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:02<00:00, 1.39it/s]\n",
" all 101 145 0.658 0.586 0.572 0.292\n",
"\n",
" Epoch gpu_mem box obj cls total labels img_size\n",
" 19/19 12.3G 0.05307 0.009194 0 0.06226 5 640: 100% 23/23 [00:35<00:00, 1.53s/it]\n",
" Class Images Labels P R [email protected] [email protected]:.95: 100% 4/4 [00:05<00:00, 1.36s/it]\n",
" all 101 145 0.77 0.531 0.578 0.309\n",
"20 epochs completed in 0.238 hours.\n",
"\n",
"Optimizer stripped from runs/train/yolov7-crosswalk5/weights/last.pt, 74.8MB\n",
"Optimizer stripped from runs/train/yolov7-crosswalk5/weights/best.pt, 74.8MB\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "NQKA4hYUX-CE"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 8. 預測影像"
],
"metadata": {
"id": "dAiCCP5SE5TR"
}
},
{
"cell_type": "code",
"source": [
"!python detect.py \\\n",
"--weight /content/drive/MyDrive/example/yolov7/runs/train/yolov7-crosswalk5/weights/best.pt \\\n",
"--conf 0.4 --img-size 640 \\\n",
"--source /content/drive/MyDrive/example/dataset1/test/images/fcfa0089-554b-47fc-b3f5-452e125913b4_jpg.rf.27db42514f441a4ab639887f45e51334.jpg --no-trace"
],
"metadata": {
"id": "fRG73MdTE6zT",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "453d6af1-796c-4fd7-a369-eb5f32cf475a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Namespace(weights=['/content/drive/MyDrive/example/yolov7/runs/train/yolov7-crosswalk5/weights/best.pt'], source='/content/drive/MyDrive/example/dataset1/test/images/fcfa0089-554b-47fc-b3f5-452e125913b4_jpg.rf.27db42514f441a4ab639887f45e51334.jpg', img_size=640, conf_thres=0.4, iou_thres=0.45, device='', view_img=False, save_txt=False, save_conf=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, no_trace=True)\n",
"YOLOR 🚀 v0.1-128-ga207844 torch 2.3.0+cu121 CUDA:0 (Tesla T4, 15102.0625MB)\n",
"\n",
"Fusing layers... \n",
"RepConv.fuse_repvgg_block\n",
"RepConv.fuse_repvgg_block\n",
"RepConv.fuse_repvgg_block\n",
"IDetect.fuse\n",
"Model Summary: 314 layers, 36481772 parameters, 6194944 gradients\n",
"/usr/local/lib/python3.10/dist-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)\n",
" return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]\n",
"1 crosswalk, Done. (22.1ms) Inference, (645.1ms) NMS\n",
" The image with the result is saved in: runs/detect/exp/fcfa0089-554b-47fc-b3f5-452e125913b4_jpg.rf.27db42514f441a4ab639887f45e51334.jpg\n",
"Done. (2.600s)\n"
]
}
]
}
]
} |