.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "build/examples_auto_module/train_image_classifier_basic.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_auto_module_train_image_classifier_basic.py: 02. Train Image Classification with Auto Estimator ===================================================== This tutorial goes through the basic steps of using GluonCV auto estimator to train an image classifier with custom hyper-parameters. .. GENERATED FROM PYTHON SOURCE LINES 9-11 Train with default configurations --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 11-13 .. code-block:: default from gluoncv.auto.estimators import ImageClassificationEstimator .. GENERATED FROM PYTHON SOURCE LINES 14-15 In this tutorial, we use a small sample dataset .. GENERATED FROM PYTHON SOURCE LINES 15-19 .. code-block:: default train, _, test = ImageClassificationEstimator.Dataset.from_folders( 'https://autogluon.s3.amazonaws.com/datasets/shopee-iet.zip') train, val, _ = train.random_split(val_size=0.1, test_size=0) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none data/ ├── test/ └── train/ .. GENERATED FROM PYTHON SOURCE LINES 20-28 Create an estimator with default configurations. We only change the number of GPUs to reflect the hardware constraint. Note that you may still launch training if no gpu is available(with {'gpus': []}) but be prepared that this is painfully slow and not even possible to finish in case the dataset isn't tiny. We recommend that you use at least one nvidia gpu with more than 6GB free GPU memory. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: default classifier = ImageClassificationEstimator( {'gpus': [0], 'train': {'batch_size': 16, 'epochs': 2}}) .. GENERATED FROM PYTHON SOURCE LINES 33-34 run fit on train/validation data .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: default classifier.fit(train, val) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Downloading /root/.mxnet/models/resnet50_v1-cc729d95.zip from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/models/resnet50_v1-cc729d95.zip... 0%| | 0/57421 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: train_image_classifier_basic.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_