Cropper¶
matmmextract.inference.cropper¶
Crop detected panels from images using the JSON files produced by
run().
Output naming convention¶
<stem>_<label>.jpg — highest-confidence detection for that label.
When multiple detections share a label, only the one with the highest
score is saved. These names are matched by dataset_builder’s IMG_RE pattern.
- class CropResult(n_crops: 'int' = 0, n_skipped: 'int' = 0, n_no_detections: 'int' = 0, output_dir: 'str' = '', failed: 'list[str]' = <factory>)[source]¶
- failed: list[str]¶
- n_crops: int = 0¶
- n_no_detections: int = 0¶
- n_skipped: int = 0¶
- output_dir: str = ''¶
- crop(image_dir: str | Path, json_dir: str | Path, output_dir: str | Path, limit: int | None = None, verbose: bool = True) CropResult[source]¶
Crop all detected panels and save them as individual JPEG files.
- Parameters:
image_dir – Directory containing the original flat images.
json_dir – Directory containing per-image
.jsonfiles fromrun()._summary.jsonis automatically skipped.output_dir – Directory where cropped panel images are saved.
limit – Process at most this many JSON files (useful for testing).
verbose – Print progress.