Back to paper library
arXiv 2018ECCV 2018SegmentationPaper notes

BiSeNet

I Want It All

Original paper

BiSeNet: Bilateral Segmentation Network for Real-time Semantic Segmentation

Paper authors

Changqian Yu · Jingbo Wang · Chao Peng · Changxin Gao · Gang Yu · Nong Sang

Publication
ECCV 2018Conference
First submitted to arXiv
arXiv:1808.00897
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{segmentationbisenet2018,
  title = {{BiSeNet: Bilateral Segmentation Network for Real-time Semantic Segmentation}},
  author = {Changqian Yu and Jingbo Wang and Chao Peng and Changxin Gao and Gang Yu and Nong Sang},
  year = {2018},
  eprint = {1808.00897},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1808.00897}
}
On this page

The segmentation models in the last few notes were all competing on accuracy. PSPNet reached 78.4% mIoU on Cityscapes, at the cost of running a dilated ResNet-101 at 1/81/8 resolution all the way through; the paper didn't report speed. The same team later built ICNet specifically to deal with PSPNet being too slow for real time.

Self-driving cars, AR glasses and surveillance cameras need real time. A 2048×10242048\times1024 street scene has to be segmented within a few tens of milliseconds.

Changqian Yu and colleagues from Huazhong University of Science and Technology, Peking University and Megvii proposed BiSeNet to get two things at once. It wants detail and a large receptive field, and it has no intention of sacrificing either one for the other.

Defining the Problem

There were roughly three ways to speed up segmentation at the time. The authors put them in one figure together with the U-shaped structure.

Original Fig. 1: (a) On the left, the input is shrunk (Resize Input) before going into the network, whose layers downsample by 4, 8, 16 and 32 in turn; on the right, the network's channels are pruned (Network Pruning) and the last stage is dropped (Drop Stage). (b) A U-shaped structure, with both encoder and decoder channel-pruned and arrows linking the matching levels. (c) BiSeNet, where the green Spatial Path on the left has only three layers and the yellow Context Path on the right downsamples quickly; the outputs of the two paths meet in the middle.
Original Fig. 1, Yu et al., from PDF page 2, arXiv license, scholarly quotation.

Look at the two columns of (a). The first approach is shrinking the input; methods like ICNet shrink the image before segmenting it, which is simple and effective, but small objects and boundary detail are gone from the start. The second is pruning channels, especially in the early part of the network; speed goes up, and the capacity for spatial information goes down with it. The third is ENet's approach, dropping the last stage outright, which makes the network very lean, but the receptive field is no longer large enough and large objects go unrecognized.

All three trade accuracy for speed.

The common remedy is the U-shaped structure in (b), which, like U-Net, connects shallow encoder features back into the decoder and raises the resolution step by step. The authors see two problems with it. A full U-shaped structure has to do a lot of extra computation on high-resolution feature maps, so it slows down again; more fundamentally, the spatial information thrown away by shrinking the input or pruning channels can't be recovered from the shallow layers either. In the authors' words, the U-shape only eases the problem; it doesn't solve it.

So the problem becomes two needs pulling against each other. Keeping spatial detail needs features with a small stride and high resolution; seeing the whole scene needs a large receptive field, usually obtained through many downsamplings. For one network to do both, it has to be deep and wide, and then it can't run fast.

Solving the Problem

The authors' answer is (c), with two paths that each take care of one thing.

Original Fig. 2: (a) BiSeNet architecture. The input street scene splits into two paths; on the left, the Spatial Path is three conv+bn+relu layers; on the right, the Context Path downsamples by 4, 8, 16 and 32 in turn, with an ARM at each of the 16× and 32× points and a global pooling at the very bottom. The two paths meet at the FFM, and an 8× upsampling (red line, done only at test time) gives the segmentation result. (b) ARM: global pooling, 1×1 convolution, BatchNorm and sigmoid, then multiplied with the input. (c) FFM: the two paths' features are concatenated and go through conv+bn+relu, then global pooling, 1×1 convolution, ReLU, 1×1 convolution and sigmoid compute weights, which are multiplied in and then added to the original features.
Original Fig. 2, Yu et al., from PDF page 5, arXiv license, scholarly quotation.

This figure has three parts to read, the Spatial Path on the left, the Context Path on the right, and the FFM that joins them. We'll take the input the paper uses for its speed measurements, a Cityscapes image shrunk to 1536×7681536\times768, and walk it down each path.

