Skip to content

Commit

Permalink
💚 [Pass] format check and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
henrytsui000 committed Jan 3, 2025
1 parent 83bfa31 commit fa548df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion yolo/tools/data_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions yolo/tools/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 2 additions & 7 deletions yolo/utils/dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit fa548df

Please sign in to comment.