Classification on large images

Sylvain_Ard: <p>Hello all !<br>
I would a code of image classification which take at the input of the neural network images of 2000x1500 pixels because all the codes I have found take only 224x224 size images and I need very little details on all the image.<br>
Thank you<br>
Best regards</p>

ptrblck: <p>A lot of <code>torchvision.models</code> (and I think all classification models) accept variable spatial input shapes.<br>
Assuming your device has enough memory to train the desired model using the increased spatial input shape, you should be able to directly pass your images to the model and train it.</p>

Sylvain_Ard: <p>I don’t see any, I talk the size of the image in the input of neural network. A resizing of images before is commonly done. If you have one for this which take account of very imbalanced classes it interests me</p>

Sylvain_Ard: <p>my GPU has 24 GB of RAM so it’s sufficient, I suppose</p>

ptrblck: <aside class="quote no-group" data-username="Sylvain_Ard" data-post="3" data-topic="149896">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sylvain_ard/48/30714_2.png" class="avatar"> Sylvain_Ard:</div>
<blockquote>
<p>I don’t see any, I talk the size of the image in the input of neural network.</p>
</blockquote>
</aside>
<p>I’m not sure how to understand this.<br>
As described, you can just pass larger images to these models:</p>
<pre data-code-wrap="python"><code class="lang-python">model = models.resnet18()

x = torch.randn(1, 3, 224, 224)
out = model(x)

x = torch.randn(1, 3, 2000, 1500)
out = model(x)
</code></pre>
<p>and train them with this data.</p>

Sylvain_Ard: <p>for example with this tutorial : <a href="https://www.nbshare.io/notebook/628144649/Stock-Charts-Detection-Using-Image-Classification-Model-ResNet/" rel="noopener nofollow ugc">https://www.nbshare.io/notebook/628144649/Stock-Charts-Detection-Using-Image-Classification-Model-ResNet/</a> what I have to change to fit neural network with 2000x1500 pixels images ?</p>

Sylvain_Ard: <p>I have only to delete these lines ?</p>
<p>In [12]:</p>
<pre><code>    transforms.RandomResizedCrop(224),
    transforms.Resize((224, 224)),
    transforms.CenterCrop(224),
</code></pre>
<p>other question in this code what is the goal of the lines :<br>
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ?</p>

Sylvain_Ard: <p>in this code too : <a href="https://github.com/zhmiao/OpenLongTailRecognition-OLTR" class="inline-onebox" rel="noopener nofollow ugc">GitHub - zhmiao/OpenLongTailRecognition-OLTR: Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL)</a></p>

ptrblck: <aside class="quote no-group" data-username="Sylvain_Ard" data-post="7" data-topic="149896">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sylvain_ard/48/30714_2.png" class="avatar"> Sylvain_Ard:</div>
<blockquote>
<p>I have only to delete these lines ?</p>
</blockquote>
</aside>
<p>This could be the case, so did you try it?</p>
<aside class="quote no-group" data-username="Sylvain_Ard" data-post="7" data-topic="149896">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sylvain_ard/48/30714_2.png" class="avatar"> Sylvain_Ard:</div>
<blockquote>
<p>other question in this code what is the goal of the lines :<br>
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ?</p>
</blockquote>
</aside>
<p>This code normalizes the data by subtracting the <code>mean</code> and dividing by the <code>std</code> as described in the <a href="https://pytorch.org/vision/main/generated/torchvision.transforms.Normalize.html">docs</a>.</p>

Sylvain_Ard: <p>No I have not tried it<br>
But there will be not gestion of imbalanced classes if I do this isn’t it ?<br>
Could you look at the code and tell me please ?</p>