0

我正在尝试为可以在 Google Coral edgetpu 上运行的语义分割实现 UNet。为此,我们需要有一个可以使用 tensorflow_model_optimization API 获得的量化模型。

但是在使用 API 时,有一个 UpSampling2D 层不受Quantization Aware API支持。这是从推荐的正常模型中获取量化模型的代码。

from image_segmentation_keras.keras_segmentation.models.unet import vgg_unet 
import tensorflow_model_optimization as tfmot 
model = vgg_unet(n_classes=4 ,  input_height=832, input_width=1216  ) 
quantize_model = tfmot.quantization.keras.quantize_model #q_aware stands for for quantization aware. 
q_aware_model = quantize_model(model)

...
o = (Conv2D(512, (3, 3), padding='valid' , data_format=IMAGE_ORDERING))(o)
o = (BatchNormalization())(o)
o = Activation('relu')(o)

o = (UpSampling2D((2, 2), data_format=IMAGE_ORDERING))(o)
o = (concatenate([o, f3], axis=MERGE_AXIS))
o = (ZeroPadding2D((1, 1), data_format=IMAGE_ORDERING))(o)
...

Layer up_sampling2d:<class 'tensorflow.python.keras.layers.convolutional.UpSampling2D'> is not supported.You can quantize this layer by passing a `tfmot.quantization.keras.QuantizeConfig` instance to the `quantize_annotate_layer` API.

以下是调查结果——

  • 我尝试使用 up_sampling2d Conv2DTranspose 的替代方法而不是上采样,但看起来 Conv2DTranspose 也不支持。
  • Layer conv2Dtranspose:<class 'tensorflow.python.keras.layers.convolutional.Conv2DTranspose'> is not supported.

  • Edge TPU的大多数官方示例量化模型不需要对图像进行放大。例如 - 分类和检测模型输出是一个类或多个具有相应类的边界框。

  • 虽然有一个用于分割的示例 edgetpu 量化模型——基于 Deeplabv3 的量化 edgetpu 分割,但对于架构和如何解决放大问题没有帮助。

在这方面的任何帮助将不胜感激。

4

0 回答 0