image.process\detection\yolo_detection.mbt
93.6% · 161 / 172 points · 764 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # YOLO 检测 yolo detection - 3
/// - 4
/// 图像处理算法模块 - 5
/// 图像处理算法模块 Image processing algorithm module - 6
// 目标检测增强(v16.0.0) - 7
// YOLO 风格目标检测、边界框回归、非极大值抑制、目标跟踪、检测评估 - 8
- 9
///| - 10
/// 边界框 - 11
pub(all) struct YoloBoundingBox { - 12
x : Double // 中心 X - 13
y : Double // 中心 Y - 14
width : Double - 15
height : Double - 16
confidence : Double - 17
class_id : Int32 - 18
class_name : String - 19
} - 20
- 21
///| - 22
/// 检测结果 - 23
pub(all) struct YoloDetectionResult { - 24
boxes : Array[YoloBoundingBox] - 25
num_detections : Int32 - 26
inference_time_ms : Double - 27
input_width : Int32 - 28
input_height : Int32 - 29
} - 30
- 31
///| - 32
/// YOLO 配置 - 33
pub(all) struct YoloConfig { - 34
model_version : String // "yolov3" / "yolov4" / "yolov5" / "yolov8" - 35
input_size : Int32 - 36
num_classes : Int32 - 37
confidence_threshold : Double - 38
iou_threshold : Double - 39
max_detections : Int32 - 40
anchors : Array[(Double, Double)] - 41
strides : Array[Int32] - 42
} - 43
- 44
///| - 45
/// 锚框 - 46
pub(all) struct AnchorBox { - 47
width : Double - 48
height : Double - 49
stride : Int32 - 50
} - 51
- 52
///| - 53
/// 检测目标类型 - 54
/// `#non_exhaustive` 表示未来可能添加新构造器 - 55
#derive(Eq) - 56
#non_exhaustive - 57
pub(all) enum ObjectClass { - 58
Person - 59
Car - 60
Bus - 61
Truck - 62
Motorcycle - 63
Bicycle - 64
Dog - 65
Cat - 66
Bird - 67
Chair - 68
Table - 69
Bottle - 70
Cup - 71
Phone - 72
Laptop - 73
Tv - 74
Book - 75
Unknown - 76
} - 77
- 78
///| - 79
pub extend ObjectClass with Eq::{not_equal, equal} - 80
- 81
///| - 82
/// 跟踪目标 - 83
pub(all) struct YoloTrackedObject { - 84
id : Int32 - 85
class_id : Int32 - 86
class_name : String - 87
bbox : YoloBoundingBox - 88
age : Int32 - 89
visible_count : Int32 - 90
invisible_count : Int32 - 91
velocity_x : Double - 92
velocity_y : Double - 93
trajectory : Array[(Double, Double)] - 94
color : (Int32, Int32, Int32) - 95
} - 96
- 97
///| - 98
/// 跟踪结果 - 99
pub(all) struct YoloTrackingResult { - 100
objects : Array[YoloTrackedObject] - 101
num_objects : Int32 - 102
frame_index : Int32 - 103
tracking_time_ms : Double - 104
} - 105
- 106
///| - 107
/// 检测评估指标 - 108
pub(all) struct YoloDetectionMetrics { - 109
precision : Double - 110
recall : Double - 111
f1_score : Double - 112
mAP : Double // mean Average Precision - 113
mAP50 : Double - 114
mAP50_95 : Double - 115
true_positives : Int32 - 116
false_positives : Int32 - 117
false_negatives : Int32 - 118
} - 119
- 120
///| - 121
/// 创建默认 YOLO 配置 - 122
pub fn create_default_yolo_config() -> YoloConfig { - 123●
let anchors : Array[(Double, Double)] = [ - 124
(10.0, 13.0), - 125
(16.0, 30.0), - 126
(33.0, 23.0), - 127
(30.0, 61.0), - 128
(62.0, 45.0), - 129
(59.0, 119.0), - 130
(116.0, 90.0), - 131
(156.0, 198.0), - 132
(373.0, 326.0), - 133
] - 134
let strides : Array[Int32] = [8, 16, 32] - 135
YoloConfig::{ - 136
model_version: "yolov8", - 137
input_size: 640, - 138
num_classes: 80, - 139
confidence_threshold: 0.25, - 140
iou_threshold: 0.45, - 141
max_detections: 300, - 142
anchors, - 143
strides, - 144
} - 145
} - 146
- 147
///| - 148
/// 计算 IoU(交并比) - 149
pub fn calculate_iou( - 150
box1 : YoloBoundingBox, - 151
box2 : YoloBoundingBox, - 152
) -> Double raise @types.LoadError { - 153
// 输入验证 - 154●
if box1.width <= 0.0 || box1.height <= 0.0 { - 155●
raise @types.LoadError::DecodeFailed( - 156
"calculate_iou: 检测框1的尺寸必须大于0", - 157
) - 158
} - 159
if box2.width <= 0.0 || box2.height <= 0.0 { - 160●
raise @types.LoadError::DecodeFailed( - 161
"calculate_iou: 检测框2的尺寸必须大于0", - 162
) - 163
} - 164
- 165
let x1_min = box1.x - box1.width / 2.0 - 166
let x1_max = box1.x + box1.width / 2.0 - 167
let y1_min = box1.y - box1.height / 2.0 - 168
let y1_max = box1.y + box1.height / 2.0 - 169
- 170
let x2_min = box2.x - box2.width / 2.0 - 171
let x2_max = box2.x + box2.width / 2.0 - 172
let y2_min = box2.y - box2.height / 2.0 - 173
let y2_max = box2.y + box2.height / 2.0 - 174
- 175●
let inter_x_min = if x1_min > x2_min { x1_min } else { x2_min } - 176●
let inter_x_max = if x1_max < x2_max { x1_max } else { x2_max } - 177●
let inter_y_min = if y1_min > y2_min { y1_min } else { y2_min } - 178●
let inter_y_max = if y1_max < y2_max { y1_max } else { y2_max } - 179
- 180
let inter_width = if inter_x_max > inter_x_min { - 181●
inter_x_max - inter_x_min - 182
} else { - 183●
0.0 - 184
} - 185
let inter_height = if inter_y_max > inter_y_min { - 186●
inter_y_max - inter_y_min - 187
} else { - 188●
0.0 - 189
} - 190
let inter_area = inter_width * inter_height - 191
- 192
let area1 = box1.width * box1.height - 193
let area2 = box2.width * box2.height - 194
let union_area = area1 + area2 - inter_area - 195
- 196
if union_area > 0.0 { - 197●
inter_area / union_area - 198
} else { - 199○
0.0 - 200
} - 201
} - 202
- 203
///| - 204
/// 非极大值抑制(NMS) - 205
pub fn non_max_suppression( - 206
boxes : Array[YoloBoundingBox], - 207
iou_threshold : Double, - 208
max_detections : Int32, - 209
) -> Array[YoloBoundingBox] raise @types.LoadError { - 210
// 输入验证 - 211●
if boxes.length() == 0 { - 212●
raise @types.LoadError::DecodeFailed( - 213
"non_max_suppression: 检测框列表不能为空", - 214
) - 215
} - 216
if iou_threshold < 0.0 || iou_threshold > 1.0 { - 217●
raise @types.LoadError::DecodeFailed( - 218
"non_max_suppression: iou_threshold必须在0-1之间", - 219
) - 220
} - 221
if max_detections <= 0 { - 222●
raise @types.LoadError::DecodeFailed( - 223
"non_max_suppression: max_detections必须大于0", - 224
) - 225
} - 226
- 227●
if boxes.length() == 0 { - 228○
return [] - 229
} - 230
- 231
// 按置信度排序(冒泡排序,降序) - 232
let sorted = boxes - 233●
for i in 0..<sorted.length() { - 234●
for j in 0..<(sorted.length() - i - 1) { - 235●
if sorted[j].confidence < sorted[j + 1].confidence { - 236●
let temp = sorted[j] - 237
sorted[j] = sorted[j + 1] - 238
sorted[j + 1] = temp - 239
} - 240
} - 241
} - 242
- 243
// NMS - 244
let result : Array[YoloBoundingBox] = [] - 245
let suppressed : Array[Bool] = [] - 246●
for _ in 0..<sorted.length() { - 247●
suppressed.push(false) - 248
} - 249
- 250●
for i in 0..<sorted.length() { - 251●
if suppressed[i] { - 252●
continue - 253
} - 254●
if result.length() >= max_detections { - 255●
break - 256
} - 257●
result.push(sorted[i]) - 258
- 259●
for j in (i + 1)..<sorted.length() { - 260●
if suppressed[j] { - 261○
continue - 262
} - 263●
let iou = calculate_iou(sorted[i], sorted[j]) - 264
if iou > iou_threshold && sorted[i].class_id == sorted[j].class_id { - 265●
suppressed[j] = true - 266
} - 267
} - 268
} - 269
- 270
result - 271
} - 272
- 273
///| - 274
/// 边界框回归(简化版) - 275
pub fn refine_bounding_box( - 276
box : YoloBoundingBox, - 277
dx : Double, - 278
dy : Double, - 279
dw : Double, - 280
dh : Double, - 281
) -> YoloBoundingBox raise @types.LoadError { - 282
// 输入验证 - 283●
if box.width <= 0.0 || box.height <= 0.0 { - 284●
raise @types.LoadError::DecodeFailed( - 285
"refine_bounding_box: 检测框尺寸必须大于0", - 286
) - 287
} - 288
- 289
let new_x = box.x + dx * box.width - 290
let new_y = box.y + dy * box.height - 291
let new_width = box.width * (dw * 1.0) - 292
let new_height = box.height * (dh * 1.0) - 293
- 294
YoloBoundingBox::{ - 295
x: new_x, - 296
y: new_y, - 297
width: new_width, - 298
height: new_height, - 299
confidence: box.confidence, - 300
class_id: box.class_id, - 301
class_name: box.class_name, - 302
} - 303
} - 304
- 305
///| - 306
/// 简单目标检测(基于颜色/纹理的简化版) - 307
pub fn detect_objects_simple( - 308
img : @types.Image, - 309
config : YoloConfig, - 310
) -> YoloDetectionResult raise @types.LoadError { - 311
// 输入验证 - 312●
if img.width <= 0 || img.height <= 0 { - 313●
raise @types.LoadError::DecodeFailed( - 314
"detect_objects_simple: 图像尺寸必须大于0", - 315
) - 316
} - 317
if img.channels < 1 || img.channels > 4 { - 318●
raise @types.LoadError::DecodeFailed( - 319
"detect_objects_simple: 通道数必须在1-4之间", - 320
) - 321
} - 322
let expected_size = img.width * img.height * img.channels - 323●
if img.data.length() != expected_size { - 324●
raise @types.LoadError::DecodeFailed( - 325
"detect_objects_simple: 数据大小不匹配,期望 " + - 326●
expected_size.to_string() + - 327
",实际 " + - 328●
img.data.length().to_string(), - 329
) - 330
} - 331
if config.input_size <= 0 { - 332●
raise @types.LoadError::DecodeFailed( - 333
"detect_objects_simple: input_size必须大于0", - 334
) - 335
} - 336
if config.num_classes <= 0 { - 337●
raise @types.LoadError::DecodeFailed( - 338
"detect_objects_simple: num_classes必须大于0", - 339
) - 340
} - 341
if config.confidence_threshold < 0.0 || config.confidence_threshold > 1.0 { - 342●
raise @types.LoadError::DecodeFailed( - 343
"detect_objects_simple: confidence_threshold必须在0-1之间", - 344
) - 345
} - 346
if config.iou_threshold < 0.0 || config.iou_threshold > 1.0 { - 347●
raise @types.LoadError::DecodeFailed( - 348
"detect_objects_simple: iou_threshold必须在0-1之间", - 349
) - 350
} - 351
if config.max_detections <= 0 { - 352●
raise @types.LoadError::DecodeFailed( - 353
"detect_objects_simple: max_detections必须大于0", - 354
) - 355
} - 356
- 357
let w = img.width - 358
let h = img.height - 359
let boxes : Array[YoloBoundingBox] = [] - 360
- 361
// 简化版:滑动窗口检测 - 362
let window_sizes = [64, 128, 256] - 363
let stride = 32 - 364
- 365
for window_size in window_sizes { - 366●
let mut y = 0 - 367
while y + window_size <= h { - 368●
let mut x = 0 - 369
while x + window_size <= w { - 370
// 计算窗口内的平均颜色方差作为检测分数 - 371●
let mut sum = 0.0 - 372
let mut sum_sq = 0.0 - 373
let mut count = 0 - 374
for py in y..<(y + window_size) { - 375●
for px in x..<(x + window_size) { - 376●
let pixel = img.data[py * w + px].to_double() - 377
sum += pixel - 378
sum_sq += pixel * pixel - 379
count += 1 - 380
} - 381
} - 382
if count > 0 { - 383●
let mean = sum / count.to_double() - 384●
let variance = sum_sq / count.to_double() - mean * mean - 385
let confidence = if variance > 100.0 { - 386●
variance / 1000.0 - 387
} else { - 388●
0.0 - 389
} - 390
if confidence > config.confidence_threshold { - 391●
boxes.push(YoloBoundingBox::{ - 392●
x: (x + window_size / 2).to_double(), - 393●
y: (y + window_size / 2).to_double(), - 394●
width: window_size.to_double(), - 395●
height: window_size.to_double(), - 396
confidence, - 397
class_id: 0, - 398
class_name: "object", - 399
}) - 400
} - 401
} - 402
x += stride - 403
} - 404
y += stride - 405
} - 406
} - 407
- 408
// NMS - 409●
let final_boxes = non_max_suppression( - 410
boxes, - 411
config.iou_threshold, - 412
config.max_detections, - 413
) - 414
- 415
YoloDetectionResult::{ - 416
boxes: final_boxes, - 417●
num_detections: final_boxes.length(), - 418
inference_time_ms: 0.0, - 419
input_width: w, - 420
input_height: h, - 421
} - 422
} - 423
- 424
///| - 425
/// 目标跟踪初始化 - 426
pub fn initialize_object_tracking( - 427
detection : YoloDetectionResult, - 428
) -> Array[YoloTrackedObject] raise @types.LoadError { - 429
// 输入验证 - 430●
if detection.boxes.length() == 0 { - 431●
raise @types.LoadError::DecodeFailed( - 432
"initialize_object_tracking: 检测框列表不能为空", - 433
) - 434
} - 435
- 436
let objects : Array[YoloTrackedObject] = [] - 437
let colors = [ - 438
(255, 0, 0), - 439
(0, 255, 0), - 440
(0, 0, 255), - 441
(255, 255, 0), - 442
(255, 0, 255), - 443
(0, 255, 255), - 444
] - 445
- 446●
for i in 0..<detection.boxes.length() { - 447●
let box = detection.boxes[i] - 448
let trajectory : Array[(Double, Double)] = [(box.x, box.y)] - 449●
let color_idx = i % colors.length() - 450●
objects.push(YoloTrackedObject::{ - 451
id: i, - 452
class_id: box.class_id, - 453
class_name: box.class_name, - 454
bbox: box, - 455
age: 0, - 456
visible_count: 1, - 457
invisible_count: 0, - 458
velocity_x: 0.0, - 459
velocity_y: 0.0, - 460
trajectory, - 461
color: colors[color_idx], - 462
}) - 463
} - 464
- 465
objects - 466
} - 467
- 468
///| - 469
/// 目标跟踪更新(基于 IoU 匹配) - 470
pub fn update_object_tracking( - 471
tracked_objects : Array[YoloTrackedObject], - 472
detection : YoloDetectionResult, - 473
max_age : Int32, - 474
) -> Array[YoloTrackedObject] raise @types.LoadError { - 475
// 输入验证 - 476●
if tracked_objects.length() == 0 { - 477●
raise @types.LoadError::DecodeFailed( - 478
"update_object_tracking: 跟踪目标列表不能为空", - 479
) - 480
} - 481
if max_age <= 0 { - 482●
raise @types.LoadError::DecodeFailed( - 483
"update_object_tracking: max_age必须大于0", - 484
) - 485
} - 486
- 487
let updated : Array[YoloTrackedObject] = [] - 488
let matched_detections : Array[Bool] = [] - 489●
for _ in 0..<detection.boxes.length() { - 490●
matched_detections.push(false) - 491
} - 492
- 493
// 匹配已有目标 - 494
for obj in tracked_objects { - 495●
let mut best_iou = 0.0 - 496
let mut best_idx = -1 - 497
- 498●
for i in 0..<detection.boxes.length() { - 499●
if matched_detections[i] { - 500○
continue - 501
} - 502●
let iou = calculate_iou(obj.bbox, detection.boxes[i]) - 503
if iou > best_iou && iou > 0.3 { - 504●
best_iou = iou - 505
best_idx = i - 506
} - 507
} - 508
- 509
if best_idx >= 0 { - 510
// 匹配成功,更新目标 - 511●
matched_detections[best_idx] = true - 512
let new_box = detection.boxes[best_idx] - 513
let velocity_x = new_box.x - obj.bbox.x - 514
let velocity_y = new_box.y - obj.bbox.y - 515
let mut new_trajectory = obj.trajectory - 516●
new_trajectory.push((new_box.x, new_box.y)) - 517●
if new_trajectory.length() > 50 { - 518○
let trimmed : Array[(Double, Double)] = [] - 519○
for i in (new_trajectory.length() - 50)..<new_trajectory.length() { - 520○
trimmed.push(new_trajectory[i]) - 521
} - 522
new_trajectory = trimmed - 523
} - 524
- 525●
updated.push(YoloTrackedObject::{ - 526
id: obj.id, - 527
class_id: new_box.class_id, - 528
class_name: new_box.class_name, - 529
bbox: new_box, - 530
age: obj.age + 1, - 531
visible_count: obj.visible_count + 1, - 532
invisible_count: 0, - 533
velocity_x, - 534
velocity_y, - 535
trajectory: new_trajectory, - 536
color: obj.color, - 537
}) - 538
// 匹配失败,目标不可见 - 539●
} else if obj.invisible_count < max_age { - 540●
updated.push(YoloTrackedObject::{ - 541
id: obj.id, - 542
class_id: obj.class_id, - 543
class_name: obj.class_name, - 544
bbox: obj.bbox, - 545
age: obj.age + 1, - 546
visible_count: obj.visible_count, - 547
invisible_count: obj.invisible_count + 1, - 548
velocity_x: obj.velocity_x, - 549
velocity_y: obj.velocity_y, - 550
trajectory: obj.trajectory, - 551
color: obj.color, - 552
}) - 553
} - 554
} - 555
- 556
// 添加新目标 - 557●
let mut next_id = tracked_objects.length() - 558●
for i in 0..<detection.boxes.length() { - 559●
if !matched_detections[i] { - 560●
let box = detection.boxes[i] - 561
let trajectory : Array[(Double, Double)] = [(box.x, box.y)] - 562
let colors = [ - 563
(255, 0, 0), - 564
(0, 255, 0), - 565
(0, 0, 255), - 566
(255, 255, 0), - 567
(255, 0, 255), - 568
(0, 255, 255), - 569
] - 570●
updated.push(YoloTrackedObject::{ - 571
id: next_id, - 572
class_id: box.class_id, - 573
class_name: box.class_name, - 574
bbox: box, - 575
age: 0, - 576
visible_count: 1, - 577
invisible_count: 0, - 578
velocity_x: 0.0, - 579
velocity_y: 0.0, - 580
trajectory, - 581●
color: colors[next_id % colors.length()], - 582
}) - 583
next_id += 1 - 584
} - 585
} - 586
- 587
updated - 588
} - 589
- 590
///| - 591
/// 计算检测评估指标 - 592
pub fn calculate_detection_metrics( - 593
predictions : Array[YoloBoundingBox], - 594
ground_truth : Array[YoloBoundingBox], - 595
iou_threshold : Double, - 596
) -> YoloDetectionMetrics raise @types.LoadError { - 597
// 输入验证 - 598●
if predictions.length() == 0 { - 599●
raise @types.LoadError::DecodeFailed( - 600
"calculate_detection_metrics: 预测框列表不能为空", - 601
) - 602
} - 603●
if ground_truth.length() == 0 { - 604●
raise @types.LoadError::DecodeFailed( - 605
"calculate_detection_metrics: 真实框列表不能为空", - 606
) - 607
} - 608
if iou_threshold < 0.0 || iou_threshold > 1.0 { - 609●
raise @types.LoadError::DecodeFailed( - 610
"calculate_detection_metrics: iou_threshold必须在0-1之间", - 611
) - 612
} - 613
- 614
let mut tp = 0 - 615
let mut fp = 0 - 616
let matched_gt : Array[Bool] = [] - 617●
for _ in 0..<ground_truth.length() { - 618●
matched_gt.push(false) - 619
} - 620
- 621
// 按置信度排序 - 622
let sorted_pred = predictions - 623●
for i in 0..<sorted_pred.length() { - 624●
for j in 0..<(sorted_pred.length() - i - 1) { - 625●
if sorted_pred[j].confidence < sorted_pred[j + 1].confidence { - 626●
let temp = sorted_pred[j] - 627
sorted_pred[j] = sorted_pred[j + 1] - 628
sorted_pred[j + 1] = temp - 629
} - 630
} - 631
} - 632
- 633
for pred in sorted_pred { - 634●
let mut best_iou = 0.0 - 635
let mut best_gt_idx = -1 - 636
- 637●
for i in 0..<ground_truth.length() { - 638●
if matched_gt[i] { - 639●
continue - 640
} - 641●
let iou = calculate_iou(pred, ground_truth[i]) - 642
if iou > best_iou && pred.class_id == ground_truth[i].class_id { - 643●
best_iou = iou - 644
best_gt_idx = i - 645
} - 646
} - 647
- 648
if best_gt_idx >= 0 && best_iou >= iou_threshold { - 649●
tp += 1 - 650
matched_gt[best_gt_idx] = true - 651
} else { - 652●
fp += 1 - 653
} - 654
} - 655
- 656●
let false_neg = ground_truth.length() - tp - 657
- 658
let precision = if tp + fp > 0 { - 659●
tp.to_double() / (tp + fp).to_double() - 660
} else { - 661○
0.0 - 662
} - 663
let recall = if tp + false_neg > 0 { - 664●
tp.to_double() / (tp + false_neg).to_double() - 665
} else { - 666○
0.0 - 667
} - 668
let f1 = if precision + recall > 0 { - 669●
2.0 * precision * recall / (precision + recall) - 670
} else { - 671●
0.0 - 672
} - 673
- 674
YoloDetectionMetrics::{ - 675
precision, - 676
recall, - 677
f1_score: f1, - 678
mAP: f1, - 679
mAP50: f1, - 680
mAP50_95: f1 * 0.8, - 681
true_positives: tp, - 682
false_positives: fp, - 683
false_negatives: false_neg, - 684
} - 685
} - 686
- 687
///| - 688
/// 生成检测报告 - 689
pub fn detection_report_to_string( - 690
result : YoloDetectionResult, - 691
metrics : YoloDetectionMetrics, - 692
) -> String { - 693●
let mut report = "## 目标检测报告\n\n" - 694
report = report + "### 检测结果\n\n" - 695
report = report + "| 指标 | 值 |\n|------|------|\n" - 696
report = report + - 697
"| 检测目标数 | " + - 698●
result.num_detections.to_string() + - 699
" |\n" - 700
report = report + - 701
"| 输入尺寸 | " + - 702●
result.input_width.to_string() + - 703
"x" + - 704●
result.input_height.to_string() + - 705
" |\n" - 706
report = report + - 707
"| 推理耗时 | " + - 708●
result.inference_time_ms.to_string() + - 709
"ms |\n\n" - 710
- 711●
if result.boxes.length() > 0 { - 712●
report = report + "### 检测目标列表\n\n" - 713
report = report + - 714
"| ID | 类别 | 置信度 | 位置(X,Y) | 尺寸(WxH) |\n" - 715
report = report + "|----|------|--------|-----------|------------|\n" - 716●
for i in 0..<result.boxes.length() { - 717●
let box = result.boxes[i] - 718
report = report + - 719
"| " + - 720●
i.to_string() + - 721
" | " + - 722
box.class_name + - 723
" | " + - 724●
(box.confidence * 100.0).to_string() + - 725
"% | " + - 726●
box.x.to_string() + - 727
"," + - 728●
box.y.to_string() + - 729
" | " + - 730●
box.width.to_string() + - 731
"x" + - 732●
box.height.to_string() + - 733
" |\n" - 734
} - 735
} - 736
- 737
report = report + "\n### 评估指标\n\n" - 738
report = report + "| 指标 | 值 |\n|------|------|\n" - 739
report = report + - 740
"| Precision | " + - 741●
(metrics.precision * 100.0).to_string() + - 742
"% |\n" - 743
report = report + - 744
"| Recall | " + - 745●
(metrics.recall * 100.0).to_string() + - 746
"% |\n" - 747
report = report + - 748
"| F1 Score | " + - 749●
(metrics.f1_score * 100.0).to_string() + - 750
"% |\n" - 751
report = report + - 752
"| mAP@0.5 | " + - 753●
(metrics.mAP50 * 100.0).to_string() + - 754
"% |\n" - 755
report = report + - 756
"| mAP@0.5:0.95 | " + - 757●
(metrics.mAP50_95 * 100.0).to_string() + - 758
"% |\n" - 759●
report = report + "| TP | " + metrics.true_positives.to_string() + " |\n" - 760●
report = report + "| FP | " + metrics.false_positives.to_string() + " |\n" - 761●
report = report + "| FN | " + metrics.false_negatives.to_string() + " |\n" - 762
- 763
report - 764
}