HRDA learns semantic segmentation from unlabeled images

HRDA (Context-Aware High-Resolution Domain-Adaptive Semantic Segmentation) is a training method that adapts a semantic segmentation model from labeled images of one domain to unlabeled images of another. In Supervisely you train it on labeled images, synthetic or a small real set, together with unlabeled real images, and serve the result.

Poster of the Train HRDA app: a car from the source domain adapted to a car in the target domain
Labels
  • Polygons
  • Bitmaps, plus unlabeled images
Apps
Train, Serve
Source
Paper, GitHub

Apps in the Supervisely Ecosystem

Every model in Supervisely comes as a Supervisely App: a module from the Ecosystem that plugs into the platform and runs on your own GPU, with no code to install. A Serve App puts the model behind the labeling tools, and where the model can be trained, a Train App fits it to your labeled project. All Apps work on the same projects, so you add a model, update it or swap it for another without changing anything else.

Fine detail and wide context at once

HRDA comes from "HRDA: Context-Aware High-Resolution Domain-Adaptive Semantic Segmentation" by Lukas Hoyer, Dengxin Dai and Luc Van Gool, ECCV 2022 (code). It addresses unsupervised domain adaptation: a model learns from labeled images of a source domain, often synthetic data, and has to work on a target domain, such as real photos, for which there are no labels.

Domain adaptation for segmentation is memory-hungry, so earlier methods trained on downscaled images and lost fine detail; random crops at full resolution keep detail but miss the wider context. HRDA combines both: small high-resolution crops for detail and large low-resolution crops for context, merged by a learned scale attention, at a manageable GPU memory cost. The paper reports 73.8 mIoU from GTA to Cityscapes and 65.8 from Synthia to Cityscapes, 5.5 and 4.9 points above the previous state of the art.

Two cases where it helps

The Supervisely apps use HRDA for models that must generalize to data unlike their labeled images. Their READMEs name two cases:

  • Training on synthetic data: images generated by simulation or rendering always differ from real ones, and HRDA narrows the gap.
  • Semi-supervised learning: a small labeled set explains the task, and HRDA learns from a larger pool of unlabeled images as well.

In both, the model labels the unlabeled images itself with pseudo-labels and learns from them alongside your labels. The network is the DAFormer architecture on a MiT-b5 encoder; the training app lists its pretrained model as SegFormer MiT-b5, with 82 million parameters.

Two posts on the blog walk through both cases with real numbers: semi-supervised training on 62 labeled images and crack segmentation trained on synthetic data.

Preparing the data and training

Train HRDA needs a project with three datasets: a labeled source dataset (synthetic images or a small part of your real ones), an unlabeled target dataset of real images, and a labeled dataset for validation. Labels are polygons or bitmap masks, drawn into one class mask per image. The Split Dataset app can divide an existing project. Then run Train HRDA from the Ecosystem or the project's context menu:

  1. Select the pretrained SegFormer MiT-b5 model or your own weights.
  2. Choose the classes to train on.
  3. Set the source, target and validation datasets.
  4. Pick an augmentation template (light, medium or hard, each also with image corruptions) or your own.
  5. Set the hyperparameters: 25,000 iterations, validation every 1,000, a 640 × 640 input and a batch of 2 by default.
  6. Press Train and follow the logs, the charts and the predictions, which refresh after each validation.

Validation measures mean IoU, and the checkpoints and the config are saved to Team Files.

Serving the trained model

Serve HRDA has no pretrained models: copy the path of your trained checkpoint from Team Files, paste it into the app, select the device and press Serve. A GPU is preferred. The served model returns a bitmap per class and works with NN Image Labeling in the image labeling toolbox and with Apply NN to Videos Project. To run it outside Supervisely, download the config and the .pth weights from Team Files and follow the inference notebook in the app repository; it needs no Supervisely SDK.

When HRDA is worth it

Your dataTrain with
Many labeled images from the domain you will deploy inMMSegmentation, UNet or MaskDINO
Labels only on synthetic images; real images unlabeledHRDA
A few labeled real images and many unlabeled onesHRDA
Street scenes and no wish to trainSTDC-Seg with its Cityscapes checkpoints

To see what the unlabeled images add, train an ordinary model on the same labeled set and compare both on the same validation dataset. When the real images can be labeled after all, model-assisted labeling with the HRDA model is a quick way to get there.

Frequently asked questions.

What is HRDA used for?

HRDA trains a semantic segmentation model that has to work on images unlike its labeled ones: labels on synthetic images and a model for real photos, or a few labeled images and many unlabeled ones. It learns from the unlabeled images with pseudo-labels.

What data does Train HRDA need?

One project with three datasets: labeled source images, unlabeled target images and a labeled validation set. Labels are polygons or bitmap masks.

Is there a pretrained HRDA model I can serve right away?

No. Serve HRDA deploys only models trained with Train HRDA, from their Team Files path. The training app starts from a SegFormer MiT-b5 encoder.

What is domain adaptation in computer vision?

Training a model on labeled images of one domain, such as synthetic renders, so that it works on another domain, such as real photos, where labels are scarce or missing. HRDA does this for semantic segmentation by learning from the unlabeled images of the target domain with pseudo-labels.

Train and serve models on your own data.

Label a project in a free account, train a model on it from the browser and deploy it on your own GPU. Or book a demo to run Supervisely on your servers.