Spatial Path: Shallow and Wide

The Spatial Path has only three layers. Each is a stride-2 convolution followed by BatchNorm and ReLU.

After three stride-2 layers, the 1536×7681536\times768 input becomes 192×96192\times96, or 1/81/8 of the original. This feature map is large, with each cell covering only an 8×88\times8 region of the original image, so the detail is all still there. With only three layers, it's cheap to compute as well.

Its receptive field is tiny, since three convolution layers can't see far. That isn't its job.

Context Path: Deep and Narrow

The Context Path uses a lightweight Xception, which the authors call Xception39. Its task is to downsample fast, shrinking the image to 1/41/4, 1/81/8, 1/161/16 and 1/321/32. At 1/321/32 the feature map is only 48×2448\times24, each cell covers a 32×3232\times32 region of the original image, and the receptive field is already large.

Not satisfied with that, the authors add a global average pooling at the end of Xception39. The whole 48×2448\times24 feature map is averaged into one vector, which has the largest receptive field possible, covering the entire image. This vector is enlarged back to 48×2448\times24 and added to the last stage's output.

Next comes an "incomplete U-shape." Only the features of the last two stages (1/321/32 and 1/161/16) are progressively upsampled and added, outputting at 1/81/8 to match the Spatial Path's 192×96192\times96. The authors call this U-shape-8s; a standard U-shaped structure goes all the way to 1/41/4 and is called U-shape-4s.

ARM: Picking Channels with Global Information

An Attention Refinement Module (ARM) is attached to the output of each of the 1/161/16 and 1/321/32 stages.

ARM first global-average-pools the feature map into a vector, passes it through a 1×11\times1 convolution and BatchNorm, then a sigmoid, which gives each channel a weight between 0 and 1, and finally multiplies these weights back onto the original features. It's the same idea as SENet's channel attention, using statistics of the whole image to decide which channels to amplify.

The authors stress that ARM injects global context into the features without any upsampling, at a nearly negligible computational cost.

FFM: The Two Kinds of Features Can't Simply Be Added

Both paths now output 1/81/8 feature maps. The Spatial Path's are low-level features that record edges and textures; the Context Path's are high-level features that record "this patch is road, that patch is a car."

The authors argue that the two sit at different levels and can't be added directly, so they designed the Feature Fusion Module (FFM). First the two are concatenated and mixed through conv+BN+ReLU; then the mixed features get SENet-style weighting, where global pooling, 1×11\times1 convolution, ReLU, 1×11\times1 convolution and sigmoid produce channel weights that are multiplied in, and the result is added back to the original features.

A classifier comes last, and at test time the 1/81/8 prediction is enlarged 8× back to the original image.

Computing Both Paths Together

This design helps speed in two ways. The Spatial Path has high resolution but only three layers; the Context Path is deep, but its resolution drops so fast that every layer is small. The two paths are independent of each other and can run in parallel.

During training, the authors add an auxiliary loss to each of the Context Path's two intermediate outputs:

L=lp+α∑i=23liL = l_p + \alpha \sum_{i=2}^{3} l_i

lpl_p is the main loss on the whole network's output and lil_i is the auxiliary loss for the ii-th stage of the Context Path, all of them per-pixel softmax cross-entropy, with α=1\alpha=1. The auxiliary losses are used only during training.

The other settings are SGD, batch 16, momentum 0.9, weight decay 10−410^{-4} and a learning rate starting at 0.025 with poly decay; data augmentation consists of horizontal flipping and random scaling from 0.75 to 2.0×.

Discussion

The ablations are all on the Cityscapes validation set. Cityscapes is a street-scene dataset shot from a car, with 2,975 training, 500 validation and 1,525 test images at 2048×10242048\times1024 and 19 classes; the paper uses only the finely annotated part.

What Each Part Contributes

First, how far the Context Path's U-shape should go (Table 2 of the paper). U-shape-8s and 4s reach 66.01 and 66.13 mIoU, practically identical; on a 1920×10801920\times1080 input they take 12 ms and 17 ms. One more level of U-shape costs 40% more for 0.12 points. The authors chose 8s, which jumps from about 60.8, with just the backbone and direct upsampling, to 66.01.

Then the other parts are added in turn (Table 3 of the paper):

