You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter部署ViT类TFLite模型报错:找不到CONV_2D v6算子

问题:Flutter部署视觉Transformer模型时TFLite解释器创建失败

问题背景

在Flutter应用中使用tflite_flutter_plus和tflite_flutter_plus_helper依赖部署EfficientViT_B0、MobileViT_V2_175、RepViT_M11这三款视觉Transformer模型。所有模型均基于TensorFlow 2.10版本训练并量化,但创建解释器时触发错误;同版本TensorFlow训练的DenseNet121模型可正常运行。

核心错误信息

ERROR: Unable to create interpreter: Didn't find op for builtin opcode 'CONV_2D' version '6'. An older version of this builtin might be supported. Are you using an old TFLite binary with a newer model?

捕获错误的代码实现

Future<void> _loadModel() async {
  try {
    _interpreter = await Interpreter.fromAsset(_modelFile, options: InterpreterOptions());
    print('Interpreter Created Successfully...');

    _inputShape = _interpreter.getInputTensor(0).shape;
    _outputShape = _interpreter.getOutputTensor(0).shape;
    _inputType = _interpreter.getInputTensor(0).type;
    _outputType = _interpreter.getOutputTensor(0).type;
    _outputBuffer = TensorBuffer.createFixedSize(_outputShape, _outputType);
    // _probabilityProcessor =TensorProcessorBuilder().add(NormalizeOp(0, 1)).build();
    _probabilityProcessor = TensorProcessorBuilder().build();
  } catch (e) {
    print('ERROR: Unable to create interpreter: ${e.toString()}');
  }
}

项目pubspec.yaml配置

description: "A new Flutter project."
publish_to: 'none' 

version: 1.0.0+1

environment:
  sdk: '>=3.3.4 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  dynamic_color: ^1.7.0
  flutter_launcher_icons: ^0.11.0
  path_provider: ^2.0.15
  path: ^1.9.0
  http: ^1.2.1
  flutter_rating_bar: ^4.0.1
  transparent_image: ^2.0.1
  provider: ^6.1.2
  shared_preferences: ^2.2.3
  persistent_bottom_nav_bar: ^6.2.1
  percent_indicator: ^4.2.3
  google_fonts: ^6.2.1
  image: ^3.3.0
  image_picker: ^1.1.2
  tflite_flutter_plus: ^0.0.1
  tflite_flutter_helper_plus: ^0.0.2
  camera: ^0.10.6

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^4.0.0

flutter:
  uses-material-design: true

  assets:
    - assets/
    - assets/images/
    - assets/classes/

已尝试的操作及结果

  • 运行依赖对应的install.bat文件:仅上述ViT模型报错,DenseNet121模型正常运行。
  • 修改install.bat中的TF_VERSION参数:所有模型均触发动态库加载错误,错误信息如下:

Invalid argument(s): Failed to load dynamic library 'libtensorflowlite_c.so': dlopen failed: "/data/app/~~L-_uTAUsnBW2lkc8a5p0KQ==/com.example.project-dpeoZ1PR50UeKS0PoXAgog==/base.apk!/lib/arm64-v8a/libtensorflowlite_c.so" has bad ELF magic: 4e6f7420

  • 使用TensorFlow 2.5.0重新生成ViT模型:问题依旧存在。

内容的提问来源于stack exchange,提问作者D.Varam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 18:53:19