Skip to content

Commit e8e9bdb

Browse files
buoyancy99fmassa
authored andcommitted
fix transform for rcnns so original images list is unchanged (#1084)
* fix transform for rcnns so original images are unchanged * transform does not change input list anymore transform does not change input list anymore. Improve code according to reviewer comment * transform for maskrcnn no longer modify input list transform for maskrcnn no longer modify input list. improve code according to comment * transform for maskrcnn no longer modifies input list
1 parent 7d8cc19 commit e8e9bdb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

torchvision/models/detection/transform.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, min_size, max_size, image_mean, image_std):
3030
self.image_std = image_std
3131

3232
def forward(self, images, targets=None):
33+
images = images[:]
3334
for i in range(len(images)):
3435
image = images[i]
3536
target = targets[i] if targets is not None else targets
@@ -41,6 +42,7 @@ def forward(self, images, targets=None):
4142
images[i] = image
4243
if targets is not None:
4344
targets[i] = target
45+
4446
image_sizes = [img.shape[-2:] for img in images]
4547
images = self.batch_images(images)
4648
image_list = ImageList(images, image_sizes)

0 commit comments

Comments
 (0)