SettingmIoU (%)
Context Path66.01
+ Spatial Path (plain sum)66.82
+ Spatial Path (FFM)67.42
+ global pooling68.42
+ ARM68.72
+ global pooling + ARM71.40

The Spatial Path itself adds 0.8 points, and fusing with FFM instead adds another 0.6, confirming that the two paths' features really don't suit plain addition. Global pooling and ARM each add only about 1 point on their own; added together, they give nearly 4. Both parts inject global information into the Context Path, and together they do more than the sum of their separate gains, which the paper doesn't explain further.

Original Fig. 3: four Cityscapes street scenes; each row shows, in order, the image, the prediction with only the U-shaped structure (Context Path), the BiSeNet prediction with the Spatial Path added, and the ground truth. The utility poles, traffic signals and pedestrian outlines in the BiSeNet column are finer than in the U-shape column.
Original Fig. 3, Yu et al., from PDF page 10, arXiv license, scholarly quotation.

In the numbers the Spatial Path adds less than 1 point, but the figure shows what it fills in. In the second and third rows, the thin poles and signals in the middle of the frame are often broken or smeared into a blob in the U-shape column, and much cleaner in the BiSeNet column. These thin little objects take up very few pixels and barely move mIoU, but they matter a great deal to a self-driving car.

Speed

Table 5 of the paper measures three input sizes on a Titan XP:

Model640×360640\times3601280×7201280\times7201920×10801920\times1080
BiSeNet (Xception39)4 ms8 ms18 ms
BiSeNet (ResNet-18)5 ms13 ms29 ms

On a Titan X at the same 1920×10801920\times1080, ENet takes 46 ms, SegNet 637 ms, and BiSeNet (Xception39) 24 ms.

As for computation (Table 4 of the paper, 640×360640\times360 input), BiSeNet (Xception39) needs 2.9 GFLOPs, less than ENet's 3.8, while its parameters are 5.8M against ENet's 0.4M. ENet has far fewer parameters yet runs slower; parameter count and speed are two different things.

Results in the Real-Time Setting

Table 6 of the paper gives Cityscapes test-set results, with speed and accuracy measured under the same setting:

MethodBackboneTest mIoU (%)FPS
SegNetVGG1656.1–
ENetFrom scratch58.3–
ICNetPSPNet5069.530.3
Two-column NetResNet-5072.914.7
BiSeNetXception3968.4105.8
BiSeNetResNet-1874.765.5

The ResNet-18 version is 5 points above ICNet at more than twice its speed; the Xception39 version is 1 point below ICNet at more than three times its speed.

There's a condition here to read carefully. The abstract says "2048×10242048\times1024 input, 105 FPS," but the main text explains that for measuring speed and accuracy, the authors first shrink the 2048×10242048\times1024 images to 1536×7681536\times768. So BiSeNet actually processes only 56% of the original pixels, which is exactly the "shrinking the input" the authors criticized when defining the problem. The scaling isn't drastic, but before comparing its FPS with other papers, check that everyone measured at the same resolution.

Without the Speed Limit

The authors also trained in a setting that ignores speed (Table 7 of the paper), with 1024×10241024\times1024 random crops. BiSeNet with a ResNet-101 backbone reaches 78.9% on the Cityscapes test set, slightly above PSPNet's 78.4%; the ResNet-18 version gets 77.7%.

On the CamVid test set, the Xception39 and ResNet-18 versions get 65.6% and 68.7%, against 55.6% for SegNet; on the COCO-Stuff validation set, the ResNet-101 version gets 31.3% mIoU.

Conclusion

BiSeNet refuses to choose between keeping detail and enlarging the receptive field, and gives each one its own path. The Spatial Path keeps detail at 1/81/8 resolution with three convolution layers, the Context Path sees the whole image with a lightweight backbone plus global pooling, and the FFM combines the two kinds of features with channel weighting. In the paper's real-time setting, the ResNet-18 version runs at 65.5 images per second with 74.7% on the Cityscapes test set.

This skeleton, with one path for detail and one for semantics, is what BiSeNetV2, DDRNet and PIDNet later kept refining in the same direction. Three years on, Rethinking BiSeNet measured that the Spatial Path itself is quite time-consuming, dropped it altogether, and instead uses Detail Guidance during training to supervise detail in the shallow layers, so inference computes nothing extra.

If you're going to deploy it, measure the speed again at your own resolution and on your own GPU. The paper's 105 FPS was measured on frames shrunk to 1536×7681536\times768.