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-crop-scale", type=float, default=1.4)
|
||||||
parser.add_argument("--proposal-classifier-batch", type=int, default=64)
|
parser.add_argument("--proposal-classifier-batch", type=int, default=64)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
if args.batch < 1:
|
||||||
|
parser.error("--batch must be positive")
|
||||||
if args.proposal_classifier_batch < 1:
|
if args.proposal_classifier_batch < 1:
|
||||||
parser.error("--proposal-classifier-batch must be positive")
|
parser.error("--proposal-classifier-batch must be positive")
|
||||||
if not 0.0 < args.nms_iou < 1.0:
|
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]
|
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]
|
image_paths = [item["image_path"] for item in tiles]
|
||||||
results = YOLO(str(args.model)).predict(
|
def predict_bounded(model: YOLO) -> list[Any]:
|
||||||
image_paths,
|
bounded_results: list[Any] = []
|
||||||
conf=min(args.thresholds),
|
for start in range(0, len(image_paths), args.batch):
|
||||||
device=args.device,
|
bounded_results.extend(
|
||||||
augment=args.augment,
|
model.predict(
|
||||||
imgsz=args.imgsz,
|
image_paths[start : start + args.batch],
|
||||||
batch=args.batch,
|
conf=min(args.thresholds),
|
||||||
max_det=args.max_det,
|
device=args.device,
|
||||||
iou=args.nms_iou,
|
augment=args.augment,
|
||||||
verbose=False,
|
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
|
additional_results = None
|
||||||
if args.additional_model:
|
if args.additional_model:
|
||||||
additional_results = YOLO(str(args.additional_model)).predict(
|
additional_results = predict_bounded(YOLO(str(args.additional_model)))
|
||||||
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,
|
|
||||||
)
|
|
||||||
observations: list[dict[str, Any]] = []
|
observations: list[dict[str, Any]] = []
|
||||||
for result_index, (tile, result) in enumerate(zip(tiles, results, strict=True)):
|
for result_index, (tile, result) in enumerate(zip(tiles, results, strict=True)):
|
||||||
height, width = result.orig_shape
|
height, width = result.orig_shape
|
||||||
|
|||||||
Reference in New Issue
Block a user