Tensorflow 如何使用EfficientNet Lite模型作为关键点回归的主干?

Tensorflow 如何使用EfficientNet Lite模型作为关键点回归的主干?,tensorflow,tensorflow-lite,Tensorflow,Tensorflow Lite,我想使用EfficientNet Lite 0模型作为主干来执行关键点回归任务。但是,我在从Tensorflow Hub或官方GitHub存储库加载模型时遇到了困难。你能解释一下我该如何: 从ImageNet导入带有检查点的Tensorflow中的此类模型 修改网络的最后一层 根据我的任务修改损失 网络再培训 我期待着使用高效Lite,因为我想将所有内容都转换为TF Lite。TensorFlow Lite目前不支持高效Net Lite,但它们支持对移动(CPU和GPU)友好的CenterN

我想使用EfficientNet Lite 0模型作为主干来执行关键点回归任务。但是,我在从Tensorflow Hub或官方GitHub存储库加载模型时遇到了困难。你能解释一下我该如何:

  • 从ImageNet导入带有检查点的Tensorflow中的此类模型
  • 修改网络的最后一层
  • 根据我的任务修改损失
  • 网络再培训

我期待着使用高效Lite,因为我想将所有内容都转换为TF Lite。

TensorFlow Lite目前不支持高效Net Lite,但它们支持对移动(CPU和GPU)友好的CenterNet。请参见演示如何使用此模型的部分

用于转换关键点模型的命令:

# Get mobile-friendly CenterNet for Keypoint detection task.
# See TensorFlow 2 Detection Model Zoo for more details:
# https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md

wget http://download.tensorflow.org/models/object_detection/tf2/20210210/centernet_mobilenetv2fpn_512x512_coco17_kpts.tar.gz
tar -xf centernet_mobilenetv2fpn_512x512_coco17_kpts.tar.gz
rm centernet_mobilenetv2fpn_512x512_coco17_kpts.tar.gz*

# Export the intermediate SavedModel that outputs 10 detections & takes in an 
# image of dim 320x320.
# Modify these parameters according to your needs.

python models/research/object_detection/export_tflite_graph_tf2.py \
  --pipeline_config_path=centernet_mobilenetv2_fpn_kpts/pipeline.config \
  --trained_checkpoint_dir=centernet_mobilenetv2_fpn_kpts/checkpoint \
  --output_directory=centernet_mobilenetv2_fpn_kpts/tflite \
  --centernet_include_keypoints=true \
  --keypoint_label_map_path=centernet_mobilenetv2_fpn_kpts/label_map.txt \
  --max_detections=10 \
  --config_override=" \
    model{ \
      center_net { \
        image_resizer { \
          fixed_shape_resizer { \
            height: 320 \
            width: 320 \
          } \
        } \
      } \
    }"

tflite_convert --output_file=centernet_mobilenetv2_fpn_kpts/model.tflite \
  --saved_model_dir=centernet_mobilenetv2_fpn_kpts/tflite/saved_model

非常感谢你的建议。我查看了CenterNet网络的pipeline.config,发现需要提供关键点排列,以防图像翻转。因此,我的问题是,如果我的物体以多种不同的姿势呈现,网络是否也能识别关键点,或者图像都应该或多或少地从相同的姿势拍摄?我的意思是,如果我的物体在一个图像和另一个图像之间旋转90°,这是网络的问题吗?它应该可以工作。您可以将colab代码用于自定义图像,并查看它是否有效。