diff --git a/yolo/tools/data_augmentation.py b/yolo/tools/data_augmentation.py index 358c329..915534c 100644 --- a/yolo/tools/data_augmentation.py +++ b/yolo/tools/data_augmentation.py @@ -67,7 +67,7 @@ def __call__(self, image: Image, boxes): scale = min(self.target_width / img_width, self.target_height / img_height) new_width, new_height = int(img_width * scale), int(img_height * scale) - resized_image = image.resize((new_width, new_height), Image.LANCZOS) + resized_image = image.resize((new_width, new_height), Image.Resampling.LANCZOS) pad_left = (self.target_width - new_width) // 2 pad_top = (self.target_height - new_height) // 2 diff --git a/yolo/tools/solver.py b/yolo/tools/solver.py index 61fc871..8246a66 100644 --- a/yolo/tools/solver.py +++ b/yolo/tools/solver.py @@ -48,8 +48,9 @@ def validation_step(self, batch, batch_idx): batch_size, images, targets, rev_tensor, img_paths = batch H, W = images.shape[2:] predicts = self.post_process(self.ema(images), image_size=[W, H]) - self.metric.update([to_metrics_format(predict) for predict in predicts], - [to_metrics_format(target) for target in targets]) + self.metric.update( + [to_metrics_format(predict) for predict in predicts], [to_metrics_format(target) for target in targets] + ) return predicts def on_validation_epoch_end(self): diff --git a/yolo/utils/dataset_utils.py b/yolo/utils/dataset_utils.py index 252b349..dd9a66a 100644 --- a/yolo/utils/dataset_utils.py +++ b/yolo/utils/dataset_utils.py @@ -104,13 +104,8 @@ def scale_segmentation( if "segmentation" in anno: seg_list = [item for sublist in anno["segmentation"] for item in sublist] elif "bbox" in anno: - x,y,width,height = anno["bbox"] - seg_list = [ - x, y, # Top-left corner - x + width, y, # Top-right corner - x + width, y + height, # Bottom-right corner - x, y + height # Bottom-left corner - ] + x, y, width, height = anno["bbox"] + seg_list = [x, y, x + width, y, x + width, y + height, x, y + height] scaled_seg_data = ( np.array(seg_list).reshape(-1, 2) / [w, h]