cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dvukadin
Contributor
Contributor
216 Views
Registered: ‎07-19-2018

Low accuracy with custom FCN model after compiling in tensorflow2 Vitis AI 1.3

Hi,

I have quantized and finetuned my custom FCN model in TF 2 and accuracy was very good after finetuning.

But, when I compile with vai_c_tensorflow2 and run on ZCU104 common image from Xilinx (petalinux 2020.2), accuracy is very low.

Here is model summary:

 

Model: "functional_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         [(None, 128, 128, 3)]     0         
_________________________________________________________________
block1_conv1 (Conv2D)        (None, 128, 128, 64)      1792      
_________________________________________________________________
block1_conv2 (Conv2D)        (None, 128, 128, 64)      36928     
_________________________________________________________________
block1_pool (MaxPooling2D)   (None, 64, 64, 64)        0         
_________________________________________________________________
block2_conv1 (Conv2D)        (None, 64, 64, 128)       73856     
_________________________________________________________________
block2_conv2 (Conv2D)        (None, 64, 64, 128)       147584    
_________________________________________________________________
block2_pool (MaxPooling2D)   (None, 32, 32, 128)       0         
_________________________________________________________________
bottleneck_1 (Conv2D)        (None, 32, 32, 160)       20971680  
_________________________________________________________________
bottleneck_2 (Conv2D)        (None, 32, 32, 160)       25760     
_________________________________________________________________
upsample_2 (Conv2DTranspose) (None, 128, 128, 20)      51200     
_________________________________________________________________
reshape (Reshape)            (None, 327680, 1)         0

Here is output message after compiling:

image_2021_04_21T07_14_04_090Z.png

 

 I use vitis::ai::DpuTask for running model.

model = vitis::ai::DpuTask::create(kernelPath);
model->setMeanScaleBGR(meanValues, scaleValues);
model->setImageBGR(preprocessedImage);
m_model->run(0);
outputTensor = m_model->getOutputTensor(0);

For converting fixpoint to float, I use this function:

std::vector<float> convert_fixpoint_to_float(const vitis::ai::library::OutputTensor &tensor) {
auto scale = vitis::ai::library::tensor_scale(tensor);
auto data = (signed char *)tensor.get_data(0);
auto size = tensor.width * tensor.height * tensor.channel;
auto ret = std::vector<float>(size);
transform(data, data + size, ret.begin(),
[scale](signed char v) { return ((float)v) * scale; });
return ret;
}

 

What could be wrong, why accuracy is very good before compiling and very low on ZCU104?

0 Kudos
1 Reply
yz87@rice.edu
Visitor
Visitor
106 Views
Registered: ‎12-05-2019

I had the similar issue of drastically dropped accuracy after compiling in tensorflow2.....

0 Kudos