diff --git a/mmp/a4/dataset.py b/mmp/a4/dataset.py index d2cc72b..4d33016 100644 --- a/mmp/a4/dataset.py +++ b/mmp/a4/dataset.py @@ -5,7 +5,7 @@ import numpy as np import torch from torch.utils.data import DataLoader from ..a3.annotation import read_groundtruth_file, AnnotationRect -from .label_grid import get_label_grid, iou +from .label_grid import get_label_grid import matplotlib.pyplot as plt import matplotlib.patches as patches from .anchor_grid import get_anchor_grid @@ -178,7 +178,6 @@ def compute_ious_vectorized(boxes1, boxes2): boxes1: (M, 4), boxes2: (N, 4) -- format [x1, y1, x2, y2] Returns: (M, N) IoU """ - M, N = boxes1.shape[0], boxes2.shape[0] # Expand to (M, N, 4) boxes1 = boxes1[:, None, :] # (M, 1, 4) diff --git a/mmp/a5/main.py b/mmp/a5/main.py index 0905199..2c6b240 100644 --- a/mmp/a5/main.py +++ b/mmp/a5/main.py @@ -3,7 +3,6 @@ import torch import torch.optim as optim import torch.nn as nn from torch.utils.data import DataLoader -from torch import Tensor from tqdm import tqdm import datetime @@ -11,6 +10,7 @@ from .model import MmpNet from ..a4.anchor_grid import get_anchor_grid from ..a4.dataset import get_dataloader from ..a2.main import get_criterion_optimizer +from ..a6.main import evaluate as evaluate_v2 def step( @@ -65,44 +65,11 @@ def get_random_sampling_mask(labels: torch.Tensor, neg_ratio: float) -> torch.Te return mask -def get_detection_metrics( - output: Tensor, labels: torch.Tensor, threshold: float -) -> tuple[float, float, float, float]: - """ - Returns precision, recall, f1 for the positive (human) class, and overall accuracy. - """ - with torch.no_grad(): - probs = torch.softmax(output, dim=-1)[..., 1] - - preds = probs >= threshold - - TP = ((preds == 1) & (labels == 1)).sum().item() - FP = ((preds == 1) & (labels == 0)).sum().item() - FN = ((preds == 0) & (labels == 1)).sum().item() - TN = ((preds == 0) & (labels == 0)).sum().item() - - precision = TP / (TP + FP) if (TP + FP) > 0 else 0.0 - recall = TP / (TP + FN) if (TP + FN) > 0 else 0.0 - f1 = ( - 2 * precision * recall / (precision + recall) - if (precision + recall) > 0 - else 0.0 - ) - accuracy = (TP + TN) / (TP + TN + FP + FN) if (TP + TN + FP + FN) > 0 else 0.0 - - return ( - precision, - recall, - f1, - accuracy, - ) - - def evaluate( model: MmpNet, criterion, dataloader: DataLoader, -) -> tuple[float, float, float, float]: +) -> float: device = next(model.parameters()).device model.eval() total_loss = 0.0 @@ -123,15 +90,7 @@ def evaluate( all_outputs.append(outputs.cpu()) all_labels.append(lbl_batch.cpu()) avg_loss = total_loss / total_samples if total_samples > 0 else 0.0 - if all_outputs and all_labels: - outputs_cat = torch.cat(all_outputs) - labels_cat = torch.cat(all_labels) - precision, recall, f1, acc = get_detection_metrics( - outputs_cat, labels_cat, threshold=0.5 - ) - else: - precision = recall = f1 = 0.0 - return avg_loss, precision, recall, f1, acc + return avg_loss def train( @@ -243,7 +202,7 @@ def main(): _, optimizer = get_criterion_optimizer(model=model) criterion = NegativeMiningCriterion(enable_negative_mining=True) criterion_eval = NegativeMiningCriterion(enable_negative_mining=False) - num_epochs = 10 + num_epochs = 5 for epoch in range(num_epochs): train_loss = train( @@ -252,17 +211,16 @@ def main(): criterion=criterion, optimizer=optimizer, ) - avg_loss, precision, recall, f1, acc = evaluate( + avg_loss = evaluate( model=model, criterion=criterion_eval, dataloader=dataloader_val ) + _ = evaluate_v2( + model=model, device=device, anchor_grid=anchor_grid, loader=dataloader_train + ) if writer is not None: writer.add_scalar("Loss/train_epoch", train_loss, epoch) writer.add_scalar("Loss/eval_epoch", avg_loss, epoch) - writer.add_scalar("Acc/precision", precision, epoch) - writer.add_scalar("Acc/recall", recall, epoch) - writer.add_scalar("Acc/acc", acc, epoch) - writer.add_scalar("Acc/f1", f1, epoch) if writer is not None: writer.close() diff --git a/mmp/a6/__init__.py b/mmp/a6/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mmp/a6/main.py b/mmp/a6/main.py index cd3a4ff..8049bdd 100644 --- a/mmp/a6/main.py +++ b/mmp/a6/main.py @@ -1,25 +1,144 @@ from typing import List, Tuple import torch import numpy as np +from tqdm import tqdm +import os + +from torch.utils.data import DataLoader + +from mmp.a6.evallib import calculate_ap_pr +from ..a4.label_grid import iou from ..a5.model import MmpNet -from ..a3.annotation import AnnotationRect +from ..a3.annotation import AnnotationRect, read_groundtruth_file + +from .nms import non_maximum_suppression def batch_inference( model: MmpNet, images: torch.Tensor, device: torch.device, anchor_grid: np.ndarray ) -> List[List[Tuple[AnnotationRect, float]]]: - raise NotImplementedError() + score_thresh = 0.5 + nms_thresh = 0.3 + + model = model.to(device) + model.eval() + images = images.to(device) + anchor_grid = anchor_grid # shape [W, R, h, w, 4] + + results = [] + with torch.no_grad(): + outputs = model(images) # (B, W, R, h, w, 2) + probs = torch.softmax(outputs, dim=-1)[..., 1] # (B, W, R, h, w) + probs_np = probs.cpu().numpy() + + batch_size = outputs.shape[0] + for b in range(batch_size): + detections = [] + for idx in np.ndindex(anchor_grid.shape[:-1]): + score = probs_np[b][idx] + # if score >= score_thresh: + box = anchor_grid[idx] + rect = AnnotationRect.fromarray(box) + detections.append((rect, float(score))) + detections_nms = non_maximum_suppression(detections, nms_thresh) + results.append(detections_nms) + + return results -def evaluate() -> float: # feel free to change the arguments +def evaluate( + model: MmpNet, loader: DataLoader, device: torch.device, anchor_grid: np.ndarray +) -> float: """Evaluates a specified model on the whole validation dataset. @return: AP for the validation set as a float. You decide which arguments this function should receive """ - raise NotImplementedError() + + path_to_data = ".data/mmp-public-3.2/train" + + progress_bar = tqdm(loader, desc="Evaluation", unit="batch") + image_count = 0 + ap_total = 0 + for img_batch, _, id_batch in progress_bar: + inference = batch_inference( + anchor_grid=anchor_grid, device=device, images=img_batch, model=model + ) + gts = get_gts_for_batch(id_batch=id_batch, gt_base_path=path_to_data) + + dict_detections = { + img_id.item(): inference[idx] for idx, img_id in enumerate(id_batch) + } + dict_gt = {img_id.item(): gts[idx] for idx, img_id in enumerate(id_batch)} + average_prevision, precision, recall = calculate_ap_pr(dict_detections, dict_gt) + ap_total = (ap_total * image_count + average_prevision) / ( + image_count + id_batch.shape[0] + ) + image_count += id_batch.shape[0] + + progress_bar.set_postfix( + { + "ap": ap_total, + } + ) + + return ap_total + + +def get_gts_for_batch( + id_batch: torch.Tensor, gt_base_path: str +) -> List[List[AnnotationRect]]: + return [ + read_groundtruth_file( + os.path.join(gt_base_path, f"{str(img_id.item()).zfill(8)}.gt_data.txt") + ) + for img_id in id_batch + ] + + +def calc_tp_fp_fn( + detections: List[Tuple[AnnotationRect, float]], + gts: List[AnnotationRect], + iou_threshold: float = 0.5, + confidence_threshhold: float = 0.5, +) -> tuple[int, int, int]: + """ + Calculates precision and recall for object detection results on a single image. + + Args: + detections: List of (AnnotationRect, confidence) tuples representing predicted boxes and scores. Should be sorted by descending confidence. + gts: List of AnnotationRect for ground truth. + iou_threshold: Minimum IoU to consider a detection a true positive. + confidence_threshhold: Minimum confidence required to include a detection. + Returns: + num_tp: Number of true positives (int). + num_fp: Number of false positives (int). + num_fn: Number of false negatives (int). + """ + detections = [det for det in detections if det[1] >= confidence_threshhold] + detections.sort(key=lambda x: x[1], reverse=True) + + matches = set() + fp = 0 + tp = 0 + + for det_rect, _ in detections: + iou_map = [iou(det_rect, gt_rect) for gt_rect in gts] + if len(iou_map) == 0: + fp += 1 + continue + max_idx = np.argmax(iou_map) + if max_idx in matches or iou_map[max_idx] < iou_threshold: + fp += 1 + continue + matches.add(max_idx) + tp += 1 + + fn = len(gts) - len(matches) + + return tp, fp, fn def evaluate_test(): # feel free to change the arguments diff --git a/mmp/a6/model_output.txt b/mmp/a6/model_output.txt index 8425b8a..fbb1158 100644 --- a/mmp/a6/model_output.txt +++ b/mmp/a6/model_output.txt @@ -1,928 +1,228 @@ -00009713 218 51 531 500 0.9992377758026123 -00009713 241 63 442 341 0.05638350173830986 -00009713 314 62 523 359 0.04272805154323578 -00009713 356 146 518 486 0.027418583631515503 -00009713 361 80 501 269 0.02033345028758049 -00009713 371 303 511 502 0.016882028430700302 -00009713 182 82 332 421 0.011045699007809162 -00009713 268 56 418 202 0.010104012675583363 -00009713 349 425 503 512 0.009388841688632965 -00009713 269 206 427 500 0.008801761083304882 -00009713 287 420 431 512 0.006916396785527468 -00009713 372 53 518 187 0.006824038457125425 -00009713 3 0 139 267 0.005639121402055025 -00009713 455 119 589 400 0.00560223450884223 -00009713 191 95 316 266 0.004849089775234461 -00009713 194 169 298 331 0.003228328190743923 -00009713 431 42 622 218 0.002790184924378991 -00009713 273 346 421 474 0.0026446999981999397 -00009713 194 52 314 194 0.0025389627553522587 -00009713 195 232 308 434 0.002077374141663313 -00009713 473 180 586 319 0.0020562238059937954 -00009713 385 249 508 420 0.0019144380930811167 -00009713 270 180 411 324 0.0017681934405118227 -00009713 386 159 509 339 0.0015080178854987025 -00009713 373 145 496 222 0.0012623979710042477 -00009713 471 115 605 253 0.0012612993596121669 -00009713 245 121 465 239 0.0012237385381013155 -00009713 291 70 400 158 0.001207000226713717 -00009713 10 0 257 317 0.00101530144456774 -00009713 470 252 581 393 0.0009472385281696916 -00009713 282 263 413 402 0.0008254581480287015 -00009713 240 280 538 512 0.0007688302430324256 -00009713 11 6 95 74 0.0007474914309568703 -00009713 387 297 511 362 0.0006525561329908669 -00009713 286 129 683 474 0.0005818814388476312 -00009713 36 2 472 462 0.0005682968767359853 -00009713 184 220 293 292 0.0005486627924256027 -00009713 360 58 638 299 0.0005419111112132668 -00009713 451 240 602 511 0.0005035421927459538 -00009713 307 349 559 488 0.0005015279748477042 -00009713 555 13 683 194 0.0004701976431533694 -00009713 573 137 667 228 0.00044757628347724676 -00009713 75 12 231 214 0.000447265338152647 -00009713 371 367 509 454 0.0004257388354744762 -00009713 385 220 507 288 0.00038073325413279235 -00009713 158 24 354 236 0.00035600937553681433 -00009713 0 79 128 406 0.0003287547442596406 -00009713 303 279 546 401 0.0003173290169797838 -00009713 9 9 164 97 0.0003086021461058408 -00009713 14 24 113 180 0.0003060425806324929 -00009713 273 156 408 213 0.0003009705396834761 -00009713 279 231 407 283 0.00030007059103809297 -00009713 71 0 215 89 0.0002919489925261587 -00009713 246 419 581 512 0.0002787837292999029 -00009713 276 0 423 132 0.0002776375913526863 -00009713 472 68 595 154 0.0002671642287168652 -00009713 457 219 581 286 0.0002533297229092568 -00009713 76 113 242 381 0.00023223753669299185 -00009713 187 8 303 73 0.000222606016905047 -00009713 298 194 548 319 0.00021702505182474852 -00009713 134 207 268 297 0.00020666902128141373 -00009713 288 11 397 81 0.0002039782120846212 -00009713 171 0 323 134 0.0001967123826034367 -00009713 282 303 396 353 0.00019214724306948483 -00009713 181 270 337 512 0.0001880993804661557 -00009713 287 372 410 431 0.00018720832304097712 -00009713 86 115 509 341 0.0001758743019308895 -00009713 557 148 683 512 0.00017386412946507335 -00009713 187 294 303 363 0.00017254093836527318 -00009713 561 93 683 250 0.00016316788969561458 -00009713 44 0 434 227 0.00014413666212931275 -00009713 167 154 377 327 0.00013937256881035864 -00009713 292 29 683 196 0.00012797315139323473 -00009713 370 0 509 99 0.0001272348454222083 -00009713 16 91 268 507 0.00011757406173273921 -00009713 17 0 287 138 0.00011480335524538532 -00009713 549 459 677 502 0.00011015331256203353 -00009713 373 443 666 512 0.00010754197865026072 -00009713 456 294 590 360 0.00010586134885670617 -00014468 409 5 648 351 0.9735230803489685 -00014468 0 54 130 363 0.44076091051101685 -00014468 409 238 588 382 0.41775429248809814 -00014468 519 0 666 92 0.2504248321056366 -00014468 222 35 622 323 0.17690446972846985 -00014468 7 185 118 316 0.1115042045712471 -00014468 440 0 591 87 0.10381144285202026 -00014468 157 178 459 319 0.10139060020446777 -00014468 302 110 467 287 0.09870130568742752 -00014468 436 0 582 206 0.09038496017456055 -00014468 7 153 247 344 0.08151272684335709 -00014468 308 206 456 305 0.07829681038856506 -00014468 519 241 663 415 0.06633421033620834 -00014468 647 0 768 256 0.06180586293339729 -00014468 496 142 647 348 0.037872474640607834 -00014468 395 0 658 130 0.036778151988983154 -00014468 371 208 587 306 0.03397992253303528 -00014468 297 11 527 249 0.03205402195453644 -00014468 313 232 480 377 0.03200297802686691 -00014468 427 73 588 283 0.029695607721805573 -00014468 309 0 768 406 0.02609015442430973 -00014468 1 242 118 398 0.02604709193110466 -00014468 320 4 447 64 0.025225749239325523 -00014468 97 144 576 348 0.02415069378912449 -00014468 315 27 456 196 0.022448189556598663 -00014468 0 446 141 512 0.02237512730062008 -00014468 0 48 256 454 0.0199214369058609 -00014468 629 0 768 84 0.01908457651734352 -00014468 480 50 696 464 0.018058978021144867 -00014468 77 435 232 512 0.01586795225739479 -00014468 69 177 230 303 0.01513176504522562 -00014468 15 23 129 203 0.012557721696794033 -00014468 18 0 124 96 0.012197092175483704 -00014468 9 131 120 261 0.01200497429817915 -00014468 261 0 531 71 0.010978903621435165 -00014468 211 208 371 296 0.01010939385741949 -00014468 521 205 652 314 0.009653517045080662 -00014468 363 5 733 205 0.009641261771321297 -00014468 18 42 595 440 0.00883176364004612 -00014468 0 0 181 263 0.008783712051808834 -00014468 313 147 441 221 0.00830777920782566 -00014468 431 296 571 362 0.007992669939994812 -00014468 310 5 468 117 0.0076032062061131 -00014468 0 332 124 478 0.007124173454940319 -00014468 29 77 380 325 0.006255109328776598 -00014468 309 227 659 392 0.005658395122736692 -00014468 667 23 760 170 0.005383150186389685 -00014468 43 226 211 512 0.005345460958778858 -00014468 10 224 116 286 0.004777092020958662 -00014468 570 0 750 360 0.004515498876571655 -00014468 527 113 653 243 0.004187507554888725 -00014468 533 288 665 374 0.003978192340582609 -00014468 197 136 370 260 0.003923742566257715 -00014468 432 268 595 474 0.0029992053750902414 -00014468 644 166 761 470 0.0024739429354667664 -00014468 327 71 443 144 0.002247918862849474 -00014468 49 129 250 269 0.002185120014473796 -00014468 529 57 645 145 0.0021819998510181904 -00014468 56 4 546 257 0.0019006043439731002 -00014468 124 0 645 107 0.0018854559166356921 -00014468 525 230 637 287 0.0017206895863637328 -00014468 385 131 611 246 0.0015216664178296924 -00014468 476 41 680 158 0.0013784924522042274 -00014468 440 339 570 446 0.0013399936724454165 -00014468 6 302 107 358 0.0013254748191684484 -00014468 440 60 568 151 0.001188935129903257 -00014468 663 110 741 237 0.001175640500150621 -00014468 644 251 742 416 0.0011698382440954447 -00014468 657 179 752 333 0.0010792257962748408 -00014468 83 331 207 487 0.0010766894556581974 -00014468 412 151 628 509 0.0010367141803726554 -00014468 72 239 216 391 0.0010078402701765299 -00014468 205 244 362 372 0.0010065195383504033 -00014468 188 455 353 509 0.001006228500045836 -00014468 199 54 359 170 0.0009535890421830118 -00014468 329 303 471 361 0.0009530404349789023 -00014468 647 65 746 138 0.0009202142246067524 -00014468 427 457 547 501 0.0008598389686085284 -00014468 6 377 118 435 0.0007640997646376491 -00014468 56 14 246 228 0.0007406030199490488 -00014468 104 146 220 222 0.0006877986597828567 -00014468 158 220 440 403 0.0006747996085323393 -00014468 643 220 739 292 0.0006719886441715062 -00014468 217 159 352 212 0.0006317707011476159 -00014468 505 283 691 482 0.0006164428777992725 -00014468 191 162 695 458 0.0006032923120073974 -00014468 436 155 567 210 0.0005852437461726367 -00014468 528 157 643 211 0.000560874817892909 -00014468 656 308 744 465 0.0005311771528795362 -00014468 0 380 171 512 0.0005210476811043918 -00014468 312 272 471 485 0.0005162066081538796 -00014468 150 28 395 210 0.0005146207404322922 -00014468 99 431 469 512 0.0004906487301923335 -00014468 313 452 435 506 0.0004388469969853759 -00014468 226 84 362 137 0.00043012999230995774 -00014468 2 212 291 407 0.0004277551779523492 -00014468 205 12 358 61 0.0003826924948953092 -00014468 84 5 266 73 0.00037687510484829545 -00014468 317 338 439 452 0.00037506010266952217 -00014468 642 450 744 501 0.00037216124474070966 -00014468 74 226 211 283 0.0003604786761570722 -00014468 554 23 768 153 0.0003345779550727457 -00014468 541 331 667 456 0.00031569114071317017 -00014468 91 58 234 166 0.0003060665330849588 -00014468 647 157 729 211 0.00026765247457660735 -00014468 146 3 388 71 0.0002443758421577513 -00014468 101 374 223 447 0.00022916143643669784 -00014468 24 0 352 107 0.00022534155868925154 -00014468 15 81 125 146 0.00022204364358913153 -00014468 91 291 226 358 0.00022102090588305146 -00014468 638 289 743 365 0.0002095637610182166 -00014468 331 370 468 436 0.00020206336921546608 -00014468 337 448 551 509 0.00019877179875038564 -00014468 213 304 355 358 0.0001658054388826713 -00014468 426 405 573 512 0.00015460496069863439 -00014468 649 363 749 428 0.00011848975555039942 -00014468 562 437 739 492 0.00011737779277609661 -00014468 362 320 686 460 0.00011457992513896897 -00014468 208 350 322 460 0.00011263904889347032 -00014468 565 196 756 315 0.00010528942220844328 -00014468 306 411 458 512 0.00010313800885342062 -00015230 178 249 312 437 0.9959318041801453 -00015230 213 72 386 428 0.2688807249069214 -00015230 33 14 297 436 0.2494492083787918 -00015230 576 177 678 480 0.19585390388965607 -00015230 188 292 297 363 0.11881355941295624 -00015230 144 19 303 328 0.1107005700469017 -00015230 108 265 233 398 0.10564856976270676 -00015230 268 151 381 379 0.1039527952671051 -00015230 536 38 673 452 0.091851606965065 -00015230 295 40 581 512 0.06822070479393005 -00015230 4 270 119 508 0.06499487161636353 -00015230 170 229 279 286 0.061953481286764145 -00015230 407 2 658 442 0.050201401114463806 -00015230 103 195 230 357 0.03833271190524101 -00015230 166 89 276 268 0.031265269964933395 -00015230 249 0 426 350 0.029569445177912712 -00015230 75 315 230 471 0.028139572590589523 -00015230 274 193 362 316 0.024587228894233704 -00015230 180 350 309 449 0.02428106777369976 -00015230 110 31 442 456 0.022810660302639008 -00015230 300 29 384 339 0.02086961455643177 -00015230 274 326 402 462 0.01880483515560627 -00015230 199 289 447 480 0.01485055685043335 -00015230 343 157 506 474 0.01163405179977417 -00015230 131 291 332 504 0.011067722924053669 -00015230 1 357 288 512 0.009945414960384369 -00015230 578 68 666 314 0.00972050428390503 -00015230 2 0 119 332 0.00730498693883419 -00015230 83 57 220 338 0.00683275330811739 -00015230 171 28 308 196 0.006445717997848988 -00015230 492 90 625 419 0.006181038916110992 -00015230 209 435 487 512 0.006068288814276457 -00015230 586 321 667 454 0.005752839148044586 -00015230 28 430 264 511 0.00567103223875165 -00015230 142 429 329 512 0.005517907906323671 -00015230 0 156 113 391 0.005319138988852501 -00015230 104 218 214 292 0.005297711584717035 -00015230 276 283 382 378 0.005283021833747625 -00015230 286 102 361 251 0.005134196486324072 -00015230 4 443 113 506 0.004170606844127178 -00015230 372 254 492 419 0.0041236355900764465 -00015230 80 6 223 67 0.003493226831778884 -00015230 85 119 206 250 0.0034833878744393587 -00015230 171 80 300 142 0.0033243291545659304 -00015230 89 0 371 253 0.0032783772330731153 -00015230 580 201 681 308 0.00292400736361742 -00015230 73 250 536 512 0.0028666011057794094 -00015230 106 297 219 360 0.0026948906015604734 -00015230 0 255 206 447 0.002396118827164173 -00015230 171 11 306 66 0.0022646216675639153 -00015230 283 12 393 63 0.002249243203550577 -00015230 575 392 686 512 0.0021612492855638266 -00015230 83 198 371 353 0.0021533893886953592 -00015230 172 150 290 224 0.0019805317278951406 -00015230 272 455 423 509 0.0018809009343385696 -00015230 375 190 482 337 0.0018443414010107517 -00015230 252 355 438 507 0.0018138799350708723 -00015230 268 230 355 281 0.001625738455913961 -00015230 321 289 554 512 0.001601602416485548 -00015230 446 240 684 512 0.001572682405821979 -00015230 584 118 656 235 0.0014700503088533878 -00015230 63 402 438 512 0.0014373891754075885 -00015230 81 46 220 162 0.00140690291300416 -00015230 0 278 132 388 0.0013858119491487741 -00015230 114 0 364 74 0.0012928118230774999 -00015230 484 302 625 482 0.001271268934942782 -00015230 499 248 599 403 0.001168360118754208 -00015230 485 103 591 252 0.0011452098842710257 -00015230 561 440 669 505 0.0011047901352867484 -00015230 70 451 232 501 0.0010012248530983925 -00015230 529 161 681 352 0.0009972326224669814 -00015230 8 199 121 315 0.0009441319270990789 -00015230 279 2 400 223 0.000916606280952692 -00015230 491 168 595 318 0.0009148159297183156 -00015230 282 377 394 437 0.0009114544955082238 -00015230 105 67 335 151 0.0008766204700805247 -00015230 403 45 524 416 0.0008748723776079714 -00015230 363 15 516 56 0.0008612139499746263 -00015230 50 0 247 108 0.0008136475807987154 -00015230 36 13 267 200 0.0008048824965953827 -00015230 492 16 606 217 0.0008016278152354062 -00015230 582 33 663 176 0.0007212623604573309 -00015230 378 323 503 480 0.000717444228939712 -00015230 236 219 399 301 0.0006925383931957185 -00015230 5 361 105 449 0.0006493552937172353 -00015230 88 375 210 430 0.0006325744325295091 -00015230 379 227 494 293 0.0006269200821407139 -00015230 335 437 550 512 0.0006178041803650558 -00015230 503 44 586 157 0.0006124836509115994 -00015230 531 250 686 407 0.0005549605120904744 -00015230 549 19 665 61 0.0005369195714592934 -00015230 88 155 196 207 0.0005319862975738943 -00015230 234 239 650 447 0.0005251106922514737 -00015230 146 134 355 228 0.0004897980252280831 -00015230 222 0 462 67 0.00048801666707731783 -00015230 0 60 627 512 0.0004792926483787596 -00015230 1 299 106 356 0.0004750869993586093 -00015230 79 85 217 133 0.0004715617105830461 -00015230 274 153 377 218 0.00046576018212363124 -00015230 576 158 663 204 0.0004592995683196932 -00015230 8 24 110 187 0.00044759377487935126 -00015230 399 438 672 512 0.0003923877957277 -00015230 11 114 106 248 0.00037759292172268033 -00015230 278 54 378 156 0.0003370838821865618 -00015230 462 13 619 62 0.0003333610948175192 -00015230 490 148 588 215 0.00033139390870928764 -00015230 382 112 497 286 0.00030931030050851405 -00015230 187 404 686 512 0.00030819582752883434 -00015230 570 280 683 373 0.0003037074056919664 -00015230 469 377 643 512 0.00029880538932047784 -00015230 294 3 596 62 0.00029317126609385014 -00015230 482 220 584 289 0.0002869328309316188 -00015230 576 375 665 436 0.00028457085136324167 -00015230 159 0 561 313 0.00028411028324626386 -00015230 509 340 686 456 0.0002808108401950449 -00015230 385 289 494 371 0.00027951804804615676 -00015230 3 15 118 89 0.000273281242698431 -00015230 299 157 343 195 0.00026812852593138814 -00015230 489 84 588 131 0.0002570910146459937 -00015230 0 0 162 68 0.0002473231579642743 -00015230 398 46 503 170 0.00023022381355986 -00015230 487 366 600 444 0.00019754520326387137 -00015230 0 228 103 282 0.00018550784443505108 -00015230 568 74 652 139 0.00017890492745209485 -00015230 280 86 385 133 0.0001370907120872289 -00015230 534 142 681 213 0.00012998854799661785 -00015230 394 87 507 135 0.00012494646944105625 -00015230 470 455 626 506 0.00011189257202204317 -00015230 5 72 104 141 0.00011082242417614907 -00017984 538 173 634 479 0.9758561849594116 -00017984 261 129 373 445 0.4949325919151306 -00017984 346 144 458 437 0.44343745708465576 -00017984 309 0 479 187 0.4026491045951843 -00017984 47 141 189 458 0.3471282720565796 -00017984 10 265 108 442 0.2865073084831238 -00017984 174 181 283 437 0.24743126332759857 -00017984 1 6 105 214 0.2426595687866211 -00017984 315 19 481 389 0.21384383738040924 -00017984 404 0 566 85 0.20143844187259674 -00017984 542 186 627 322 0.18983417749404907 -00017984 38 29 483 480 0.18894675374031067 -00017984 459 233 547 383 0.18465028703212738 -00017984 257 0 538 97 0.13138219714164734 -00017984 346 234 444 373 0.12689857184886932 -00017984 354 50 459 275 0.1082889661192894 -00017984 105 98 328 464 0.10561501234769821 -00017984 65 270 176 441 0.10463956743478775 -00017984 252 218 354 377 0.08810015022754669 -00017984 543 234 638 371 0.07793550193309784 -00017984 198 73 405 464 0.07457202672958374 -00017984 542 52 637 337 0.06975558400154114 -00017984 285 22 375 316 0.06801705062389374 -00017984 58 405 213 478 0.06772372871637344 -00017984 0 0 118 98 0.06651414185762405 -00017984 0 0 504 137 0.06394131481647491 -00017984 343 31 457 140 0.06209742650389671 -00017984 265 3 415 64 0.06165854632854462 -00017984 551 350 640 480 0.05735442414879799 -00017984 452 188 542 323 0.05548981949687004 -00017984 59 46 185 319 0.05158618837594986 -00017984 0 148 96 331 0.05091795325279236 -00017984 340 180 448 316 0.050816427916288376 -00017984 221 0 462 273 0.050689149647951126 -00017984 367 0 591 143 0.03464897722005844 -00017984 349 106 446 223 0.033363234251737595 -00017984 278 90 356 224 0.031203508377075195 -00017984 157 402 284 477 0.026595542207360268 -00017984 0 0 300 80 0.024599652737379074 -00017984 396 109 605 480 0.024052482098340988 -00017984 267 180 369 306 0.023258449509739876 -00017984 547 111 632 239 0.022464999929070473 -00017984 301 219 475 393 0.02109949290752411 -00017984 170 248 276 359 0.019602710381150246 -00017984 19 335 109 414 0.019570162519812584 -00017984 533 1 640 205 0.01869731955230236 -00017984 5 0 228 199 0.01801302097737789 -00017984 266 20 405 175 0.01598801463842392 -00017984 180 296 267 437 0.01470915600657463 -00017984 77 251 191 361 0.013860350474715233 -00017984 73 108 175 223 0.012612282298505306 -00017984 1 352 107 480 0.012336566112935543 -00017984 526 413 635 480 0.01222901325672865 -00017984 340 271 443 335 0.011973942629992962 -00017984 258 73 534 480 0.011938601732254028 -00017984 496 1 640 92 0.011416708119213581 -00017984 346 208 460 276 0.01124538853764534 -00017984 491 9 640 427 0.010218174196779728 -00017984 260 270 344 438 0.010217254050076008 -00017984 445 269 544 340 0.00989519152790308 -00017984 121 262 300 453 0.009888404980301857 -00017984 427 51 576 346 0.009483912028372288 -00017984 487 177 640 351 0.009426653385162354 -00017984 363 280 448 450 0.009263766929507256 -00017984 73 174 177 291 0.008566944859921932 -00017984 29 331 227 480 0.007799222134053707 -00017984 389 221 602 389 0.007399847265332937 -00017984 237 270 347 336 0.007192984689027071 -00017984 446 122 548 227 0.007055722642689943 -00017984 431 27 554 137 0.006025912240147591 -00017984 45 25 194 154 0.005740707274526358 -00017984 470 270 640 460 0.0056888568215072155 -00017984 539 150 624 201 0.0055724214762449265 -00017984 266 139 372 209 0.005120808258652687 -00017984 545 209 627 270 0.005058073438704014 -00017984 73 335 180 413 0.004779793322086334 -00017984 351 75 451 125 0.004577530547976494 -00017984 122 1 344 62 0.004329141695052385 -00017984 18 233 231 412 0.004277946427464485 -00017984 8 396 332 480 0.004254643339663744 -00017984 446 322 583 480 0.004149259068071842 -00017984 0 414 131 476 0.003962669055908918 -00017984 542 44 639 142 0.00392248434945941 -00017984 175 193 301 300 0.0038470567669719458 -00017984 345 146 443 196 0.0036654917057603598 -00017984 527 313 640 437 0.0033379981759935617 -00017984 177 23 294 342 0.0033334356267005205 -00017984 258 213 362 265 0.0031698280945420265 -00017984 170 96 285 245 0.0031678564846515656 -00017984 328 0 640 329 0.0029770247638225555 -00017984 205 222 425 384 0.00297210062853992 -00017984 442 397 640 480 0.002924235537648201 -00017984 1 199 96 279 0.0026055932976305485 -00017984 78 146 188 191 0.0025824573822319508 -00017984 276 147 344 188 0.002413131296634674 -00017984 0 59 98 141 0.002408545231446624 -00017984 163 19 307 184 0.0023836123291403055 -00017984 0 133 96 209 0.002350326394662261 -00017984 268 65 396 139 0.002328172093257308 -00017984 170 282 273 330 0.002294263569638133 -00017984 0 0 146 366 0.0022621757816523314 -00017984 0 317 167 426 0.001978493295609951 -00017984 542 277 633 336 0.00182425940874964 -00017984 442 211 532 265 0.0018011685460805893 -00017984 76 214 179 259 0.0017821775982156396 -00017984 249 268 516 462 0.001736486330628395 -00017984 81 281 185 333 0.001576754031702876 -00017984 9 283 103 336 0.0015247806441038847 -00017984 0 270 372 466 0.0015093388501554728 -00017984 277 411 525 479 0.0013674917863681912 -00017984 157 414 413 476 0.0013192225014790893 -00017984 277 190 505 297 0.001269816653802991 -00017984 47 7 215 58 0.0011716332519426942 -00017984 355 421 478 477 0.0011690118117257953 -00017984 255 419 372 473 0.0011173418024554849 -00017984 89 239 352 378 0.0011126784374937415 -00017984 319 132 510 213 0.001100254012271762 -00017984 434 79 545 124 0.0010360201122239232 -00017984 16 160 240 326 0.001034620450809598 -00017984 408 200 576 286 0.0010141994571313262 -00017984 529 83 630 128 0.0010060722706839442 -00017984 170 76 302 139 0.0009955894201993942 -00017984 77 192 460 406 0.0009637664188630879 -00017984 453 425 568 477 0.0009482947061769664 -00017984 65 0 377 226 0.0008330706623382866 -00017984 545 353 637 409 0.0007769505609758198 -00017984 77 249 617 480 0.0007756722043268383 -00017984 57 80 190 120 0.000709329207893461 -00017984 289 68 505 231 0.0006693153991363943 -00017984 29 77 244 236 0.0006519559537991881 -00017984 171 353 271 404 0.0006353610660880804 -00017984 347 342 486 480 0.0005356252659112215 -00017984 168 388 634 480 0.0005155978142283857 -00017984 253 339 377 480 0.0005088666221126914 -00017984 173 149 291 196 0.000496460881549865 -00017984 222 297 395 444 0.0004891842254437506 -00017984 207 12 607 175 0.0004602100816555321 -00017984 258 340 348 410 0.0004121677775401622 -00017984 116 55 350 144 0.00039320881478488445 -00017984 361 341 447 413 0.0003922795585822314 -00017984 366 172 604 310 0.0003749817842617631 -00017984 0 249 163 368 0.0003390935598872602 -00017984 139 330 295 415 0.0003272908797953278 -00017984 144 151 362 355 0.00029974692733958364 -00017984 339 295 630 480 0.0002550742938183248 -00017984 225 155 460 325 0.0002539839188102633 -00017984 0 109 151 217 0.00022946164244785905 -00017984 21 356 522 480 0.0002136928669642657 -00017984 449 337 557 420 0.00021203125652391464 -00017984 382 118 622 227 0.00013031855633016676 -00017984 146 113 384 236 0.00011765705130528659 -00018573 319 110 450 244 0.9897462129592896 -00018573 90 102 229 234 0.9283090233802795 -00018573 79 87 224 401 0.4545566439628601 -00018573 43 49 218 211 0.3753353953361511 -00018573 287 65 428 219 0.37207674980163574 -00018573 71 133 180 227 0.3257155120372772 -00018573 103 393 522 500 0.2447475790977478 -00018573 348 144 452 216 0.24418456852436066 -00018573 136 106 389 230 0.2402806282043457 -00018573 268 86 486 274 0.22362710535526276 -00018573 8 117 98 226 0.19536162912845612 -00018573 213 120 311 219 0.14684827625751495 -00018573 59 71 169 177 0.1411411315202713 -00018573 353 66 451 194 0.1284961998462677 -00018573 2 68 83 170 0.09691505879163742 -00018573 188 30 323 232 0.0784328430891037 -00018573 340 148 462 296 0.06238303706049919 -00018573 141 438 431 503 0.05915208160877228 -00018573 120 147 226 215 0.057493019849061966 -00018573 127 63 220 198 0.04484178498387337 -00018573 229 369 509 472 0.044580694288015366 -00018573 37 62 290 295 0.0383601188659668 -00018573 0 67 90 352 0.03603912144899368 -00018573 0 122 210 217 0.032230257987976074 -00018573 259 428 488 503 0.0305311419069767 -00018573 292 125 438 344 0.026789184659719467 -00018573 2 16 254 444 0.02605234831571579 -00018573 94 0 253 247 0.019378909841179848 -00018573 261 259 494 512 0.01737048663198948 -00018573 57 84 158 134 0.017106175422668457 -00018573 2 8 346 224 0.016886768862605095 -00018573 425 115 518 248 0.016800038516521454 -00018573 56 121 192 312 0.014590417966246605 -00018573 325 375 492 438 0.01327232550829649 -00018573 110 138 233 306 0.012144745327532291 -00018573 338 0 469 216 0.012041065841913223 -00018573 411 440 507 500 0.011774958111345768 -00018573 326 216 473 288 0.011646736413240433 -00018573 0 31 111 224 0.011095283553004265 -00018573 181 451 339 502 0.009249952621757984 -00018573 303 78 392 158 0.009181584231555462 -00018573 360 69 519 298 0.008503065444529057 -00018573 187 123 515 393 0.007812915369868279 -00018573 419 91 515 394 0.007111456245183945 -00018573 39 95 370 504 0.007102791219949722 -00018573 232 51 307 185 0.0070172823034226894 -00018573 352 81 446 141 0.006858893670141697 -00018573 33 154 188 493 0.006417808122932911 -00018573 13 79 115 489 0.005871733650565147 -00018573 179 378 408 443 0.005770611576735973 -00018573 399 2 521 235 0.005407017655670643 -00018573 151 37 499 222 0.00539295794442296 -00018573 285 179 414 299 0.0051244585774838924 -00018573 41 220 194 280 0.0051088291220366955 -00018573 353 0 461 96 0.004971992690116167 -00018573 21 175 256 289 0.004446413833647966 -00018573 358 212 466 411 0.0040200259536504745 -00018573 214 386 340 436 0.004018367268145084 -00018573 272 0 398 193 0.004015874117612839 -00018573 118 222 231 284 0.003910831641405821 -00018573 105 46 404 329 0.003624335862696171 -00018573 279 20 522 503 0.00339940725825727 -00018573 276 382 397 428 0.003176348051056266 -00018573 339 338 489 479 0.0030564111657440662 -00018573 0 223 94 277 0.0029446613043546677 -00018573 284 236 400 278 0.002469860715791583 -00018573 347 450 475 498 0.002156781265512109 -00018573 16 152 447 365 0.002094767289236188 -00018573 432 0 522 84 0.0019603644032031298 -00018573 129 83 214 142 0.0018060017609968781 -00018573 433 155 512 210 0.001754443976096809 -00018573 30 301 477 512 0.0015794619685038924 -00018573 384 411 497 508 0.0015135450521484017 -00018573 54 10 178 66 0.0014640988083556294 -00018573 207 0 310 151 0.0014184099854901433 -00018573 20 444 251 511 0.0012729985173791647 -00018573 285 0 389 104 0.0012238421477377415 -00018573 129 159 244 420 0.0011796436738222837 -00018573 293 192 409 412 0.0010717087425291538 -00018573 435 163 519 304 0.0009974032873287797 -00018573 64 412 359 511 0.0009544852655380964 -00018573 49 297 170 490 0.0009427929180674255 -00018573 0 167 106 291 0.0008830682490952313 -00018573 125 451 274 503 0.0008813723106868565 -00018573 278 0 520 97 0.0008789845742285252 -00018573 205 224 308 282 0.0008723472128622234 -00018573 11 0 221 158 0.000871601514518261 -00018573 421 291 522 510 0.0008698318270035088 -00018573 427 225 522 279 0.0008524131262674928 -00018573 413 380 522 440 0.0007958997739478946 -00018573 224 1 306 77 0.0007714590174145997 -00018573 0 459 94 503 0.0007581215468235314 -00018573 73 363 368 471 0.0006139951292425394 -00018573 6 214 87 444 0.0006080020684748888 -00018573 272 450 409 500 0.0006064313347451389 -00018573 358 295 456 369 0.0006049877847544849 -00018573 217 192 325 427 0.0005285342922434211 -00018573 227 85 304 141 0.0005183502216823399 -00018573 205 70 348 171 0.0005180046427994967 -00018573 203 154 316 316 0.0005172021919861436 -00018573 0 16 105 59 0.0004934542230330408 -00018573 432 222 522 432 0.00048021049587987363 -00018573 145 381 244 443 0.0004673106886912137 -00018573 131 0 233 160 0.00045855832286179066 -00018573 216 270 310 392 0.0004489491693675518 -00018573 166 171 390 454 0.0004233682411722839 -00018573 123 190 431 299 0.0004197377129457891 -00018573 50 454 183 504 0.0004125136765651405 -00018573 13 224 261 423 0.00038468558341264725 -00018573 169 1 363 80 0.0003753843775484711 -00018573 61 225 169 400 0.0003697050560731441 -00018573 194 385 342 512 0.00035893486347049475 -00018573 442 43 522 191 0.0003199915518052876 -00018573 137 5 232 74 0.0003163672226946801 -00018573 173 106 332 371 0.0003013779642060399 -00018573 184 323 386 496 0.0002842953254003078 -00018573 8 332 264 497 0.0002603182219900191 -00018573 276 378 423 512 0.00025999819627031684 -00018573 290 280 402 385 0.000249253906076774 -00018573 52 2 270 81 0.0002486195007804781 -00018573 2 14 162 95 0.000207726945518516 -00018573 210 274 469 401 0.00019459314353298396 -00018573 106 0 430 109 0.00019169341248925775 -00018573 134 255 232 392 0.00018858499242924154 -00018573 59 376 161 447 0.0001838515163399279 -00018573 297 311 387 358 0.0001550256711198017 -00018573 131 318 257 479 0.0001470775023335591 -00018573 314 253 522 417 0.00014644552720710635 -00018573 12 314 85 501 0.0001262789883185178 -00018573 224 307 315 358 0.00011264947534073144 -00018573 62 298 178 364 0.00011231343523832038 -00018573 0 0 167 317 0.00010820152965607122 -00018573 62 267 332 393 0.00010355013364460319 -00032564 87 59 215 390 0.9970299005508423 -00032564 23 62 164 385 0.26364627480506897 -00032564 99 50 207 238 0.25082671642303467 -00032564 13 27 289 420 0.0916571095585823 -00032564 53 35 724 462 0.08701056987047195 -00032564 123 20 344 315 0.011361612938344479 -00032564 416 230 559 284 0.009997757151722908 -00032564 98 167 228 337 0.008734875358641148 -00032564 98 236 219 384 0.008023219183087349 -00032564 372 127 761 512 0.00781198451295495 -00032564 118 66 206 165 0.007677215617150068 -00032564 19 87 131 271 0.007462808396667242 -00032564 31 397 739 512 0.007216962520033121 -00032564 436 146 531 221 0.005844444502145052 -00032564 12 158 130 347 0.005281529389321804 -00032564 195 72 307 282 0.004632377531379461 -00032564 346 147 436 237 0.003867375198751688 -00032564 442 178 581 330 0.00384037964977324 -00032564 55 95 238 268 0.003470006166025996 -00032564 446 85 537 128 0.0033686659298837185 -00032564 190 136 333 340 0.0033482061699032784 -00032564 447 115 562 264 0.0032745026983320713 -00032564 0 133 485 359 0.0031289865728467703 -00032564 324 202 471 321 0.0027138893492519855 -00032564 203 128 307 229 0.0021317931823432446 -00032564 546 81 640 133 0.0021200922783464193 -00032564 137 265 736 483 0.002109762281179428 -00032564 368 112 452 265 0.0020976278465241194 -00032564 543 25 661 178 0.0017771999118849635 -00032564 27 45 139 196 0.0016729205381125212 -00032564 187 14 664 313 0.0015246121911332011 -00032564 329 233 466 282 0.0014214653056114912 -00032564 219 109 586 501 0.0014111793134361506 -00032564 384 224 640 295 0.0013912779977545142 -00032564 0 22 500 276 0.0013232897035777569 -00032564 100 148 209 206 0.0013111219741404057 -00032564 201 193 317 301 0.0012872613733634353 -00032564 631 458 744 504 0.0012433662777766585 -00032564 328 163 399 198 0.0012145760701969266 -00032564 658 22 757 178 0.0011336510069668293 -00032564 45 150 254 504 0.00111566879786551 -00032564 655 142 770 505 0.0010633376659825444 -00032564 431 56 529 135 0.0010132075985893607 -00032564 85 379 238 441 0.0010107355192303658 -00032564 407 110 630 397 0.0009370078914798796 -00032564 529 227 676 286 0.0009267269051633775 -00032564 421 301 566 360 0.000832569960039109 -00032564 661 44 725 148 0.0007897102041170001 -00032564 343 134 491 393 0.0007532132440246642 -00032564 296 300 446 363 0.0007341417949646711 -00032564 346 50 415 307 0.0007213400676846504 -00032564 418 211 585 428 0.0007024178048595786 -00032564 305 254 460 385 0.0006743855192326009 -00032564 635 79 722 136 0.0006542549817822874 -00032564 126 130 358 428 0.0005980688147246838 -00032564 195 158 293 197 0.0005854472983628511 -00032564 293 197 702 326 0.0005834837211295962 -00032564 545 154 651 210 0.0005717547610402107 -00032564 182 450 592 512 0.0005654341075569391 -00032564 329 88 448 134 0.0005609166109934449 -00032564 658 329 770 469 0.0005522951250895858 -00032564 655 425 766 504 0.00054553133668378 -00032564 446 33 550 166 0.0005345381796360016 -00032564 647 372 760 435 0.0005295398295857012 -00032564 3 190 196 416 0.000515947409439832 -00032564 108 306 219 362 0.0005089023034088314 -00032564 646 151 720 204 0.0004967362037859857 -00032564 502 37 625 150 0.00048782670637592673 -00032564 190 234 287 276 0.0004749493673443794 -00032564 71 61 275 176 0.0004699462733697146 -00032564 451 0 670 263 0.0004676413373090327 -00032564 63 173 375 321 0.00046215864131227136 -00032564 324 431 770 512 0.00045980376307852566 -00032564 8 143 125 218 0.00045729518751613796 -00032564 546 102 663 261 0.00043780243140645325 -00032564 5 218 127 292 0.000426046404754743 -00032564 16 249 147 381 0.00040254584746435285 -00032564 104 229 215 287 0.0004011912096757442 -00032564 508 448 717 510 0.000397819239879027 -00032564 295 463 463 503 0.00038894236786291003 -00032564 420 385 555 422 0.00038203923031687737 -00032564 268 186 506 442 0.00037836332921870053 -00032564 182 220 346 395 0.00037603138480335474 -00032564 318 384 468 424 0.00036403941339813173 -00032564 204 300 336 367 0.0003511334944050759 -00032564 282 156 441 217 0.0003370631893631071 -00032564 33 363 293 472 0.00032610856578685343 -00032564 668 127 729 202 0.0003255174378864467 -00032564 475 258 729 512 0.00032254966208711267 -00032564 0 16 88 59 0.00031814086833037436 -00032564 409 459 573 502 0.00030859277467243373 -00032564 366 254 621 494 0.0002852455945685506 -00032564 666 96 754 247 0.0002839291119016707 -00032564 292 80 469 259 0.00028375457623042166 -00032564 145 151 288 209 0.0002729874977376312 -00032564 653 252 770 394 0.0002715993905439973 -00032564 313 15 441 54 0.0002689342654775828 -00032564 400 153 619 219 0.00025347518385387957 -00032564 638 295 767 356 0.0002461145631968975 -00032564 319 57 447 163 0.00024403704446740448 -00032564 524 173 688 336 0.00023362674983218312 -00032564 206 56 332 172 0.0002189571678172797 -00032564 434 15 534 57 0.0002188477956224233 -00032564 625 238 746 278 0.00021711339650209993 -00032564 0 394 361 512 0.00020605060853995383 -00032564 656 16 769 77 0.00019652863556984812 -00032564 532 300 685 360 0.0001937610941240564 -00032564 267 354 692 460 0.00019373191753402352 -00032564 186 463 371 503 0.000192962063010782 -00032564 6 215 584 425 0.00018357826047576964 -00032564 413 356 555 449 0.00018246070249006152 -00032564 155 115 359 235 0.00017860053048934788 -00032564 193 281 616 384 0.0001722056622384116 -00032564 378 0 770 350 0.00017156190006062388 -00032564 183 322 555 496 0.00016361191228497773 -00032564 531 376 682 438 0.0001626279845368117 -00032564 23 260 330 388 0.00015872351650614291 -00032564 214 84 333 137 0.00014699225721415132 -00032564 372 292 652 367 0.00014495261711999774 -00032564 1 371 154 434 0.00013407117512542754 -00032564 396 427 587 512 0.00013374023546930403 -00032564 254 374 535 442 0.0001306784397456795 -00032564 394 44 580 123 0.00012277862697374076 -00032564 533 11 701 66 0.00012054431135766208 -00032564 490 342 714 468 0.00011813630408141762 -00032564 502 124 643 228 0.00011395861656637862 -00032564 649 204 770 282 0.00011071289918618277 -00032564 527 233 703 411 0.00010990674491040409 -00032564 0 36 241 200 0.00010878648026846349 -00032564 7 308 150 361 0.0001055368993547745 -00032564 0 280 155 486 0.00010524936078581959 -00032564 18 81 140 138 0.0001024300727294758 -00032564 417 0 747 66 0.00010104414832312614 -00035635 105 94 374 694 0.9997064471244812 -00035635 162 116 349 504 0.029531387612223625 -00035635 115 134 281 440 0.020277176052331924 -00035635 113 233 262 661 0.017007218673825264 -00035635 423 117 512 638 0.012933779507875443 -00035635 251 136 380 619 0.01204749010503292 -00035635 56 422 174 577 0.010531827807426453 -00035635 115 192 245 347 0.008671603165566921 -00035635 5 501 221 756 0.00672384537756443 -00035635 189 265 327 654 0.0065661147236824036 -00035635 200 514 316 698 0.0050666071474552155 -00035635 32 402 213 627 0.004788365680724382 -00035635 64 352 317 715 0.004783510230481625 -00035635 97 446 259 701 0.004216741770505905 -00035635 260 91 376 307 0.003701842622831464 -00035635 109 396 290 608 0.0034999342169612646 -00035635 344 272 449 510 0.0033990778028964996 -00035635 0 633 279 768 0.0032744701020419598 -00035635 423 360 505 592 0.002836190164089203 -00035635 190 86 331 280 0.0027417512610554695 -00035635 297 111 460 623 0.002378646284341812 -00035635 128 236 238 315 0.0019606042187660933 -00035635 204 146 323 362 0.0019473455613479018 -00035635 23 95 254 651 0.0017580452840775251 -00035635 272 371 380 615 0.0015840621199458838 -00035635 0 468 109 768 0.001275054644793272 -00035635 0 670 105 759 0.0012715993216261268 -00035635 178 423 338 600 0.0010581344831734896 -00035635 433 289 504 497 0.0010389654198661447 -00035635 350 396 458 584 0.0009849437046796083 -00035635 48 218 182 330 0.0009708252036944032 -00035635 412 671 512 755 0.0008861586102284491 -00035635 115 84 271 273 0.0008384454413317144 -00035635 52 206 175 564 0.0007300805300474167 -00035635 116 444 262 560 0.0006994891446083784 -00035635 109 547 251 659 0.0006538451998494565 -00035635 280 246 377 522 0.0006502107717096806 -00035635 32 519 177 684 0.0006300053792074323 -00035635 356 331 442 440 0.0005845251143909991 -00035635 129 284 237 508 0.0005117427790537477 -00035635 60 277 160 471 0.0005114825908094645 -00035635 270 206 375 331 0.00048127619083970785 -00035635 44 152 229 351 0.00047699446440674365 -00035635 132 339 425 646 0.0004545162955764681 -00035635 23 669 189 761 0.00045146659249439836 -00035635 47 231 334 536 0.0003717626677826047 -00035635 365 429 511 557 0.0003406273608561605 -00035635 304 652 512 768 0.0003139482287224382 -00035635 207 555 303 642 0.0002988954074680805 -00035635 415 401 512 733 0.0002865834394469857 -00035635 206 237 312 320 0.0002680493053048849 -00035635 340 119 444 446 0.00025423202896490693 -00035635 277 449 379 559 0.00024970012600533664 -00035635 280 338 371 434 0.0002345809480175376 -00035635 0 23 157 737 0.0002314470912097022 -00035635 140 653 340 768 0.00022031478874851018 -00035635 352 458 440 540 0.0002125000028172508 -00035635 166 313 335 467 0.0002062947751255706 -00035635 423 452 499 541 0.00020343433425296098 -00035635 443 0 512 443 0.00020288460655137897 -00035635 31 0 226 435 0.00019246978627052158 -00035635 368 333 512 633 0.00019027013331651688 -00035635 87 53 348 378 0.00018567664665170014 -00035635 127 338 268 450 0.00018149284005630761 -00035635 42 333 160 424 0.00017923378618434072 -00035635 195 247 477 511 0.00015656722825951874 -00035635 112 671 253 765 0.00015264384273905307 -00035635 207 453 302 542 0.00015120966418180615 -00035635 344 62 442 280 0.00014004811237100512 -00035635 0 441 417 768 0.00013604489504359663 -00035635 133 120 241 236 0.00012094359408365563 -00035635 0 0 99 495 0.00011243269545957446 -00035635 0 552 107 667 0.00010408610251033679 -00035635 209 109 328 205 0.00010359201405663043 -00035635 0 412 105 574 0.00010155184281757101 -00049736 5 60 357 488 0.9960564374923706 -00049736 162 68 446 505 0.6719235777854919 -00049736 0 73 151 489 0.3681921660900116 -00049736 294 149 447 505 0.31004464626312256 -00049736 59 70 265 370 0.054970815777778625 -00049736 16 239 295 512 0.051978111267089844 -00049736 0 30 156 231 0.049275580793619156 -00049736 199 241 374 512 0.038529664278030396 -00049736 188 78 359 322 0.03765743598341942 -00049736 0 310 133 512 0.02319936826825142 -00049736 58 36 243 204 0.01730644330382347 -00049736 635 333 768 497 0.016376622021198273 -00049736 33 384 274 512 0.012192524038255215 -00049736 309 245 435 421 0.008943583816289902 -00049736 4 5 130 96 0.008081500418484211 -00049736 626 406 752 511 0.0079392334446311 -00049736 408 217 548 303 0.007434685714542866 -00049736 295 93 446 327 0.006321291904896498 -00049736 199 42 356 210 0.005443563684821129 -00049736 85 0 245 93 0.005272073205560446 -00049736 0 158 118 343 0.00520692951977253 -00049736 640 0 730 66 0.005100768990814686 -00049736 302 324 451 490 0.004670242313295603 -00049736 59 353 242 468 0.004144612234085798 -00049736 31 5 768 512 0.00392926437780261 -00049736 18 403 151 509 0.0037611338775604963 -00049736 78 205 251 449 0.003475954057648778 -00049736 403 251 562 425 0.003344107884913683 -00049736 91 295 465 512 0.003202399704605341 -00049736 182 380 366 512 0.003090837737545371 -00049736 6 239 121 427 0.002794140251353383 -00049736 209 0 346 95 0.0027575697749853134 -00049736 83 107 238 236 0.0027025239542126656 -00049736 11 3 348 283 0.0022753735538572073 -00049736 647 363 766 442 0.0020165028981864452 -00049736 321 194 444 313 0.0017973019275814295 -00049736 393 305 551 493 0.001757959951646626 -00049736 317 291 442 355 0.0015206626849249005 -00049736 308 7 443 66 0.0014347851974889636 -00049736 389 167 560 351 0.0014336461899802089 -00049736 32 0 312 142 0.0014267273945733905 -00049736 632 0 758 179 0.0012978059239685535 -00049736 259 82 598 501 0.0012594008585438132 -00049736 291 407 461 512 0.0012341917026787996 -00049736 416 294 557 365 0.001195562188513577 -00049736 392 144 575 236 0.001180910738185048 -00049736 206 264 356 403 0.001093524624593556 -00049736 137 101 408 246 0.0010163452243432403 -00049736 125 231 441 438 0.0009884013561531901 -00049736 83 176 234 317 0.0009568653767928481 -00049736 5 365 131 451 0.0009261324303224683 -00049736 308 202 630 313 0.0008603077731095254 -00049736 185 354 402 461 0.0008436915813945234 -00049736 201 142 339 226 0.0008303183712996542 -00049736 452 416 737 512 0.0007777310092933476 -00049736 210 193 356 311 0.0007423642091453075 -00049736 9 61 139 156 0.0007366120698861778 -00049736 5 138 119 220 0.0007306770421564579 -00049736 255 323 617 495 0.000693094334565103 -00049736 404 422 579 512 0.000673351576551795 -00049736 525 6 677 60 0.0006362493732012808 -00049736 243 2 558 77 0.0006083156331442297 -00049736 626 169 768 486 0.0005766884423792362 -00049736 86 66 224 158 0.0005534703377634287 -00049736 279 258 621 435 0.0005424958653748035 -00049736 177 419 559 512 0.0005314233130775392 -00049736 58 281 254 385 0.0005172271048650146 -00049736 0 216 113 294 0.0004919166094623506 -00049736 84 374 233 429 0.00048600794980302453 -00049736 162 11 379 140 0.0004730106156785041 -00049736 294 41 461 224 0.0004689077031798661 -00049736 318 143 448 224 0.0004450618289411068 -00049736 531 225 683 297 0.00041610634070821106 -00049736 15 170 333 329 0.000389123015338555 -00049736 358 104 599 263 0.00038782309275120497 -00049736 308 228 425 281 0.0003832030051853508 -00049736 425 0 739 71 0.00037614646134898067 -00049736 17 120 500 365 0.00037287009763531387 -00049736 201 171 675 347 0.00035750397364608943 -00049736 291 5 466 126 0.0003379762056283653 -00049736 510 297 698 500 0.00030197997693903744 -00049736 1 291 120 367 0.0003019428113475442 -00049736 423 54 582 171 0.0002952874347101897 -00049736 227 69 339 162 0.00029319082386791706 -00049736 446 17 768 470 0.00028081220807507634 -00049736 204 301 335 353 0.0002780314825940877 -00049736 97 155 224 212 0.0002647485234774649 -00049736 215 99 747 266 0.0002605488698463887 -00049736 206 376 344 432 0.0002577457926236093 -00049736 76 445 244 505 0.0002510900376364589 -00049736 204 446 363 505 0.00023869663709774613 -00049736 103 2 464 103 0.00022333009110298008 -00049736 284 364 470 445 0.0002196197456214577 -00049736 206 230 330 282 0.00020889802544843405 -00049736 620 70 741 132 0.00020067479636054486 -00049736 535 11 708 200 0.00018031505169346929 -00049736 92 231 224 282 0.00017632618255447596 -00049736 520 449 693 506 0.00017475367349106818 -00049736 517 176 705 349 0.00015294659533537924 -00049736 526 345 673 460 0.0001499950885772705 -00049736 525 299 700 368 0.00014876158093102276 -00049736 539 49 670 157 0.00014690229727420956 -00049736 639 184 768 326 0.0001433542784070596 -00049736 88 302 234 356 0.0001413424761267379 -00049736 606 0 756 341 0.00012745802814606577 -00049736 417 367 555 440 0.00011021708633052185 -00049736 378 22 625 212 0.00010244589793728665 \ No newline at end of file +02249614 65 115 284 334 0.11435138434171677 +02249614 92 25 357 424 0.127435103058815 +02249614 65 15 284 234 0.14974096417427063 +02249614 165 115 384 334 0.17529238760471344 +02249614 115 34 334 515 0.17793156206607819 +02249614 162 -12 287 262 0.20319262146949768 +02249614 112 37 237 312 0.20388354361057281 +02249614 65 60 284 389 0.37386229634284973 +02249614 165 60 384 389 0.41293928027153015 +02249614 115 -39 334 289 0.41427987813949585 +02249614 115 15 334 234 0.5675835013389587 +02249614 65 10 284 339 0.6445811986923218 +02249614 92 92 357 357 0.6764624714851379 +02249614 165 10 384 339 0.794566810131073 +02249614 162 37 287 312 0.8439006805419922 +02249614 142 42 407 307 0.8930709958076477 +02249614 42 42 307 307 0.8957828879356384 +02249614 115 115 334 334 0.9514585733413696 +02249614 65 65 284 284 0.9604349732398987 +02249614 115 10 334 339 0.970931351184845 +02249614 115 60 334 389 0.9861239194869995 +02249614 92 42 357 307 0.9872657060623169 +02249614 115 65 334 284 0.9875077605247498 +02247421 65 165 284 384 0.10739228874444962 +02247421 -96 17 246 532 0.10774776339530945 +02247421 112 137 237 412 0.10862737894058228 +02247421 -46 117 296 632 0.11600174009799957 +02247421 42 -67 307 517 0.11964241415262222 +02247421 42 42 307 307 0.12091951072216034 +02247421 -96 153 246 496 0.12462905049324036 +02247421 92 25 357 424 0.13260731101036072 +02247421 -7 -117 257 467 0.13391970098018646 +02247421 42 175 307 574 0.14761845767498016 +02247421 -7 42 257 307 0.16014616191387177 +02247421 42 132 307 717 0.1734863519668579 +02247421 -46 221 296 428 0.18211039900779724 +02247421 65 134 284 615 0.18877118825912476 +02247421 15 210 234 539 0.20378996431827545 +02247421 115 60 334 389 0.20593030750751495 +02247421 112 181 237 368 0.21045942604541779 +02247421 65 10 284 339 0.224850594997406 +02247421 15 165 234 384 0.23230236768722534 +02247421 92 92 357 357 0.24125336110591888 +02247421 3 171 346 378 0.30774781107902527 +02247421 42 -117 307 467 0.3205472528934479 +02247421 42 -17 307 567 0.3917545974254608 +02247421 3 121 346 328 0.4078617990016937 +02247421 -96 103 246 446 0.4144771695137024 +02247421 -7 132 257 717 0.42445868253707886 +02247421 42 32 307 617 0.4286566376686096 +02247421 53 103 396 446 0.42928609251976013 +02247421 3 -32 346 482 0.45051756501197815 +02247421 -7 -24 257 374 0.5604137182235718 +02247421 65 115 284 334 0.5604478716850281 +02247421 42 82 307 667 0.5879097580909729 +02247421 53 53 396 396 0.6182984709739685 +02247421 42 -24 307 374 0.6469487547874451 +02247421 -46 -32 296 482 0.6791166663169861 +02247421 -46 171 296 378 0.6863168478012085 +02247421 15 10 234 339 0.6878474950790405 +02247421 -7 242 257 507 0.7024731040000916 +02247421 42 192 307 457 0.7269757390022278 +02247421 -7 -67 257 517 0.7451796531677246 +02247421 -46 121 296 328 0.751475989818573 +02247421 15 115 234 334 0.7877477407455444 +02247421 3 67 346 582 0.800713837146759 +02247421 3 17 346 532 0.835267961025238 +02247421 65 -65 284 415 0.8378594517707825 +02247421 65 160 284 489 0.854299008846283 +02247421 -46 67 296 582 0.8612954616546631 +02247421 15 134 234 615 0.9034911394119263 +02247421 -7 175 257 574 0.9331607222557068 +02247421 65 -15 284 465 0.9333763718605042 +02247421 15 -65 234 415 0.9469347596168518 +02247421 42 142 307 407 0.9641258120536804 +02247421 -46 17 296 532 0.9649289846420288 +02247421 15 160 234 489 0.9664151072502136 +02247421 65 34 284 515 0.9778496026992798 +02247421 -7 -17 257 567 0.9817848205566406 +02247421 -7 32 257 617 0.9818206429481506 +02247421 3 53 346 396 0.9827135801315308 +02247421 65 110 284 439 0.9831369519233704 +02247421 -46 53 296 396 0.9835508465766907 +02247421 -7 82 257 667 0.9836792349815369 +02247421 15 -15 234 465 0.983996570110321 +02247421 65 84 284 565 0.9849858283996582 +02247421 65 60 284 389 0.9855386018753052 +02247421 3 153 346 496 0.985903799533844 +02247421 -7 192 257 457 0.9874616265296936 +02247421 42 92 307 357 0.9892619848251343 +02247421 15 60 234 389 0.990605890750885 +02247421 -46 153 296 496 0.9914147257804871 +02247421 42 125 307 524 0.9944851994514465 +02247421 15 110 234 439 0.9951778650283813 +02247421 42 25 307 424 0.9958212375640869 +02247421 3 103 346 446 0.9973427653312683 +02247421 15 34 234 515 0.9974967837333679 +02247421 -7 142 257 407 0.9976779818534851 +02247421 -7 92 257 357 0.9976812601089478 +02247421 42 75 307 474 0.9977225661277771 +02247421 15 84 234 565 0.9979581832885742 +02247421 -7 25 257 424 0.99849534034729 +02247421 -46 103 296 446 0.9990177154541016 +02247421 -7 125 257 524 0.9997511506080627 +02247421 -7 75 257 474 0.9999322891235352 +02249576 3 3 346 346 0.10726945847272873 +02249576 -7 92 257 357 0.10764674097299576 +02249576 -96 -32 246 482 0.1096310019493103 +02249576 -7 242 257 507 0.12057746946811676 +02249576 65 110 284 439 0.12198618054389954 +02249576 103 -32 446 482 0.1285630166530609 +02249576 15 60 234 389 0.12870939075946808 +02249576 192 125 457 524 0.13079483807086945 +02249576 165 184 384 665 0.13839243352413177 +02249576 3 -103 346 653 0.13900315761566162 +02249576 42 -117 307 467 0.17445659637451172 +02249576 -7 192 257 457 0.1866433322429657 +02249576 53 167 396 682 0.18708133697509766 +02249576 53 -253 396 503 0.22112397849559784 +02249576 165 265 384 484 0.25993046164512634 +02249576 -46 -82 296 432 0.27460145950317383 +02249576 -34 84 184 565 0.28630197048187256 +02249576 53 -103 396 653 0.28783923387527466 +02249576 92 132 357 717 0.4297880232334137 +02249576 53 -82 396 432 0.47827836871147156 +02249576 -96 103 246 446 0.5075122117996216 +02249576 -96 67 246 582 0.5092635750770569 +02249576 103 203 446 546 0.5178287029266357 +02249576 -7 142 257 407 0.5224711298942566 +02249576 142 132 407 717 0.5671201348304749 +02249576 142 -67 407 517 0.6074339747428894 +02249576 -57 125 207 524 0.6107057929039001 +02249576 53 53 396 396 0.6149684190750122 +02249576 92 142 357 407 0.6370267868041992 +02249576 -96 153 246 496 0.6733827590942383 +02249576 53 -203 396 553 0.6888253092765808 +02249576 115 210 334 539 0.7124033570289612 +02249576 3 203 346 546 0.7316920757293701 +02249576 142 142 407 407 0.7354334592819214 +02249576 3 53 346 396 0.7624342441558838 +02249576 3 -82 346 432 0.7626661062240601 +02249576 15 160 234 489 0.7674854397773743 +02249576 -7 -117 257 467 0.7699214816093445 +02249576 -46 -153 296 603 0.7705489993095398 +02249576 -34 34 184 515 0.7742652297019958 +02249576 -46 203 296 546 0.7760255336761475 +02249576 103 117 446 632 0.7815256118774414 +02249576 53 203 396 546 0.8008450269699097 +02249576 -46 -253 296 503 0.8050944209098816 +02249576 42 32 307 617 0.8098806142807007 +02249576 92 242 357 507 0.8367900848388672 +02249576 3 -253 346 503 0.8538235425949097 +02249576 142 192 407 457 0.8690260052680969 +02249576 153 153 496 496 0.8717634081840515 +02249576 15 -15 234 465 0.878864049911499 +02249576 -96 17 246 532 0.9018354415893555 +02249576 142 242 407 507 0.9037714600563049 +02249576 -46 117 296 632 0.932393491268158 +02249576 -46 53 296 396 0.9361428022384644 +02249576 65 84 284 565 0.9385261535644531 +02249576 53 117 396 632 0.9442618489265442 +02249576 -46 -203 296 553 0.9482489228248596 +02249576 3 -203 346 553 0.9531092643737793 +02249576 3 117 346 632 0.9561370015144348 +02249576 103 17 446 532 0.958500862121582 +02249576 115 110 334 439 0.958509624004364 +02249576 142 -17 407 567 0.9603559970855713 +02249576 165 210 384 539 0.9613518118858337 +02249576 15 110 234 439 0.9626227021217346 +02249576 -57 75 207 474 0.962848961353302 +02249576 42 -17 307 567 0.969247579574585 +02249576 53 -153 396 603 0.9694505333900452 +02249576 15 134 234 615 0.9695685505867004 +02249576 92 192 357 457 0.9713100790977478 +02249576 103 67 446 582 0.9754815697669983 +02249576 42 -67 307 517 0.9755988717079163 +02249576 -7 175 257 574 0.977362871170044 +02249576 92 -67 357 517 0.9778679609298706 +02249576 -7 25 257 424 0.9792865514755249 +02249576 3 -153 346 603 0.9820600748062134 +02249576 53 -32 396 482 0.9846789240837097 +02249576 103 103 446 446 0.9847381114959717 +02249576 92 175 357 574 0.986079752445221 +02249576 -46 -32 296 482 0.9866190552711487 +02249576 165 110 384 439 0.9870151281356812 +02249576 42 125 307 524 0.9883080124855042 +02249576 -7 82 257 667 0.9885198473930359 +02249576 53 67 396 582 0.9910281300544739 +02249576 3 -32 346 482 0.9912748336791992 +02249576 65 34 284 515 0.9926095604896545 +02249576 115 134 334 615 0.993029773235321 +02249576 142 175 407 574 0.9938539266586304 +02249576 92 82 357 667 0.9940272569656372 +02249576 92 -17 357 567 0.9943101406097412 +02249576 142 32 407 617 0.9943558573722839 +02249576 142 82 407 667 0.994690477848053 +02249576 -46 103 296 446 0.9947088956832886 +02249576 -46 153 296 496 0.9957232475280762 +02249576 92 32 357 617 0.9959217309951782 +02249576 53 17 396 532 0.9960122108459473 +02249576 53 103 396 446 0.9970279335975647 +02249576 42 75 307 474 0.9974703788757324 +02249576 -46 17 296 532 0.9975010752677917 +02249576 -46 67 296 582 0.9975913763046265 +02249576 165 160 384 489 0.9977046847343445 +02249576 3 103 346 446 0.9982824325561523 +02249576 -7 -67 257 517 0.9987599849700928 +02249576 103 153 446 496 0.9988300204277039 +02249576 142 75 407 474 0.9989663362503052 +02249576 -7 32 257 617 0.9989855885505676 +02249576 115 160 334 489 0.9990261793136597 +02249576 165 134 384 615 0.9990392923355103 +02249576 115 34 334 515 0.9990642666816711 +02249576 -7 -17 257 567 0.9991101622581482 +02249576 165 34 384 515 0.9993141889572144 +02249576 53 153 396 496 0.9993234872817993 +02249576 15 84 234 565 0.9993492960929871 +02249576 3 67 346 582 0.9994319081306458 +02249576 3 153 346 496 0.9994342923164368 +02249576 92 75 357 474 0.999553382396698 +02249576 3 17 346 532 0.9996030926704407 +02249576 -7 125 257 524 0.9997264742851257 +02249576 165 84 384 565 0.9997411370277405 +02249576 142 125 407 524 0.9997695088386536 +02249576 115 84 334 565 0.9998825788497925 +02249576 15 34 234 515 0.9999442100524902 +02249576 92 125 357 524 0.9999499320983887 +02249576 -7 75 257 474 0.999977707862854 diff --git a/mmp/a6/nms.py b/mmp/a6/nms.py index 00064b7..3171293 100644 --- a/mmp/a6/nms.py +++ b/mmp/a6/nms.py @@ -1,6 +1,9 @@ +import os from typing import List, Sequence, Tuple from ..a3.annotation import AnnotationRect +from ..a4.label_grid import iou, draw_annotation_rects +from collections import defaultdict def non_maximum_suppression( @@ -12,4 +15,68 @@ def non_maximum_suppression( @return: A list of tuples of the remaining boxes after NMS together with their scores """ - raise NotImplementedError() + if not boxes_scores: + return [] + + # Sort the boxes by score in descending order + boxes_scores_sorted = sorted(boxes_scores, key=lambda bs: bs[1], reverse=True) + result = [] + while boxes_scores_sorted: + # Select the box with highest score and remove it from the list + curr_box, curr_score = boxes_scores_sorted.pop(0) + result.append((curr_box, curr_score)) + # Remove boxes with IoU > threshold + new_boxes = [] + for box, score in boxes_scores_sorted: + if iou(curr_box, box) <= threshold: + new_boxes.append((box, score)) + boxes_scores_sorted = new_boxes + return result + + +def read_boxes_from_file(filepath: str) -> List[Tuple[str, AnnotationRect, float]]: + """ + Reads a file containing bounding boxes and scores in the format: + {image_number} {x1} {y1} {x2} {y2} {score} + Returns a list of tuples: (image_number, x1, y1, x2, y2, score) + """ + boxes: List[Tuple[AnnotationRect, float]] = [] + with open(filepath, "r") as f: + for line in f: + parts = line.strip().split() + if len(parts) != 6: + continue + img_id = parts[0] + x1, y1, x2, y2 = map(int, parts[1:5]) + annotation_rect = AnnotationRect(x1, y1, x2, y2) + score = float(parts[5]) + boxes.append((img_id, annotation_rect, score)) + return boxes + + +def main(): + boxes = read_boxes_from_file("mmp/a6/model_output.txt") + + grouped = defaultdict(list) + for image_id, rect, score in boxes: + grouped[image_id].append((rect, score)) + + for image_id, rects_scores in grouped.items(): + filtered_boxes = non_maximum_suppression(rects_scores, 0.3) + annotation_rects = [rect for rect, score in filtered_boxes if score > 0.5] + input_path = f".data/mmp-public-3.2/test/{image_id}.jpg" + output_path = f"mmp/a6/nms_output_{image_id}.png" + if not os.path.exists(input_path): + continue + + draw_annotation_rects( + input_path, + annotation_rects, + rect_color=(255, 0, 0), + rect_width=2, + output_path=output_path, + ) + + +if __name__ == "__main__": + main() diff --git a/mmp/a6/nms_output_02247421.png b/mmp/a6/nms_output_02247421.png new file mode 100644 index 0000000..5163943 Binary files /dev/null and b/mmp/a6/nms_output_02247421.png differ diff --git a/mmp/a6/nms_output_02249576.png b/mmp/a6/nms_output_02249576.png new file mode 100644 index 0000000..d9975cc Binary files /dev/null and b/mmp/a6/nms_output_02249576.png differ diff --git a/mmp/a6/nms_output_02249614.png b/mmp/a6/nms_output_02249614.png new file mode 100644 index 0000000..c6c15b8 Binary files /dev/null and b/mmp/a6/nms_output_02249614.png differ