.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "build/examples_classification/demo_cifar10.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_build_examples_classification_demo_cifar10.py: 1. Getting Started with Pre-trained Model on CIFAR10 ======================================================= `CIFAR10 `__ is a dataset of tiny (32x32) images with labels, collected by Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. It is widely used as benchmark in computer vision research. |image-cifar10| .. |image-cifar10| image:: https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/datasets/cifar10.png In this tutorial, we will demonstrate how to load a pre-trained model from :ref:`gluoncv-model-zoo` and classify images from the Internet or your local disk. Step by Step ------------------ Let's first try out a pre-trained cifar model with a few lines of python code. First, please follow the `installation guide <../../index.html#installation>`__ to install ``MXNet`` and ``GluonCV`` if you haven't done so yet. .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: default import matplotlib.pyplot as plt from mxnet import gluon, nd, image from mxnet.gluon.data.vision import transforms from gluoncv import utils from gluoncv.model_zoo import get_model .. GENERATED FROM PYTHON SOURCE LINES 33-34 Then, we download and show the example image: .. GENERATED FROM PYTHON SOURCE LINES 35-44 .. code-block:: default url = 'https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/classification/plane-draw.jpeg' im_fname = utils.download(url) img = image.imread(im_fname) plt.imshow(img.asnumpy()) plt.show() .. image-sg:: /build/examples_classification/images/sphx_glr_demo_cifar10_001.png :alt: demo cifar10 :srcset: /build/examples_classification/images/sphx_glr_demo_cifar10_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Downloading plane-draw.jpeg from https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/classification/plane-draw.jpeg... 0%| | 0/99 [00:00` Feed in your own image to see how well it does the job. Keep in mind that ``CIFAR10`` is a small dataset with only 10 classes. Models trained on ``CIFAR10`` only recognize objects from those 10 classes. Thus, it may surprise you if we feed one image to the model which doesn't belong to any of the 10 classes For instance we can test it with the following photo of Mt. Baker: |image-mtbaker| :: python demo_cifar10.py --model cifar_resnet110_v1 --input-pic mt_baker.jpg The result is: :: The input picture is classified to be [ship], with probability 0.949. Next Step --------- Congratulations! You’ve just finished reading the first tutorial. There are a lot more to help you learn GluonCV. If you would like to dive deeper into training on ``CIFAR10``, feel free to read the next `tutorial on CIFAR10 `__. Or, if you would like to try a larger scale dataset with 1000 classes of common objects please read `Getting Started with ImageNet Pre-trained Models `__. .. |image-mtbaker| image:: https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/classification/mt_baker.jpg .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.614 seconds) .. _sphx_glr_download_build_examples_classification_demo_cifar10.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_cifar10.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_cifar10.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_