Skip to content

Commit 813576b

Browse files
ekagra-ranjanfmassa
authored andcommitted
Updated inceptionV3 to accept different sized images (Adaptive avg pool) (#744)
* Updated inceptionV3 to accept different sized images (Adaptive avg pool) The update allows inceptionV3 to process images larger or smaller than prescribed image size (299x299) using adaptive average pooling. Will be useful while finetuning or testing on different resolution images. * Update inception.py
1 parent 83b2dfb commit 813576b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchvision/models/inception.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def forward(self, x):
118118
# 8 x 8 x 2048
119119
x = self.Mixed_7c(x)
120120
# 8 x 8 x 2048
121-
x = F.avg_pool2d(x, kernel_size=8)
121+
# Adaptive average pooling
122+
x = F.adaptive_avg_pool2d(x, (1, 1))
122123
# 1 x 1 x 2048
123124
x = F.dropout(x, training=self.training)
124125
# 1 x 1 x 2048
@@ -311,6 +312,9 @@ def forward(self, x):
311312
# 5 x 5 x 128
312313
x = self.conv1(x)
313314
# 1 x 1 x 768
315+
# Adaptive average pooling
316+
x = F.adaptive_avg_pool2d(x, (1, 1))
317+
# 1 x 1 x 768
314318
x = x.view(x.size(0), -1)
315319
# 768
316320
x = self.fc(x)

0 commit comments

Comments
 (0)