XFPN - 1.4.1 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2021-10-29
Version
1.4.1 English

Baseline Model

XFPN is a network for segmentation task. It is mainly composed of GoogleNet_v1 and FPN. The last few layers of the network are defined as follows:

layer {
	bottom: "add_p2"
	top: "pred"
	name: "toplayer_p2"
	type: "Deconvolution"
	convolution_param {
		num_output: 19
		kernel_size: 4
		pad: 1
		stride: 2
		weight_filler {
			type: "gaussian"
			std: 0.01
		}
		bias_filler {
			type: "constant"
			value: 0
		}
	}
}

layer {
	name: "loss"
	type: "SoftmaxWithLoss"
	bottom: "pred"
	bottom: "label"
	top: "loss"
	loss_weight: 1
	include {
	phase: TRAIN
	}
	loss_param {
	ignore_label: 255
	}
}
layer {
	name: "result"
	type: "Softmax"
	bottom: "pred"
	top: "result"
	include {
		phase: TEST

	}
}
layer {
	name: "segmentation_eval_classIOU"
	type: "SegmentPixelIOU"
	bottom: "result"
	bottom: "label"
	top: "segmentation_eval"
	include {
		phase: TEST
	}
}

Create a Configuration File

Create a file named config.prototxt:

workspace: "./workspace/segmentation/pruning"

gpu: "0,1,2,3"
#test_iter = validation_data_number/val_batch_size e.g. 500/4
test_iter: 125
acc_name: "segmentation_eval_classIOU"
eval_type: "segmentation"

# dataset classes number #e.g. cityscapes: 19
classiou_class_num: 19

model: "./workspace/segmentation/trainval.prototxt"
weights: "./workspace/segmentation/snapshots/_iter_200000.caffemodel"
solver: "./workspace/segmentation/solver.prototxt"

rate: 0.1

pruner {
	method: REGULAR

	exclude {
	layer_top: "pred"
	}
}

Perform Model Analysis

$ ./vai_p_caffe ana –config config.prototxt

Prune the Model

$ ./vai_p_caffe prune –config config.prototxt

Finetune the Pruned Model

The following solver settings can be used as initial parameters for fine-tuning:

net: "./workspace/segmentation/trainval.prototxt"
test_iter: 125
test_interval: 5000
test_initialization: true
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.01
momentum: 0.9
weight_decay: 0.0005
# The learning rate policy
lr_policy: "multistep"
gamma: 0.1
stepvalue: 75000
stepvalue: 85000
display: 10
max_iter: 200000
snapshot: 5000
snapshot_prefix: "./workspace/segmentation/snapshots/"
solver_mode: GPU
iter_size: 1
average_loss: 20
eval_type: "segmentation"
classiou_class_num: 19

Use the following command to start finetuning:

$ ./vai_p_caffe finetune -config config.prototxt

Estimated time required: about 40 hours for 270 epochs using Cityscapes training set (2975 images, 4 x NVIDIA Tesla V100).

Get the Final Output

To get the finalized model, run:

$ ./vai_p_caffe transform –model baseline.prototxt –weights finetuned_model.caffemodel -output
final.caffemodel

Pruning Results

Dataset
Cityscapes
Input Size
2048 x 1024
GPU Platform
4 x NVIDIA Tesla V100
FLOPs
136G
Table 1. Pruning Results of XFPN
Round FLOPs mIOU
0 100% 71.25
1 90% 70.88
2 83% 69.94