Input size for EfficientNet versions from torchvision.models

Chuong_Vo: <p>Hi guys!<br>
I’m doing some experiments with the EfficientNet as a backbone.<br>
I’m using the pre-trained EfficientNet models from <code>torchvision.models</code>.<br>
As I found from the paper and the docs of Keras, the EfficientNet variants have different input sizes as below.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/6/e64d1baec60fff5e0c138eff2ff8cd63264dc87f.png" data-download-href="https://discuss.pytorch.org/uploads/default/e64d1baec60fff5e0c138eff2ff8cd63264dc87f" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/e/6/e64d1baec60fff5e0c138eff2ff8cd63264dc87f.png" alt="image" data-base62-sha1="wRl1l75U6phZFMChR4jG3VSewLd" width="690" height="333" data-dominant-color="F7F7F7"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">734×355 11.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
Is it true for the models in Pytorch?<br>
If I want to keep the same input size for all the EfficientNet variants, will it affect the performance of the models?</p>

ptrblck: <p>Yes, the <code>torchvision</code> EfficienNet models also expect a different input shape as described in the <a href="https://pytorch.org/vision/stable/models.html">docs</a>:</p>
<blockquote>
<p>The sizes of the EfficientNet models depend on the variant. For the exact input sizes <a href="https://github.com/pytorch/vision/blob/d2bfd639e46e1c5dc3c177f889dc7750c8d137c7/references/classification/train.py#L92-L93">check here</a></p>
</blockquote>
<p>where the link points to:</p>
<pre data-code-wrap="python"><code class="lang-python">    elif args.model.startswith('efficientnet_'):
        sizes = {
            'b0': (256, 224), 'b1': (256, 240), 'b2': (288, 288), 'b3': (320, 300),
            'b4': (384, 380), 'b5': (489, 456), 'b6': (561, 528), 'b7': (633, 600),
        }
</code></pre>

Miguel_Campos: <p>Hello <a class="mention" href="/u/ptrblck">@ptrblck</a>.</p>
<p>Do you know if that sizes are still used in torchvision v.12.0 ?<br>
I can not find any information or reference in the documentation or v0.12.0 code</p>
<p>Thanks</p>

ptrblck: <p>You can read more information about each model by selecting it from <a href="https://pytorch.org/vision/stable/models/efficientnet.html">here</a>. which also describes the input size.</p>

Miguel_Campos: <p>Thanks for your answer.<br>
As you said, that is in the <strong>v0.13</strong> but I am still in the <strong>v0.12</strong> and documentation says nothing, <a href="https://pytorch.org/vision/0.12/generated/torchvision.models.efficientnet_b0.html#torchvision.models.efficientnet_b0" rel="noopener nofollow ugc">check out this example</a> or <a href="https://pytorch.org/vision/0.12/_modules/torchvision/models/efficientnet.html#efficientnet_b0" rel="noopener nofollow ugc">this</a> <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>That’s why I wonder about if the pre-processes in v0.13 and v0.12 are the same</p>

ptrblck: <p>For older versions you could use my previously posted link and change the branch to <code>0.12</code>: <a href="https://pytorch.org/vision/0.12/models.html" class="inline-onebox">Models and pre-trained weights — Torchvision 0.12 documentation</a></p>