Skip to content

Commit

Permalink
add .clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultdvx committed Dec 11, 2024
1 parent 8f1ba86 commit 7e711bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clinicadl/transforms/extraction/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def extract_sample(
"1 sample in the image."
)

return image_tensor
return image_tensor.clone()

def sample_path(self, image_path: Path, sample_index: int = 0) -> Path: # pylint:disable=unused-argument
"""
Expand Down
3 changes: 1 addition & 2 deletions clinicadl/transforms/extraction/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ def extract_sample(
This method allows for the extraction of individual patches based on the provided index.
"""
patches_tensor = self.get_patches(image_tensor)
print(patches_tensor[1])
try:
return patches_tensor[sample_index, ...].unsqueeze_(0).clone()
return patches_tensor[sample_index].unsqueeze(0).clone()
except IndexError as exc:
raise IndexError(
f"'sample_index' {sample_index} is out of range as there are only "
Expand Down
2 changes: 1 addition & 1 deletion clinicadl/transforms/extraction/roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def extract_sample(
:, x_min : x_max + 1, y_min : y_max + 1, z_min : z_max + 1
]

return roi_tensor.float().clone()
return roi_tensor.clone()

# TODO : to revise -> roi filename is not unique
def sample_path(self, image_path: Path, sample_index: int) -> Path:
Expand Down

0 comments on commit 7e711bc

Please sign in to comment.