How to pass a succession of images through Convolutional Neural Network in Jupyter Notebook?

Hedshna_Mensa: <p>Hello! I’m sorry if this is a bad question–I’m relatively new to CNNs and still figuring out everything. I constructed a CNN for image classification (3 classes) and it’s been working properly and defining the images accurately. I can pass a single image through it using the following code:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/9/09acdc26d8371841769f2ff28669e13afd5e6979.png" data-download-href="https://discuss.pytorch.org/uploads/default/09acdc26d8371841769f2ff28669e13afd5e6979" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09acdc26d8371841769f2ff28669e13afd5e6979_2_690x491.png" alt="image" data-base62-sha1="1nAEaWaSdWJjJCaExP17RJ9GqrD" width="690" height="491" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09acdc26d8371841769f2ff28669e13afd5e6979_2_690x491.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09acdc26d8371841769f2ff28669e13afd5e6979_2_1035x736.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09acdc26d8371841769f2ff28669e13afd5e6979_2_1380x982.png 2x" data-dominant-color="F2F2F2"><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">1975×1407 224 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></p>
<p>As you can see, I can define the image path for the single image being classified as “./Final Testing Images/50”. However, I have a separate image folder on my computer that is constantly receiving images (so it’s not static; there are constantly new images in it) and I want the CNN to be able to pass each new image through the model and output its class. How would I accomplish this?</p>
<p>Thank you very much! I appreciate any help.</p>

ptrblck: <p>Depending on your use case you could use <code>os.listdir</code> to check for the folder content and once a new image is detected you could execute it.</p>

Hedshna_Mensa: <p>I thought of that–thank you! But, I was hoping to have this done automatically as images are added every 2-3 seconds. Is there any way to do that?</p>

ptrblck: <p>You could check <code>torchserve</code> or <a href="https://developer.nvidia.com/triton-inference-server"><code>NVIDIA/Triton Inference Server</code></a> to check if these serving applications would provide a convenient interface for it (I would assume so).</p>

Hedshna_Mensa: <p>I’m sorry if this is a bad question–what is a serving application? I see what it is on Google, but how would I implement it?</p>

ptrblck: <p><code>TorchServe</code> and <code>Triton</code> are applications to deploy models (serve them) using trained models and usually come with utils. to process new inputs (including batching) and to return responses to the user (e.g. via the web). I don’t know if this would fit your use case. If not, you might want to apply a custom solution using the initial suggestion.</p>

Hedshna_Mensa: <p>OK, that makes sense. Thank you very much!</p>
<p>If that doesn’t work/I can’t create a custom solution, would you know of any other ways?</p>