Commit 813576b4 authored by ekka's avatar ekka Committed by Francisco Massa
Browse files

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
parent 83b2dfb2
...@@ -118,7 +118,8 @@ class Inception3(nn.Module): ...@@ -118,7 +118,8 @@ class Inception3(nn.Module):
# 8 x 8 x 2048 # 8 x 8 x 2048
x = self.Mixed_7c(x) x = self.Mixed_7c(x)
# 8 x 8 x 2048 # 8 x 8 x 2048
x = F.avg_pool2d(x, kernel_size=8) # Adaptive average pooling
x = F.adaptive_avg_pool2d(x, (1, 1))
# 1 x 1 x 2048 # 1 x 1 x 2048
x = F.dropout(x, training=self.training) x = F.dropout(x, training=self.training)
# 1 x 1 x 2048 # 1 x 1 x 2048
...@@ -311,6 +312,9 @@ class InceptionAux(nn.Module): ...@@ -311,6 +312,9 @@ class InceptionAux(nn.Module):
# 5 x 5 x 128 # 5 x 5 x 128
x = self.conv1(x) x = self.conv1(x)
# 1 x 1 x 768 # 1 x 1 x 768
# Adaptive average pooling
x = F.adaptive_avg_pool2d(x, (1, 1))
# 1 x 1 x 768
x = x.view(x.size(0), -1) x = x.view(x.size(0), -1)
# 768 # 768
x = self.fc(x) x = self.fc(x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment