Start optimizing CV models in less than 10 lines of code with GluonCV 0.10

Joshua Z. Zhang
Apache MXNet
Published in
3 min readMar 26, 2021
Train computer vision models with HPO in less than 10 lines of code!

For a very long period of time, GluonCV has been focusing on providing diverse models targeting various computer vision tasks, from fundamental image classification, object detection, to depth estimation and video action recognition, etc.
Now it’s time for the long-overdue high-level training/inference API to be available for all users! Are you tired of checking the implementation difference or details in order to compose the right model, e.g., neural network architectures, training loop, metrics, losses? The new auto estimators and task handlers might be the right tool for you. There are new tools such as hyper-parameter optimization(HPO) to help you achieve better models without extensive manual exploration.

GluonCV Auto Estimators

GluonCV’s Auto Estimator are new in version 0.10. They are similar to scikit-learn and will allow you to initiate training in less than 3 lines of code. They also have a friendly customization interface:

A single line fit function to train an image classifier from web datasets

The new auto estimators pack simple predict functions which support raw image paths, data frames, gluoncv dataset. It also allows you to save and load trained estimators without knowing the underlying model implementation. In the past, for example, you need to know the corresponding pre-process and post-process functions for a particular model otherwise the model will produce wrong outputs. We recognize that these error-prone components are tricky and should be avoided. With the new estimator API, you can get rid of unnessary code snipets and prototype a working solution faster.

GluonCV Auto Tasks

On top of Auto Estimators, in this release, we also include Auto Tasks, for hyper-parameter optimization. Comparing with pure algorithm-based estimators, the auto tasks provide identical APIs and functionalities but allow you to fitwith HPO with specified num_trialsand time_limit. For object detection, it allows multiple algorithms (such as SSDEstimator and FasterRCNNEstimator) to be tuned as a categorical search space. For example, a complete HPO task can be as simple as:

An intuitive API to search for best configuration in a specified search space

Note that the search space configuration (`search_args`) can either be a dictionary shown in the above example, or a YAML configuration file (.yml, .yaml). For the latter, you can create a code-free tuning job by editing the config file alone.

Summary

GluonCV 0.10 offers two new modules: GluonCV Auto Estimatorsand GluonCV Auto Tasks. They allow you to bootstrap computer vision tasks in a few lines of code. It is still a powerful and customizable training pipeline as it supports hundreds of hyperparameters with YAML config file support. Most importantly, the high-level API is deep learning framework agnostic, which allows you to easily extend new models and tasks implemented using MXNet or PyTorch. To get started, try these tutorials first!

Acknowledgment

Special thanks to @tmwangcas, @karan6181, @bryanyzhu, @Zarand3r, @ChaiBapchya, @domin1985, @yinweisu, @mzolfaghari, @StevenJokess for contributing to this release.

Please Like/Star/Fork/Comment/Contribute if you like GluonCV, and don’t forget to check out our latest content. Stay tuned!

--

--