Caffe Version - 1.1 English

Vitis AI User Guide (UG1414)

Document ID
Release Date
1.1 English
vai_q_caffe takes a floating-point model as an input model and uses a calibration dataset to generate a quantized model. Use the following steps to create and quantize Resnet50 floating-point model.
  1. Prepare a floating-point model for Resnet-50. You can download one from Internet or from Xilinx modelzoo (
  2. Prepare the calibration dataset used by vai_q_caffe. You can download 100 to 1000 images of ImageNet dataset from or and then change the source and root_folder of image_data_param in ResNet-50 prototxt accordingly. For example, the ImageData layer in prototxt looks like this:
    layer {
      name: "data"
      type: "ImageData"
      top: "data"
      top: "label"
      include {
        phase: TRAIN
      transform_param {
        mirror: false
        crop_size: 224
        mean_value: 104
        mean_value: 107
        mean_value: 123
      image_data_param {
        source: "/path/calibration.txt"
        root_folder: "/path/calibration_images/"
        batch_size: 20
        shuffle: false
    For quantize calibration, calibration data without label is enough. But due to the implementation, a image list file with two columns is required. Just set the second column to a random value or zero. This is an example of "calibration.txt".
    n01440764_985.JPEG 0
    n01443537_9347.JPEG 0
    n01484850_8799.JPEG 0
  3. Activate the caffe running environment:
    conda activate vitis-ai-caffe
  4. Start quantization:
    vai_q_caffe quantize -model float.prototxt -weights float.caffemodel
    If your targeting hardware platform is DPUv3, another option "-keep_fixed_neuron" should be added to the command. Refer to Chapter 4 for details.
    vai_q_caffe quantize -model float.prototxt -weights float.caffemodel -keep_fixed_neuron

This invokes the vai_q_caffe tool to perform quantization with the appropriate parameters. The running time of this command varies from a few seconds to several minutes, depending on hardware and the size of the neural network. Four files are generated in the output directory, including deploy.prototxt and deploy.caffemodel, which could be fed to VAI compiler for the following compilation process.