Bound evaluator source batches
This commit is contained in:
@@ -180,6 +180,8 @@ def main() -> int:
|
||||
parser.add_argument("--proposal-crop-scale", type=float, default=1.4)
|
||||
parser.add_argument("--proposal-classifier-batch", type=int, default=64)
|
||||
args = parser.parse_args()
|
||||
if args.batch < 1:
|
||||
parser.error("--batch must be positive")
|
||||
if args.proposal_classifier_batch < 1:
|
||||
parser.error("--proposal-classifier-batch must be positive")
|
||||
if not 0.0 < args.nms_iou < 1.0:
|
||||
@@ -211,23 +213,28 @@ def main() -> int:
|
||||
}
|
||||
tiles = [item for item in summary["tiles"] if item.get("kept", True) and item["split"] == args.split]
|
||||
image_paths = [item["image_path"] for item in tiles]
|
||||
results = YOLO(str(args.model)).predict(
|
||||
image_paths,
|
||||
conf=min(args.thresholds),
|
||||
device=args.device,
|
||||
augment=args.augment,
|
||||
imgsz=args.imgsz,
|
||||
batch=args.batch,
|
||||
max_det=args.max_det,
|
||||
iou=args.nms_iou,
|
||||
verbose=False,
|
||||
)
|
||||
def predict_bounded(model: YOLO) -> list[Any]:
|
||||
bounded_results: list[Any] = []
|
||||
for start in range(0, len(image_paths), args.batch):
|
||||
bounded_results.extend(
|
||||
model.predict(
|
||||
image_paths[start : start + args.batch],
|
||||
conf=min(args.thresholds),
|
||||
device=args.device,
|
||||
augment=args.augment,
|
||||
imgsz=args.imgsz,
|
||||
batch=args.batch,
|
||||
max_det=args.max_det,
|
||||
iou=args.nms_iou,
|
||||
verbose=False,
|
||||
)
|
||||
)
|
||||
return bounded_results
|
||||
|
||||
results = predict_bounded(YOLO(str(args.model)))
|
||||
additional_results = None
|
||||
if args.additional_model:
|
||||
additional_results = YOLO(str(args.additional_model)).predict(
|
||||
image_paths, conf=min(args.thresholds), device=args.device, augment=args.augment,
|
||||
imgsz=args.imgsz, batch=args.batch, max_det=args.max_det, iou=args.nms_iou, verbose=False,
|
||||
)
|
||||
additional_results = predict_bounded(YOLO(str(args.additional_model)))
|
||||
observations: list[dict[str, Any]] = []
|
||||
for result_index, (tile, result) in enumerate(zip(tiles, results, strict=True)):
|
||||
height, width = result.orig_shape
|
||||
|
||||
Reference in New Issue
Block a user