tensorflow lite 程序在 buildozer 上与 kivy 崩溃

Posted

技术标签:

【中文标题】tensorflow lite 程序在 buildozer 上与 kivy 崩溃【英文标题】:tensorflow lite program crashing with kivy on buildozer 【发布时间】:2022-01-10 22:35:31 【问题描述】:

我尝试运行这个 github 程序 https://github.com/tito/experiment-tensorflow-lite 它基本上是关于在 android 上使用 kivy 运行 tensorflow lite。

我尝试在我的电脑上运行该程序,但出现此错误``

STDOUT:
patching file jnius/jnius_jvm_android.pxi
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file jnius/jnius_jvm_android.pxi.rej
patching file jnius/env.py
Hunk #1 FAILED at 185.
1 out of 1 hunk FAILED -- saving rejects to file jnius/env.py.rej


  STDERR:

[INFO]:    STDOUT:
    patching file jnius/jnius_jvm_android.pxi
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file jnius/jnius_jvm_android.pxi.rej
patching file jnius/env.py
Hunk #1 FAILED at 185.
1 out of 1 hunk FAILED -- saving rejects to file jnius/env.py.rej
[INFO]:    STDERR:
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1276, in <module>
    main()
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 725, in init
    getattr(self, command)(args)
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 153, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 212, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx,
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 573, in build_recipes
    recipe.apply_patches(arch)
File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 560, in apply_patches
    self.apply_patch(
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 263, in apply_patch
    shprint(sh.patch, "-t", "-d", build_dir, "-p1",
  File "/home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
    for line in output:
  File "/usr/local/lib/python3.8/dist-packages/sh-1.14.1-py3.8.egg/sh.py", line 911, in next
    self.wait()
  File "/usr/local/lib/python3.8/dist-packages/sh-1.14.1-py3.8.egg/sh.py", line 841, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python3.8/dist-packages/sh-1.14.1-py3.8.egg/sh.py", line 865, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /usr/bin/patch -t -d /home/pls/experiment-tensorflow-lite/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyjnius-sdl2/armeabi-v7a__ndk_target_21/pyjnius -p1 -i /home/pls/experiment-tensorflow-lite/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/pyjnius/sdl2_jnienv_getter.patch

  STDOUT:
patching file jnius/jnius_jvm_android.pxi
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file jnius/jnius_jvm_android.pxi.rej
patching file jnius/env.py
Hunk #1 FAILED at 185.
1 out of 1 hunk FAILED -- saving rejects to file jnius/env.py.rej

我在 github 上使用了相同的 buildozer.init 文件 Python版本:3.8.10 我使用虚拟盒子在 ubuntu 虚拟机上运行程序

【问题讨论】:

【参考方案1】:

只需使用命令:

buildozer android clean

之前:

buildozer android debug

【讨论】:

以上是关于tensorflow lite 程序在 buildozer 上与 kivy 崩溃的主要内容,如果未能解决你的问题,请参考以下文章

Tensorflow-lite - 从量化模型输出中获取位图

如何在 Python 中导入 tensorflow lite 解释器?

小白学习tensorflow教程四使用 tfhub中的模型EfficientDet-Lite2 进行对象检测

小白学习tensorflow教程四使用 tfhub中的模型EfficientDet-Lite2 进行对象检测

tensorflow lite添加自定义操作

Bintray 502 的 Android 存储库 Flutter TensorFlow-lite 中的问题