Skip to content

Commit

Permalink
Merge pull request #2263 from Trusted-AI/development_issue_2262_2
Browse files Browse the repository at this point in the history
Remove in-place operations
  • Loading branch information
beat-buesser committed Sep 1, 2023
2 parents 8d9de16 + 52f64a8 commit ad0a546
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions art/estimators/object_detection/pytorch_object_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _preprocess_and_convert_inputs(

if not self.channels_first:
x_tensor = torch.permute(x_tensor, (0, 3, 1, 2))
x_tensor /= norm_factor
x_tensor = x_tensor / norm_factor

# Set gradients
if not no_grad:
Expand All @@ -236,7 +236,7 @@ def _preprocess_and_convert_inputs(

if not self.channels_first:
x_preprocessed = torch.permute(x_preprocessed, (0, 3, 1, 2))
x_preprocessed /= norm_factor
x_preprocessed = x_preprocessed / norm_factor

# Set gradients
if not no_grad:
Expand Down
8 changes: 4 additions & 4 deletions art/estimators/object_detection/pytorch_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def translate_labels_x1y1x2y2_to_xcycwh(
labels[:, 2:6] = label_dict["boxes"]

# normalize bounding boxes to [0, 1]
labels[:, 2:6:2] /= width
labels[:, 3:6:2] /= height
labels[:, 2:6:2] = labels[:, 2:6:2] / width
labels[:, 3:6:2] = labels[:, 3:6:2] / height

# convert from x1y1x2y2 to xcycwh
labels[:, 4] -= labels[:, 2]
Expand Down Expand Up @@ -290,7 +290,7 @@ def _preprocess_and_convert_inputs(

if not self.channels_first:
x_tensor = torch.permute(x_tensor, (0, 3, 1, 2))
x_tensor /= norm_factor
x_tensor = x_tensor / norm_factor

# Set gradients
if not no_grad:
Expand All @@ -311,7 +311,7 @@ def _preprocess_and_convert_inputs(

if not self.channels_first:
x_preprocessed = torch.permute(x_preprocessed, (0, 3, 1, 2))
x_preprocessed /= norm_factor
x_preprocessed = x_preprocessed / norm_factor

# Set gradients
if not no_grad:
Expand Down

0 comments on commit ad0a546

Please sign in to comment.