From f04a7ee0fc27f118531bc3dada771e7e40279542 Mon Sep 17 00:00:00 2001 From: JonathanKossick Date: Mon, 6 Nov 2023 00:16:15 +0100 Subject: [PATCH] Slicing: add unique slice index number to output file name (#943) Co-authored-by: jokober Co-authored-by: fatih <34196005+fcakyon@users.noreply.github.com> --- sahi/slicing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sahi/slicing.py b/sahi/slicing.py index eb3ff748e..7df9fcf19 100644 --- a/sahi/slicing.py +++ b/sahi/slicing.py @@ -469,7 +469,7 @@ def slice_coco( sliced_coco_images: List = [] # iterate over images and slice - for coco_image in tqdm(coco.images): + for idx, coco_image in enumerate(tqdm(coco.images)): # get image path image_path: str = os.path.join(image_dir, coco_image.file_name) # get annotation json list corresponding to selected coco image @@ -478,7 +478,7 @@ def slice_coco( slice_image_result = slice_image( image=image_path, coco_annotation_list=coco_image.annotations, - output_file_name=Path(coco_image.file_name).stem, + output_file_name=f"{Path(coco_image.file_name).stem}_{idx}", output_dir=output_dir, slice_height=slice_height, slice_width=slice_width,