PyTorch releases TorchVision’s New Multi-Weight Support API
(22 December 2021)

Other recent news...

Google Announces Flutter for Windows
Flutter 2.10 enables the development of high-quality Windows apps that also run as native apps on Android and iOS devices as well as web platforms - all from the same codebase!
4 February 2022
Docker supporting COVID-19 genomic monitoring
The efficient nature of Docker containerisation has transformed how public health disease monitoring is performed and grown the scale of the viral monitoring effort.
26 January 2022
Google launches new Bumblebee version of Android Studio
Android Studio is the officially supported IDE for developing Android apps and building app packages for installation on Android devices.
25 January 2022
PyTorch releases TorchVision’s New Multi-Weight Support API
TorchVision has a new backwards compatible API for building models with multi-weight support. The new API allows loading different pre-trained weights on the same model variant, keeps track of vital meta-data such as the classification labels and includes the preprocessing transforms necessary for using the models.

PyTorch is an open-source machine learning framework that accelerates the path from research prototyping to production deployment and is based on the Torch library, used for applications such as computer vision and natural language processing. It was primarily developed by Facebook's AI Research lab (now Meta) and is free and open-source software released under the Modified BSD license. Machine Learning specialsts tend to prefer PyTorch from Meta to TensorFlow from Google. For example, Tesla's Autopilot and Uber's Pyro were developed using PyTorch.

TorchVision currently provides pre-trained models which could be a starting point for transfer learning or used as-is in Computer Vision applications. However, it has limitatations such as inability to support multiple pre-trained weights, missing inference/preprocessing transforms and lack of meta-data. The new API addresses the above limitations and reduces the amount of boilerplate code needed for standard tasks.

New features in the new API are shown below:

Multi-weight support At the heart of the new API, we have the ability to define multiple different weights for the same model variant. Each model building method (eg resnet50) has an associated Enum class (eg ResNet50_Weights) which has as many entries as the number of pre-trained weights available. Additionally, each Enum class has a DEFAULT alias which points to the best available weights for the specific model. This allows the users who want to always use the best available weights to do so without modifying their code.

Associated meta-data & preprocessing transforms The weights of each model are associated with meta-data. The type of information we store depends on the task of the model (Classification, Detection, Segmentation etc). Typical information includes a link to the training recipe, the interpolation mode, information such as the categories and validation metrics. Additionally, each weights entry is associated with the necessary preprocessing transforms. All current preprocessing transforms are JIT-scriptable and can be accessed via the transforms attribute. Prior using them with the data, the transforms need to be initialized/constructed. This lazy initialization scheme is done to ensure the solution is memory efficient. The input of the transforms can be either a PIL.Image or a Tensor read using

Get weights by name The ability to link directly the weights with their properties (meta data, preprocessing callables etc) is the reason why our implementation uses Enums instead of Strings. Nevertheless for cases when only the name of the weights is available it offers a method capable of linking Weight names to their Enums.

more news...