✨LFD✨

July 23, 2025 · View on GitHub

This is the official PyTorch implementation of LFD, it achieves the best downstream segmentation results in SeaS.

[IEEE TITS] Exploiting Low-level Representations for Ultra-Fast Road Segmentation

Authors: Huan Zhou1* | Feng Xue3* | Yucong Li1* | Shi Gong1 | Yiqun Li1 | Yu Zhou1,2

Institutions: 1Huazhong University of Science and Technology | 2Wuhan jingCe Electronic Group Co.LTD | 3University of Trento

🧐 Arxiv

📣Updates:

07/24/2025

The complete code of downstream segmentation method LFD in paper for SeaS is released.

Catalogue

Abstract: [Back to Catalogue]

LFD was initially developed for road segmentation tasks, leveraging low-level features from the first stage of ResNet-18. We observed that using low-level features is advantageous for anomaly segmentation tasks, so we extended its application to supervised anomaly segmentation. Specifically, LFD adopts a bilateral structure. The spatial detail branch is first designed to extract low-level features using the first stage of ResNet-18. The context semantic branch is then designed to extract contextual features efficiently. In this branch, we asymmetrically downsample the input image and introduce an aggregation module, achieving a receptive field comparable to the third stage of ResNet-18 but with reduced computation time. Finally, a selective fusion module is proposed to compute pixel-wise attention between the low-level representation and contextual features. In anomaly segmentation, LFD is trained using image–mask pairs generated by SeaS. With a model size of only 0.936M—significantly smaller than BiSeNetV2 (3.341M) and UperNet (64.042M)—LFD achieves a pixel AP score that is 5.34% higher and an F1 score that is 3.99% higher than both. The original source code is available at https://github.com/zhouhuan-hust/LFD-RoadSeg.

pipeline

Setup: [Back to Catalogue]

Environment:

  • Python 3.9
  • Pytorch 1.10.1
  • CUDA 11.3

Clone the repository:

git clone https://github.com/HUST-SLOW/LFD.git

Create virtual environment:

conda create --name LFD python=3.9
conda activate LFD

Install the required packages:

# install pytorch
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113

# install other packages
pip install -r requirements.txt

Datasets: [Back to Catalogue]

All the datasets are placed under the ./data folder.

For training, we utilized a dataset composed of the following elements:

  • Images generated by SeaS.
  • 1/3 of the anomaly images from the original dataset (these images were previously used as training data in SeaS).
  • All good images from the train folder of the original dataset.

SeaS generated images are load from ./data/generated_dataset and the other images are load from ./data/original_dataset.

For testing, the dataset consists of:

  • The remaining 2/3 of the anomaly images from the original dataset.
  • All good images from the test folder of the original dataset.

The images are load from ./data/original_dataset.

Original Dataset

MVTec AD

data
|-- mvtec
|-----|-- bottle
|-----|-----|-- train
|-----|-----|-----|-- good
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-- test
|-----|-----|-----|-- broken_large
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- broken_small
|-----|-----|-----|-- ...
|-----|-----|-- ground_truth
|-----|-----|-----|-- broken_large
|-----|-----|-----|-----|-- 000_mask.png
|-----|-----|-----|-----|-- 001_mask.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- broken_small
|-----|-----|-----|-- ...
|-----|-- cable
|-----|-- ...

VisA

For VisA we divided the dataset according to defect categories, while dividing the good data in the original dataset into train and good. For downloading the split dataset, please refer to here.

data
|-- VisA
|-----|-- candle
|-----|-----|-- train
|-----|-----|-----|-- good
|-----|-----|-- test
|-----|-----|-----|-- chunk_of_waax_missing
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- combined
|-----|-----|-----|-- ...
|-----|-----|-- ground_truth
|-----|-----|-----|-- chunk_of_waax_missing
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- combined
|-----|-----|-----|-- ...
|-----|-- capsules
|-----|-- ...

MVTec 3D AD

data
|-- mvtec_3d
|-----|-- bagel
|-----|-----|-- test
|-----|-----|-----|-- combined
|-----|-----|-----|-----|-- gt
|-----|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-----|-- ...
|-----|-----|-----|-----|-- rgb
|-----|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-----|-- ...
|-----|-----|-----|-----|-- xyz
|-----|-----|-----|-----|-----|-- 000.tiff
|-----|-----|-----|-----|-----|-- 001.tiff
|-----|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- contamination
|-----|-----|-----|-- ...
|-----|-----|-- train
|-----|-----|-----|-- good
|-----|-----|-----|-----|-- rgb
|-----|-----|-----|-----|-- xyz
|-----|-----|-- validation
|-----|-----|-----|-- good
|-----|-----|-----|-----|-- rgb
|-----|-----|-----|-----|-- xyz
|-----|-- cable_gland
|-----|-- ...

SeaS generated Dataset

All the results are implemented by the default settings in SeaS. For downloading the generated image-mask pairs, please refer to here.

MVTec AD

data
|-- mvtec
|-----|-- bottle
|-----|-----|-- broken_large
|-----|-----|-----|-- image
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- mask
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-- broken_small
|-----|-----|-- ...
|-----|-- cable
|-----|-----|-- bent_wire
|-----|-----|-----|-- image
|-----|-----|-----|-- mask
|-----|-----|-- ...
|-----|-- ...

VisA

data
|-- VisA
|-----|-- candle
|-----|-----|-- chunk_of_waax_missing
|-----|-----|-----|-- image
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- mask
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-- combined
|-----|-----|-- ...
|-----|-- capsules
|-----|-- ...

MVtec 3D AD

data
|-- mvtec_3d_AD
|-----|-- bagel
|-----|-----|-- combined
|-----|-----|-----|-- image
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-----|-- mask
|-----|-----|-----|-----|-- 000.png
|-----|-----|-----|-----|-- 001.png
|-----|-----|-----|-----|-- ...
|-----|-----|-- contamination
|-----|-----|-- ...
|-----|-- cable_gland
|-----|-----|-- bent
|-----|-----|-----|-- image
|-----|-----|-----|-- mask
|-----|-----|-- ...
|-----|-- ...

Run LFD: [Back to Catalogue]

Train

set training: state: True in configs/LFD.yaml and run the code below:

python examples/LFD_main.py 

Test

set testing: state: True in configs/LFD.yaml and run the code below:

python examples/LFD_main.py 

Eval Speed

set eval_speed: state: True in configs/LFD.yaml and run the code below:

python examples/LFD_main.py

All checkpoints and metrics will be stored in the ./outputs/<RUN_EXP>.

Results: [Back to Catalogue]

We report the quantitative results on the MVTec AD, VisA and MVTec 3D AD datasets. All the results are implemented by the default settings in SeaS. We run all experiments on single A100.

MVTec AD

Segmentation ModelsGenerative ModelsImage-levelPixel-level
AUROCAPF1-maxAUROCAPF1-maxIoU
DFMGAN90.9094.4390.3394.5760.4260.5445.83
BiSeNet V2AnomalyDiffusion90.0894.8491.8496.2764.5062.2742.89
SeaS96.0098.1495.4397.2169.2166.3755.28
DFMGAN90.7494.4390.3792.3357.0156.9146.64
UperNetAnomalyDiffusion96.6298.6196.2196.8769.9266.9550.80
SeaS98.2999.2097.3497.8774.4270.7061.24
DFMGAN91.0895.4090.5894.9167.0665.0945.49
LFDAnomalyDiffusion95.1597.7894.6696.3069.7766.9945.77
SeaS95.8897.8995.1598.0977.1572.5256.47
DFMGAN90.9194.7590.4393.9461.5060.8545.99
AverageAnomalyDiffusion93.9597.0894.2496.4868.0665.4046.49
SeaS96.7298.4195.9797.7273.5969.8657.66

VisA

Segmentation ModelsGenerative ModelsImage-levelPixel-level
AUROCAPF1-maxAUROCAPF1-maxIoU
DFMGAN63.0762.6366.4875.919.1715.009.66
BiSeNet V2AnomalyDiffusion76.1177.7473.1389.2934.1637.9315.93
SeaS85.6186.6480.4996.0342.8045.4125.93
DFMGAN71.6971.6470.7075.0912.4218.5215.47
UperNetAnomalyDiffusion83.1884.0878.8895.0039.9245.3720.53
SeaS90.3490.7384.3397.0155.4655.9935.91
DFMGAN65.3862.2566.5981.2115.1418.706.44
LFDAnomalyDiffusion81.9782.3677.3588.0030.8638.5616.61
SeaS83.0782.8877.2492.9143.8746.4626.37
DFMGAN66.7165.5167.9277.4012.2417.4110.52
AverageAnomalyDiffusion80.4281.3976.4590.7634.9840.6217.69
SeaS86.3486.7580.6995.3247.3849.2929.40

MVTec 3D AD

Segmentation ModelsGenerative ModelsImage-levelPixel-level
AUROCAPF1-maxAUROCAPF1-maxIoU
DFMGAN61.8881.8084.4475.8915.0221.7315.68
BiSeNet V2AnomalyDiffusion61.4981.3585.3692.3915.1520.0914.70
SeaS73.6087.7585.8290.4126.0432.6128.55
DFMGAN67.5684.5384.9975.1219.5426.0418.78
UperNetAnomalyDiffusion76.5690.4287.3588.4828.9535.8125.04
SeaS82.5792.5988.7291.9338.5143.5338.56
DFMGAN62.2382.1785.3872.159.5414.2914.81
LFDAnomalyDiffusion77.0689.4487.2092.6824.2932.7419.90
SeaS78.9691.2287.2891.6140.2543.4739.00
DFMGAN63.8983.8384.9474.3914.7020.6916.42
AverageAnomalyDiffusion71.7087.0786.6491.1822.8029.5519.88
SeaS78.3890.5287.2791.3234.9339.8735.37

Citation: [Back to Catalogue]

If you find this repo useful for your research, please consider citing our paper:

@ARTICLE{zhou2024lfdroadseg,
  author={Zhou, Huan and Xue, Feng and Li, Yucong and Gong, Shi and Li, Yiqun and Zhou, Yu},
  journal={IEEE Transactions on Intelligent Transportation Systems (TITS)}, 
  title={Exploiting Low-level Representations for Ultra-Fast Road Segmentation}, 
  year={2024},
  }

Acknowledgements: [Back to Catalogue]

The codebase is built on repos: https://github.com/zhouhuan-hust/LFD_RoadSeg.git

License: [Back to Catalogue]

LFD is released under the MIT License, and is fully open for academic research and also allow free commercial usage. To apply for a commercial license, please contact yuzhou@hust.edu.cn.