tensorflow / tflite-support

TFLite Support is a toolkit that helps users to develop ML and deploy TFLite models onto mobile / ioT devices.
Apache License 2.0
373 stars 126 forks source link

Error running Bert Question Answerer #319

Closed FelipeAdachi closed 3 years ago

FelipeAdachi commented 3 years ago

Hello!

I tried using the Bert Question Answerer Demo exactly as instructed here.

I installed bazel from bazelisk, downloaded the tflite model with curl:

curl \
 -L 'https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1?lite-format=tflite' \
 -o /tmp/mobilebert.tflite

And ran the classification tool:

bazel run -c opt \
 tensorflow_lite_support/examples/task/text/desktop:bert_question_answerer_demo -- \
 --model_path=/tmp/mobilebert.tflite \
 --question="Where is Amazon rainforest?" \
 --context="The Amazon rainforest, alternatively, the Amazon Jungle, also known in \
English as Amazonia, is a moist broadleaf tropical rainforest in the Amazon \
biome that covers most of the Amazon basin of South America. This basin \
encompasses 7,000,000 km2 (2,700,000 sq mi), of which \
5,500,000 km2 (2,100,000 sq mi) are covered by the rainforest. This region \
includes territory belonging to nine nations."

However, I'm getting the error No input process unit found from metadata.:

INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=211
INFO: Reading rc options for 'run' from /mnt/c/Users/felip/Documents/Projetos-weg/tflite-support/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'run' from /mnt/c/Users/felip/Documents/Projetos-weg/tflite-support/.bazelrc:
  Inherited 'build' options: --apple_platform_type=macos --enable_platform_specific_config --java_toolchain=//third_party/toolchains/java:tf_java_toolchain --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain --action_env ANDROID_NDK_HOME --action_env ANDROID_NDK_API_LEVEL --action_env ANDROID_BUILD_TOOLS_VERSION --action_env ANDROID_SDK_API_LEVEL --action_env ANDROID_SDK_HOME --define framework_shared_object=true --define open_source_build=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --noincompatible_prohibit_aapt1 --enable_platform_specific_config --config=short_logs --config=v2
INFO: Found applicable config definition build:short_logs in file /mnt/c/Users/felip/Documents/Projetos-weg/tflite-support/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /mnt/c/Users/felip/Documents/Projetos-weg/tflite-support/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:linux in file /mnt/c/Users/felip/Documents/Projetos-weg/tflite-support/.bazelrc: --copt=-w --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
INFO: Analyzed target //tensorflow_lite_support/examples/task/text/desktop:bert_question_answerer_demo (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tensorflow_lite_support/examples/task/text/desktop:bert_question_answerer_demo up-to-date:
  bazel-bin/tensorflow_lite_support/examples/task/text/desktop/bert_question_answerer_demo
INFO: Elapsed time: 0.190s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/tensorflow_lite_support/examples/task/text/desktop/bert_question_answerer_demo '--model_path=/tmp/mobilebert.tflite' '--question=Where is Amazon rainforest?' '--context=The Amazon rainforest, alternatively, the Amazon Jungle, also known in English as Amazonia, is a moist broadleaf tropical rainforest in the Amazon biome that covers most of the Amazon basin of South America. This baINFO: Build completed successfully, 1 total action
Answer failed: No input process unit found from metadata.

Is there something I'm doing wrong? Thank you in advance!

bazel: 3.7.2 running on wsl2

FelipeAdachi commented 3 years ago

Ok, shortly after opening the issue, I got what's wrong.

Instead of downloading the model from https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1?lite-format=tflite, I downloaded the version with metadata: https://tfhub.dev/tensorflow/lite-model/mobilebert/1/metadata/1?lite-format=tflite

That fixed my problem! Thank you!