Is there a way to parse multiple images on the model?


#1

Hi,

Sorry if this is a easy question, this isn’t really my background.

The demo from here:

https://gluon-cv.mxnet.io/build/examples_segmentation/demo_psp.html

Works great however this line

output = model.demo(img)

Only accepts one image.

If there a way to send multiple images?

Would sending more be more efficient than just looping the model.demo call?

Thanks!


#2

You can just feed a batch of images into model.demo() or model(). So instead of having only one image with the shape of (1L, 3L, 512L, 669L), you would then have (batch, 3L, 512L, 669L).


#3

Hey Thanks for the reply.

Try as I might with batches I just cannot seem to get them to work. I think part of the problem is I can’t seem to find any documentation / official demo’s on how to use them. People just seem to assume you can figure it out.

I managed to find a sort of example from someone on Github which looks like this: https://gist.github.com/jackdh/3e23172c41f9cea64e73f021b7c1827f

However this is still not working as for some reason it is not possible to debug the outputs of the model, my IDE’s just freeze so I have no idea what the model is out putting.

Is there any examples / decent documentation on the batches?


#4

You can use the Gluon Dataloader:

dataloader = gluon.data.DataLoader(gluon.data.vision.ImageFolderDataset("/home/").transform_first(transform_fn),batch_size=batch_size)

for i, batch in enumerate(dataloader):
   model(batch[0])

ImageFolderDataset is expecting a folder images in the home directory. This will automatically load all images located in images, normalize them and when iterating over the dataloader, it will give a batch of images.