Image recognition with GluonCV and the Notebooks
GluonCV is an open-source Deep Learning toolkit for artificial vision. GluonCV offers ready-to-use implementations of Deep Learning algorithms in this environment, allowing for:
It supports:
- Image classification.
- Object detection.
- semantic segmentation (associate each pixel of an image with a categorical label).
- Instance segmentation.
GluonCV depends on MXNet and works with Python 2.7 or higher.
In this example, we will see how we can use GluonCV from the platform's notebook for image object recognition, with images that are provided to the platform as parameters.
- Let's start by creating a Notebook and, in its first paragraph, we install GluonCV and MXNet:
- Now we import the pre-trained models we will use:
- And we load an SSD input model with images, on a VOC Pascal Dataset with ResNet-50 V1 as its base model:
By specifying pretrained=True
we will have the model downloaded (You can find more trained models).
- To test that it works, I will use one of GluonCV's example images.
I first download the image, then I pre-process it, resizing it to 512x512 pixels.
The function returns two results: First, an NDArray with the shape (batch_size, RGB_channels, height, width) which we can pass to the model; secondly, an array with the image in numpy format, so we can display it.
- And finally we perform the inference and the display:
The function returns all the detected container boxes with their Class IDs and prediction trust.
- We will now extend the notebook to provide it, as a parameter, the image on which we want recognition done. To do this, we create a new paragraph to pass the URL as a parameter.
I first create a z.input to store the parameter:
Then I use this image: