π [Pass] format check and refactor code
Browse files- yolo/tools/data_augmentation.py +1 -1
- yolo/tools/solver.py +3 -2
- yolo/utils/dataset_utils.py +2 -7
yolo/tools/data_augmentation.py
CHANGED
@@ -67,7 +67,7 @@ class PadAndResize:
|
|
67 |
scale = min(self.target_width / img_width, self.target_height / img_height)
|
68 |
new_width, new_height = int(img_width * scale), int(img_height * scale)
|
69 |
|
70 |
-
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
71 |
|
72 |
pad_left = (self.target_width - new_width) // 2
|
73 |
pad_top = (self.target_height - new_height) // 2
|
|
|
67 |
scale = min(self.target_width / img_width, self.target_height / img_height)
|
68 |
new_width, new_height = int(img_width * scale), int(img_height * scale)
|
69 |
|
70 |
+
resized_image = image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
71 |
|
72 |
pad_left = (self.target_width - new_width) // 2
|
73 |
pad_top = (self.target_height - new_height) // 2
|
yolo/tools/solver.py
CHANGED
@@ -48,8 +48,9 @@ class ValidateModel(BaseModel):
|
|
48 |
batch_size, images, targets, rev_tensor, img_paths = batch
|
49 |
H, W = images.shape[2:]
|
50 |
predicts = self.post_process(self.ema(images), image_size=[W, H])
|
51 |
-
self.metric.update(
|
52 |
-
|
|
|
53 |
return predicts
|
54 |
|
55 |
def on_validation_epoch_end(self):
|
|
|
48 |
batch_size, images, targets, rev_tensor, img_paths = batch
|
49 |
H, W = images.shape[2:]
|
50 |
predicts = self.post_process(self.ema(images), image_size=[W, H])
|
51 |
+
self.metric.update(
|
52 |
+
[to_metrics_format(predict) for predict in predicts], [to_metrics_format(target) for target in targets]
|
53 |
+
)
|
54 |
return predicts
|
55 |
|
56 |
def on_validation_epoch_end(self):
|
yolo/utils/dataset_utils.py
CHANGED
@@ -104,13 +104,8 @@ def scale_segmentation(
|
|
104 |
if "segmentation" in anno:
|
105 |
seg_list = [item for sublist in anno["segmentation"] for item in sublist]
|
106 |
elif "bbox" in anno:
|
107 |
-
x,y,width,height = anno["bbox"]
|
108 |
-
seg_list = [
|
109 |
-
x, y, # Top-left corner
|
110 |
-
x + width, y, # Top-right corner
|
111 |
-
x + width, y + height, # Bottom-right corner
|
112 |
-
x, y + height # Bottom-left corner
|
113 |
-
]
|
114 |
|
115 |
scaled_seg_data = (
|
116 |
np.array(seg_list).reshape(-1, 2) / [w, h]
|
|
|
104 |
if "segmentation" in anno:
|
105 |
seg_list = [item for sublist in anno["segmentation"] for item in sublist]
|
106 |
elif "bbox" in anno:
|
107 |
+
x, y, width, height = anno["bbox"]
|
108 |
+
seg_list = [x, y, x + width, y, x + width, y + height, x, y + height]
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
scaled_seg_data = (
|
111 |
np.array(seg_list).reshape(-1, 2) / [w, h]
|