─░├žeri─če ge├ž

Test S├╝resi Art─▒r─▒m─▒ (TTA)

­čôÜ Bu k─▒lavuz, YOLOv5 ­čÜÇ ile daha iyi mAP ve Geri ├ça─č─▒rma i├žin test ve ├ž─▒kar─▒m s─▒ras─▒nda Test S├╝resi Art─▒r─▒m─▒n─▒n (TTA) nas─▒l kullan─▒laca─č─▒n─▒ a├ž─▒klar.

Ba┼člamadan ├ľnce

Repoyu klonlay─▒n ve requirements.txt dosyas─▒n─▒ bir Python>=3.8.0 ortam─▒ dahil olmak ├╝zere PyTorch>=1.8. Modeller ve veri setleri en son YOLOv5 s├╝r├╝m├╝nden otomatik olarak indirilir.

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Normal Test

TTA'y─▒ denemeden ├Ânce kar┼č─▒la┼čt─▒rma yapabilece─čimiz bir temel performans belirlemek istiyoruz. Bu komut YOLOv5x'i COCO val2017 ├╝zerinde 640 piksel g├Âr├╝nt├╝ boyutunda test eder. yolov5x.pt mevcut en b├╝y├╝k ve en do─čru modeldir. Di─čer se├ženekler yolov5s.pt, yolov5m.pt ve yolov5l.ptveya ├Âzel bir veri k├╝mesinin e─čitiminden elde etti─činiz kendi kontrol noktan─▒z ./weights/best.pt. Mevcut t├╝m modellerle ilgili ayr─▒nt─▒lar i├žin l├╝tfen README'ye bak─▒n masa.

python val.py --weights yolov5x.pt --data coco.yaml --img 640 --half

Çıktı:

val: data=./data/coco.yaml, weights=['yolov5x.pt'], batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.65, task=val, device=, single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=True, project=runs/val, name=exp, exist_ok=False, half=True
YOLOv5 ­čÜÇ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers...
Model Summary: 476 layers, 87730285 parameters, 0 gradients

val: Scanning '../datasets/coco/val2017' images and labels...4952 found, 48 missing, 0 empty, 0 corrupted: 100% 5000/5000 [00:01<00:00, 2846.03it/s]
val: New cache created: ../datasets/coco/val2017.cache
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 157/157 [02:30<00:00,  1.05it/s]
                 all       5000      36335      0.746      0.626       0.68       0.49
Speed: 0.1ms pre-process, 22.4ms inference, 1.4ms NMS per image at shape (32, 3, 640, 640)  # <--- baseline speed

Evaluating pycocotools mAP... saving runs/val/exp/yolov5x_predictions.json...
...
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.504  # <--- baseline mAP
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.688
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.546
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.351
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.551
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.644
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.382
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.628
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.681  # <--- baseline mAR
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.524
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.735
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.826

TTA ile test edin

Ekleme --augment mevcut herhangi bir val.py komutunu kullanarak TTA'y─▒ etkinle┼čtirin ve daha iyi sonu├žlar i├žin g├Âr├╝nt├╝ boyutunu yakla┼č─▒k %30 art─▒r─▒n. G├Âr├╝nt├╝ler sola-sa─ča ├ževrilip 3 farkl─▒ ├ž├Âz├╝n├╝rl├╝kte i┼člendi─činden ve ├ž─▒kt─▒lar NMS'den ├Ânce birle┼čtirildi─činden, TTA etkinken ├ž─▒kar─▒m─▒n normal ├ž─▒kar─▒m─▒n yakla┼č─▒k 2-3 kat─▒ zaman alaca─č─▒n─▒ unutmay─▒n. H─▒z d├╝┼č├╝┼č├╝n├╝n bir k─▒sm─▒ daha b├╝y├╝k g├Âr├╝nt├╝ boyutlar─▒ndan (832'ye kar┼č─▒ 640) kaynaklan─▒rken, bir k─▒sm─▒ da ger├žek TTA i┼člemlerinden kaynaklanmaktad─▒r.

python val.py --weights yolov5x.pt --data coco.yaml --img 832 --augment --half

Çıktı:

val: data=./data/coco.yaml, weights=['yolov5x.pt'], batch_size=32, imgsz=832, conf_thres=0.001, iou_thres=0.6, task=val, device=, single_cls=False, augment=True, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=True, project=runs/val, name=exp, exist_ok=False, half=True
YOLOv5 ­čÜÇ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers...
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /pytorch/c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Model Summary: 476 layers, 87730285 parameters, 0 gradients
val: Scanning '../datasets/coco/val2017' images and labels...4952 found, 48 missing, 0 empty, 0 corrupted: 100% 5000/5000 [00:01<00:00, 2885.61it/s]
val: New cache created: ../datasets/coco/val2017.cache
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 157/157 [07:29<00:00,  2.86s/it]
                 all       5000      36335      0.718      0.656      0.695      0.503
Speed: 0.2ms pre-process, 80.6ms inference, 2.7ms NMS per image at shape (32, 3, 832, 832)  # <--- TTA speed

Evaluating pycocotools mAP... saving runs/val/exp2/yolov5x_predictions.json...
...
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.516  # <--- TTA mAP
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.701
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.562
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.361
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.656
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.388
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.640
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.696  # <--- TTA mAR
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.553
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.744
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.833

TTA ile Çıkarım

detect.py TTA ├ž─▒kar─▒m─▒ ┼ču ┼čekilde ├žal─▒┼č─▒r val.py TTA: basit├že ekleyin --augment mevcut herhangi bir detect.py Komuta:

python detect.py --weights yolov5s.pt --img 832 --source data/images --augment

Çıktı:

YOLOv5 ­čÜÇ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Downloading https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt to yolov5s.pt...
100% 14.1M/14.1M [00:00<00:00, 81.9MB/s]

Fusing layers...
Model Summary: 224 layers, 7266973 parameters, 0 gradients
image 1/2 /content/yolov5/data/images/bus.jpg: 832x640 4 persons, 1 bus, 1 fire hydrant, Done. (0.029s)
image 2/2 /content/yolov5/data/images/zidane.jpg: 480x832 3 persons, 3 ties, Done. (0.024s)
Results saved to runs/detect/exp
Done. (0.156s)

YOLOv5 test s├╝resi art─▒r─▒mlar─▒

PyTorch Hub TTA

TTA otomatik olarak t├╝m YOLOv5 PyTorch Hub modellerine eri┼čilebilir ve bu modellere augment=True ├ž─▒kar─▒m zaman─▒nda.

import torch

# Model
model = torch.hub.load("ultralytics/yolov5", "yolov5s")  # or yolov5m, yolov5x, custom

# Images
img = "https://ultralytics.com/images/zidane.jpg"  # or file, PIL, OpenCV, numpy, multiple

# Inference
results = model(img, augment=True)  # <--- TTA inference

# Results
results.print()  # or .show(), .save(), .crop(), .pandas(), etc.

├ľzelle┼čtirme

Uygulanan TTA i┼člemlerini ┼ču ┼čekilde ├Âzelle┼čtirebilirsiniz YOLOv5 forward_augment() y├Ântem Burada.

Desteklenen Ortamlar

Ultralytics her biri CUDA, CUDNN gibi temel ba─č─▒ml─▒l─▒klarla ├Ânceden y├╝klenmi┼č bir dizi kullan─▒ma haz─▒r ortam sa─člar, Pythonve PyTorchProjelerinizi ba┼člatmak i├žin.

Proje Durumu

YOLOv5 CI

Bu rozet, t├╝m YOLOv5 GitHub Actions S├╝rekli Entegrasyon (CI) testlerinin ba┼čar─▒yla ge├žti─čini g├Âsterir. Bu CI testleri, YOLOv5 'un i┼člevselli─čini ve performans─▒n─▒ ├že┼čitli temel y├Ânlerden titizlikle kontrol eder: e─čitim, do─črulama, ├ž─▒kar─▒m, d─▒┼ča aktarma ve k─▒yaslamalar. Her 24 saatte bir ve her yeni i┼člemde yap─▒lan testlerle macOS, Windows ve Ubuntu ├╝zerinde tutarl─▒ ve g├╝venilir ├žal─▒┼čma sa─člarlar.



Created 2023-11-12, Updated 2024-06-02
Authors: glenn-jocher (6)

Yorumlar