GithubHelp home page GithubHelp logo

Comments (21)

Sundy1219 avatar Sundy1219 commented on August 17, 2024 1

Hi @samjabrahams ,I am glad to receive your reply. I get the tensorflow source compiled correctly and build it successfully due to your help. Thanks very much !!!

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

ok, it gives me an error below after 20 minutes:

pi@raspberrypi:~/tf/tensorflow $ bazel build -c opt --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package
......................................
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
ERROR: /home/pi/tf/tensorflow/tensorflow/tensorboard/bower/BUILD:5:1: no such package '@polymer//': Error cloning repository: Unexpected end of file from server caused by Unexpected end of file from server caused by Unexpected end of file from server and referenced by '//tensorflow/tensorboard/bower:bower'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 1317.545s

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

The "Sandboxed execution is not supported" warning is expected, though I should let people know about it in the guide, thanks for bringing this up!

As far as the "error cloning repository error is concerned- that possibly sounds like a networking error? I haven't seen that before. I'm assuming you followed the previous steps from the guide verbatim.

Additionally, did you see the issue template when you opened this up? There are questions that would help me reproduce this error on there:

Describe the Issue

Steps to Reproduce

Hardware/Software Info

Please provide the following information about your Raspberry Pi setup:

  • Raspberry Pi model:
  • Operating System used:
  • Version of Python used:
  • SD card memory size:
  • Size of USB/other device used as swap (if building from source):
  • TensorFlow git commit hash (if building from source):

Relevant Console Output/Logs

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

Describe the Issue
I followed all the steps except these two

sudo nano /etc/fstab
/dev/XXX none swap sw,pri=5 0 0

because I don't have an error claim at that time. But when I start to build tensorflow in folder
/home/pi/tf/tensorflow. It gives me error.

ERROR: /home/pi/tf/tensorflow/tensorflow/tensorboard/bower/BUILD:5:1: no such package '@polymer//': Error cloning repository: Unexpected end of file from server caused by Unexpected end of file from server caused by Unexpected end of file from server and referenced by '//tensorflow/tensorboard/bower:bower'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 1317.545s

Steps to Reproduce
Hardware/Software Info
Raspberry pi 3 model B
USB drive 16 GB
microSD 32 GB
python 2.7

Please provide the following information about your Raspberry Pi setup:

**Raspberry Pi model:** Raspberry pi 3 model B
**Operating System used:** Linux raspberrypi 4.4.11-v7+ #888 SMP Mon May 23 20:10:33 BST 2016 armv7l GNU/Linux

**Version of Python used:** python 2.7
**SD card memory size:** 32 GB
**Size of USB/other device used as swap (if building from source):** 16 GB USB drive
**TensorFlow git commit hash (if building from source):** I'm not sure how to do this

Relevant Console Output/Logs

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

my system seems not to be vanilla copy of Raspbian 8.0 (jessie). Is that the reason?

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

Ok, I run "sudo apt-get upgrade" and "sudo apt-get dist-upgrade" and redo the clone and build.
The previous error disappear but come with a new error below:

pi@raspberrypi:~/tf/tensorflow $ bazel build -c opt --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package
...................................................
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
INFO: Found 1 target...
INFO: From Compiling tensorflow/core/lib/io/zlib_outputbuffer.cc [for host]:
tensorflow/core/lib/io/zlib_outputbuffer.cc: In member function 'void tensorflow::io::ZlibOutputBuffer::AddToInputBuffer(tensorflow::StringPiece)':
tensorflow/core/lib/io/zlib_outputbuffer.cc:89:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (bytes_to_write > free_tail_bytes) {
^
tensorflow/core/lib/io/zlib_outputbuffer.cc: In member function 'tensorflow::Status tensorflow::io::ZlibOutputBuffer::Write(tensorflow::StringPiece)':
tensorflow/core/lib/io/zlib_outputbuffer.cc:146:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (bytes_to_write <= AvailableInputSpace()) {
^
tensorflow/core/lib/io/zlib_outputbuffer.cc:154:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (bytes_to_write <= AvailableInputSpace()) {
^
In file included from ./tensorflow/core/platform/default/logging.h:23:0,
from ./tensorflow/core/platform/logging.h:25,
from ./tensorflow/core/lib/core/status.h:24,
from ./tensorflow/core/lib/io/zlib_outputbuffer.h:20,
from tensorflow/core/lib/io/zlib_outputbuffer.cc:16:
./tensorflow/core/platform/default/logging.h: In instantiation of 'std::string* tensorflow::internal::Check_LEImpl(const T1&, const T2&, const char_) [with T1 = unsigned int; T2 = int; std::string = std::basic_string]':
tensorflow/core/lib/io/zlib_outputbuffer.cc:65:3: required from here
./tensorflow/core/platform/default/logging.h:196:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
TF_DEFINE_CHECK_OP_IMPL(Check_LE, <= )
^
./tensorflow/core/platform/macros.h:54:29: note: in definition of macro 'TF_PREDICT_TRUE'
#define TF_PREDICT_TRUE(x) (x)
^
./tensorflow/core/platform/default/logging.h:196:1: note: in expansion of macro 'TF_DEFINE_CHECK_OP_IMPL'
TF_DEFINE_CHECK_OP_IMPL(Check_LE, <= )
^
ERROR: /home/pi/tf/tensorflow/tensorflow/core/BUILD:817:1: C++ compilation of rule '//tensorflow/core:lib_internal' failed: gcc failed: error executing command
(cd /home/pi/.cache/bazel/bazel_pi/4770c5ca1786316d370c900c0b614a6d/tensorflow &&
exec env -
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
/usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections -g0 '-std=c++0x' -iquote . -iquote bazel-out/host/genfiles -iquote external/protobuf -iquote bazel-out/host/genfiles/external/protobuf -iquote external/bazel_tools -iquote bazel-out/host/genfiles/external/bazel_tools -iquote external/farmhash_archive -iquote bazel-out/host/genfiles/external/farmhash_archive -iquote external/jpeg_archive -iquote bazel-out/host/genfiles/external/jpeg_archive -iquote external/png_archive -iquote bazel-out/host/genfiles/external/png_archive -iquote external/highwayhash -iquote bazel-out/host/genfiles/external/highwayhash -iquote external/re2 -iquote bazel-out/host/genfiles/external/re2 -iquote external/eigen_archive -iquote bazel-out/host/genfiles/external/eigen_archive -iquote external/zlib_archive -iquote bazel-out/host/genfiles/external/zlib_archive -isystem external/protobuf/src -isystem bazel-out/host/genfiles/external/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem bazel-out/host/genfiles/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/host/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/host/genfiles/external/png_archive/libpng-1.2.53 -isystem external/highwayhash -isystem bazel-out/host/genfiles/external/highwayhash -isystem external/re2 -isystem bazel-out/host/genfiles/external/re2 -isystem third_party/eigen3 -isystem bazel-out/host/genfiles/third_party/eigen3 -isystem external/eigen_archive/eigen-eigen-5f86b31739cd -isystem bazel-out/host/genfiles/external/eigen_archive/eigen-eigen-5f86b31739cd -isystem external/zlib_archive/zlib-1.2.8 -isystem bazel-out/host/genfiles/external/zlib_archive/zlib-1.2.8 -fno-exceptions -DEIGEN_AVOID_STL_ARRAY -pthread -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE
_="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/host/bin/tensorflow/core/objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.o' -MD -MF bazel-out/host/bin/tensorflow/core/objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.d -fPIC -c tensorflow/core/lib/jpeg/jpeg_handle.cc -o bazel-out/host/bin/tensorflow/core/objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from ./tensorflow/core/lib/jpeg/jpeg_handle.h:22:0,
from tensorflow/core/lib/jpeg/jpeg_handle.cc:22:
./tensorflow/core/platform/jpeg.h:31:2: error: #error Define the appropriate PLATFORM
macro for this platform
#error Define the appropriate PLATFORM
macro for this platform
^
In file included from tensorflow/core/lib/jpeg/jpeg_handle.cc:22:0:
./tensorflow/core/lib/jpeg/jpeg_handle.h:29:17: error: variable or field 'CatchError' declared void
void CatchError(j_common_ptr cinfo);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:29:17: error: 'j_common_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:32:31: error: field 'pub' has incomplete type 'tensorflow::jpeg::jpeg_destination_mgr'
struct jpeg_destination_mgr pub;
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:33:3: error: 'JOCTET' does not name a type
JOCTET *buffer;
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:40:26: error: field 'pub' has incomplete type 'tensorflow::jpeg::jpeg_source_mgr'
struct jpeg_source_mgr pub;
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:13: error: variable or field 'SetSrc' declared void
void SetSrc(j_decompress_ptr cinfo, const void *data,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:13: error: 'j_decompress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:37: error: expected primary-expression before 'const'
void SetSrc(j_decompress_ptr cinfo, const void *data,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:47:13: error: expected primary-expression before 'unsigned'
unsigned long int datasize, bool try_recover_truncated_jpeg);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:47:41: error: expected primary-expression before 'bool'
unsigned long int datasize, bool try_recover_truncated_jpeg);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:14: error: variable or field 'SetDest' declared void
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:14: error: 'j_compress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:36: error: expected primary-expression before 'void'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:50: error: expected primary-expression before 'int'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:14: error: variable or field 'SetDest' declared void
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:14: error: 'j_compress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:36: error: expected primary-expression before 'void'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:50: error: expected primary-expression before 'int'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:55:21: error: expected primary-expression before '
' token
string *destination);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:55:22: error: 'destination' was not declared in this scope
string *destination);
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:32:17: error: variable or field 'CatchError' declared void
void CatchError(j_common_ptr cinfo) {
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:32:17: error: 'j_common_ptr' was not declared in this scope
tensorflow/core/lib/jpeg/jpeg_handle.cc:45:25: error: variable or field 'MemInitDestination' declared void
void MemInitDestination(j_compress_ptr cinfo) {
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:45:25: error: 'j_compress_ptr' was not declared in this scope
tensorflow/core/lib/jpeg/jpeg_handle.cc:177:1: error: expected '}' at end of input
} // namespace tensorflow
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:177:1: error: expected '}' at end of input
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 205.726s, Critical Path: 66.17s

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

@samjabrahams
Any suggestion?

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

@zxzhijia

Sorry for the delay- it's been a busy couple of days. I'll try to replicate this as soon as I can, as it's possible it is something due to a change in the TensorFlow repository.

To get the commit hash from git, try running this command:

git log --oneline --decorate -5

You should get an output like this:

ce330a7 (HEAD -> master, upstream/master, upstream/HEAD) Merge pull request #2828 from MicaelCarvalho/master
2c33855 Fix build for PPC. (#2911)
451f18c Fixing minor typo in comments. (#2961)
af794ed Merge pull request #2945 from siddharth-agrawal/sparse_tensor_shape_dtype
242d75a Merge pull request #2946 from siddharth-agrawal/sparse_tensor_square

Copy the alphanumeric string that has the word "HEAD" next to it, in this case it would be ce330a7

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

No problem. Thank you for your reply. I have a maybe novice question. Do I have to
build from source in order to run the network trained on my desktop? I've
collected images from my GoPiGo camera and trained it using Inception model
on my PC. I'm wondering what to do next in order to use the trained model
on my raspberry pi. I tried to find the image_retraining folder in my
raspberry pi and test by following link "
https://petewarden.com/2016/02/28/tensorflow-for-poets/comment-page-1/#comment-98551"
using:

bazel-bin/tensorflow/examples/image_retraining/retrain
--bottleneck_dir=/tf_files/bottlenecks
--model_dir=/tf_files/inception
--output_graph=/tf_files/retrained_graph.pb
--output_labels=/tf_files/retrained_labels.txt
--image_dir /tf_files/flower_photos

It works on my PC. But I don't know whether directly git clone
tensorflow... from source and use the image_retraining in it is ok. If
that's fine, I don't

need to build from source. By the way, i supposed bazel-bin can be run
in terminal. But how could I combine the tensorflow bazel-bin with my
GoPiGo control .py file?

On Mon, Jun 20, 2016 at 10:27 PM, Sam Abrahams [email protected]
wrote:

@zxzhijia
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_zxzhijia&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=-CAgAN2eqQzcWealyw-6Wv6wnQURf8_TXtvEl-QJSgs&s=aqtivtxXO-vznmxWnVT8XE-j5kRjqDT7J4RbJOlnRXE&e=

Sorry for the delay- it's been a busy couple of days. I'll try to
replicate this as soon as I can, as it's possible it is something due to a
change in the TensorFlow repository.

To get the commit hash from git, try running this command:

git log --oneline --decorate -5

You should get an output like this:

ce330a7 (HEAD -> master, upstream/master, upstream/HEAD) Merge pull request #2828 from MicaelCarvalho/master
2c33855 Fix build for PPC. (#2911)
451f18c Fixing minor typo in comments. (#2961)
af794ed Merge pull request #2945 from siddharth-agrawal/sparse_tensor_shape_dtype
242d75a Merge pull request #2946 from siddharth-agrawal/sparse_tensor_square

Copy the alphanumeric string that has the word "HEAD" next to it, in this
case it would be ce330a7


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_samjabrahams_tensorflow-2Don-2Draspberry-2Dpi_issues_23-23issuecomment-2D227324167&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=-CAgAN2eqQzcWealyw-6Wv6wnQURf8_TXtvEl-QJSgs&s=B8p9cQp5P6AHXTxOibFODnnJAoYkj44QKQA8z8oUaFc&e=,
or mute the thread
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe_ALPsQEmUIl1S9lHSjyDsHGwwSYce2mdtks5qN0wogaJpZM4I5FQW&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=-CAgAN2eqQzcWealyw-6Wv6wnQURf8_TXtvEl-QJSgs&s=Cw9kaK2q0REu8uGmUpK-1gvfyeYhjIRTfGku3pRvU2Y&e=
.

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

I know GoPiGo might move really slow. But just feel so exciting to see if it works: )

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

In other words, I now have retrained_graph.pb and retrained_labels.txt files trained by my PC using GoPiGo collected images and labels. I don't have the image_retraining folder on my raspberry pi. How could I use this to control the GoPiGo? Do you have any suggestions?

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

Fun! If you want to use the example C++ program in the tensorflow/examples/label_image directory, you'll have to build it with Bazel. From the same Pete Warden blog, that means you would copy the retrained_graph.pb and retrained_labels.txt files to your device, and then run this on the RPi:

bazel build tensorflow/examples/label_image:label_image && \
bazel-bin/tensorflow/examples/label_image/label_image \
--graph=/tf_files/retrained_graph.pb \
--labels=/tf_files/retrained_labels.txt \
--output_layer=final_result \
--image=/tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg  # Or whatever image you want to run)

The other option is to use the Python version of the example, which would mean tweaking this file to read in your retrained_graph.pb, as well as properly handling retrained_labels.txt. This requires less compilation, but more work by hand.

Let me know if you have any more questions or if any of this wasn't clear!

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

I tried to edit the python version of the example. In the code, they call a
pbtxt file, I don't have that. I only have a pb file and a txt file. How
should I replace that part of their code?

On Tuesday, June 21, 2016, Sam Abrahams [email protected] wrote:

Fun! If you want to use the example C++ program in the
tensorflow/examples/label_image directory, you'll have to build it with
Bazel. From the same Pete Warden blog, that means you would copy the
retrained_graph.pb and retrained_labels.txt files to your device, and then
run this on the RPi:

bazel build tensorflow/examples/label_image:label_image &&
bazel-bin/tensorflow/examples/label_image/label_image
--graph=/tf_files/retrained_graph.pb
--labels=/tf_files/retrained_labels.txt
--output_layer=final_result
--image=/tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg # Or whatever image you want to run)

The other option is to use the Python version of the example, which would
mean tweaking this file
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_tensorflow_tensorflow_blob_master_tensorflow_models_image_imagenet_classify-5Fimage.py&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=HiueBB26uAtVZJJYxlx14xvS_xtPdURPLrBwM1g3lj8&e=
to read in your retrained_graph.pb, as well as properly handling
retrained_labels.txt. This requires less compilation, but more work by hand.

Let me know if you have any more questions or if any of this wasn't clear!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_samjabrahams_tensorflow-2Don-2Draspberry-2Dpi_issues_23-23issuecomment-2D227364738&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=h0yr94xt5_oEQZ94GYWqdJUEthoOpbF_UqLa-Z97sXs&e=,
or mute the thread
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe_ALPsQI9l8AXmxr5oTH3qNbFdl0JhfUwyks5qN5YhgaJpZM4I5FQW&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=5Am1BPMt3KN28zDhBgg2_wjszrIMNpcFMA_c5V0th5g&e=
.

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

It's this line.

label_lookup_path = os.path.join(FLAGS.model_dir,
'imagenet_2012_challenge_label_map_proto.pbtxt')

On Tuesday, June 21, 2016, Xu Zhang [email protected] wrote:

I tried to edit the python version of the example. In the code, they call
a pbtxt file, I don't have that. I only have a pb file and a txt file. How
should I replace that part of their code?

On Tuesday, June 21, 2016, Sam Abrahams <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

Fun! If you want to use the example C++ program in the
tensorflow/examples/label_image directory, you'll have to build it with
Bazel. From the same Pete Warden blog, that means you would copy the
retrained_graph.pb and retrained_labels.txt files to your device, and then
run this on the RPi:

bazel build tensorflow/examples/label_image:label_image &&
bazel-bin/tensorflow/examples/label_image/label_image
--graph=/tf_files/retrained_graph.pb
--labels=/tf_files/retrained_labels.txt
--output_layer=final_result
--image=/tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg # Or whatever image you want to run)

The other option is to use the Python version of the example, which would
mean tweaking this file
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_tensorflow_tensorflow_blob_master_tensorflow_models_image_imagenet_classify-5Fimage.py&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=HiueBB26uAtVZJJYxlx14xvS_xtPdURPLrBwM1g3lj8&e=
to read in your retrained_graph.pb, as well as properly handling
retrained_labels.txt. This requires less compilation, but more work by hand.

Let me know if you have any more questions or if any of this wasn't clear!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_samjabrahams_tensorflow-2Don-2Draspberry-2Dpi_issues_23-23issuecomment-2D227364738&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=h0yr94xt5_oEQZ94GYWqdJUEthoOpbF_UqLa-Z97sXs&e=,
or mute the thread
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe_ALPsQI9l8AXmxr5oTH3qNbFdl0JhfUwyks5qN5YhgaJpZM4I5FQW&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=gimbSKpTrO17c7Xa9ZEjMBdnAdCF3s0vCFr4nhufxG0&s=5Am1BPMt3KN28zDhBgg2_wjszrIMNpcFMA_c5V0th5g&e=
.

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

Yes, that code needs replacing. The original Inception graph has something like 1000 output labels, and the .pbtxt is how they convert the output vector to human readable text. I think the retrained_labels.txt file only has 5 outputs, so you should be able to handle them directly in the code.

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

I tried this code below by python retrain_test.py /home/pi/Robotimages/Robot1/w/1.jpg but got an error

import tensorflow as tf, sys
image_path = sys.argv[1]

Read in the image_data

image_data = tf.gfile.FastGFile(image_path, 'rb').read()

Loads label file, strips off carriage return

label_lines = [line.rstrip() for line
in tf.gfile.GFile("/home/pi/Robotimages/retrained_labels.txt")]

Unpersists graph from file

with tf.gfile.FastGFile("/home/pi/Robotimages/retrained_graph.pb", 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
with tf.Session() as sess:

Feed the image_data as input to the graph and get first prediction

softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
predictions = sess.run(softmax_tensor,
{'DecodeJpeg/contents:0': image_data})

Sort to show labels of first prediction in order of confidence

top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]
for node_id in top_k:
human_string = label_lines[node_id]
score = predictions[0][node_id]
print('%s (score = %.5f)' % (human_string, score))

Error is as below

pi@raspberrypi:/robotimages $ python retrain_test.py
/home/pi/robotimages/Robot1/w/1.jpg
Traceback (most recent call last):
File "retrain_test.py", line 15, in
graph_def.ParseFromString(f.read())
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/message.py",
line 185, in ParseFromString
self.MergeFromString(serialized)
File
"/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py",
line 1091, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File
"/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py",
line 1127, in InternalParse
pos = field_decoder(buffer, new_pos, end, self, field_dict)
File
"/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/decoder.py",
line 610, in DecodeRepeatedField
raise _DecodeError('Truncated message.')
google.protobuf.message.DecodeError: Truncated message.
pi@raspberrypi:
/robotimages $

On Thu, Jun 23, 2016 at 3:57 AM, Sam Abrahams [email protected]
wrote:

Yes, that's code needs replacing. The original Inception graph has
something like 1000 output labels, and the .pbtxt is how they convert the
output vector to human readable text. I think the retrained_labels.txt file
only has 5 outputs, so you should be able to handle them directly in the
code.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_samjabrahams_tensorflow-2Don-2Draspberry-2Dpi_issues_23-23issuecomment-2D227977000&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=_3tBoqX2Lhhvqfk-9JUGCQ7zTRJ2FdQXd3fcTpJwgNM&s=-dxfEHeR1Yg2zD1p0_Z1fWnUGiUsrgGqATGcnjL6oms&e=,
or mute the thread
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe_ALPsQON32FZTsvuED7r1a7yqbfj2ZtSlks5qOjxmgaJpZM4I5FQW&d=CwMCaQ&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=X3YsXL1AZsKHgsh28HFY8A&m=_3tBoqX2Lhhvqfk-9JUGCQ7zTRJ2FdQXd3fcTpJwgNM&s=_noC0sLSjoC8fO7xPATZamFG1FoZVvhk-m2HXeOc3aQ&e=
.

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

Sorry to bother u. Any suggestion? @samjabrahams

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

Hi @zxzhijia -

Sorry for the delayed response. There are two separate things going on in this issue thread:

The first is the compilation error. I've been able to replicate the error, and it seems to be due to a change in the /tensorflow/core/lib/jpeg directory (there may be other issues, too). When I have some time, I plan on figuring out what exactly is causing the error, but it may take a little while to diagnose.

The other question is related to using the pb file and txt file without using the pbtxt labels file. Unfortunately, this really isn't an appropriate venue for that sort of conversation, and I apologize for not being able to assist you further. For questions related to projects, I highly recommend Stack Overflow. This repository, for now, can only support issues and questions strictly related to the TensorFlow binaries for Raspberry Pi, as I don't have the time to debug individual users' code.

I'm going to leave this issue open as I work on the compilation problem, as that needs to be addressed.

from tensorflow-on-raspberry-pi.

zxzhijia avatar zxzhijia commented on August 17, 2024

Thank you for your reply. I'll post it on Stack Overflow.

from tensorflow-on-raspberry-pi.

Sundy1219 avatar Sundy1219 commented on August 17, 2024

@zxzhijia
Hello, i meet the same problem with you when building from source. the problem is ::

ERROR: /home/pi/tf/tensorflow/tensorflow/core/BUILD:817:1: C++ compilation of rule '//tensorflow/core:lib_internal' failed: gcc failed: error executing command
(cd /home/pi/.cache/bazel/bazel_pi/4770c5ca1786316d370c900c0b614a6d/tensorflow &&
exec env -
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
/usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections -g0 '-std=c++0x' -iquote . -iquote bazel-out/host/genfiles -iquote external/protobuf -iquote bazel-out/host/genfiles/external/protobuf -iquote external/bazel_tools -iquote bazel-out/host/genfiles/external/bazel_tools -iquote external/farmhash_archive -iquote bazel-out/host/genfiles/external/farmhash_archive -iquote external/jpeg_archive -iquote bazel-out/host/genfiles/external/jpeg_archive -iquote external/png_archive -iquote bazel-out/host/genfiles/external/png_archive -iquote external/highwayhash -iquote bazel-out/host/genfiles/external/highwayhash -iquote external/re2 -iquote bazel-out/host/genfiles/external/re2 -iquote external/eigen_archive -iquote bazel-out/host/genfiles/external/eigen_archive -iquote external/zlib_archive -iquote bazel-out/host/genfiles/external/zlib_archive -isystem external/protobuf/src -isystem bazel-out/host/genfiles/external/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem bazel-out/host/genfiles/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/host/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/host/genfiles/external/png_archive/libpng-1.2.53 -isystem external/highwayhash -isystem bazel-out/host/genfiles/external/highwayhash -isystem external/re2 -isystem bazel-out/host/genfiles/external/re2 -isystem third_party/eigen3 -isystem bazel-out/host/genfiles/third_party/eigen3 -isystem external/eigen_archive/eigen-eigen-5f86b31739cd -isystem bazel-out/host/genfiles/external/eigen_archive/eigen-eigen-5f86b31739cd -isystem external/zlib_archive/zlib-1.2.8 -isystem bazel-out/host/genfiles/external/zlib_archive/zlib-1.2.8 -fno-exceptions DEIGEN_AVOID_STL_ARRAY -pthread -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE_="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/host/bin/tensorflow/core/objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.o' -MD -MF bazel-out/host/bin/tensorflow/core/_objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.d -fPIC -c tensorflow/core/lib/jpeg/jpeg_handle.cc -o bazel-out/host/bin/tensorflow/core/objs/lib_internal/tensorflow/core/lib/jpeg/jpeg_handle.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from ./tensorflow/core/lib/jpeg/jpeg_handle.h:22:0,
from tensorflow/core/lib/jpeg/jpeg_handle.cc:22:
./tensorflow/core/platform/jpeg.h:31:2: error: #error Define the appropriate PLATFORM macro for this platform
#error Define the appropriate PLATFORM
macro for this platform
^
In file included from tensorflow/core/lib/jpeg/jpeg_handle.cc:22:0:
./tensorflow/core/lib/jpeg/jpeg_handle.h:29:17: error: variable or field 'CatchError' declared void
void CatchError(j_common_ptr cinfo);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:29:17: error: 'j_common_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:32:31: error: field 'pub' has incomplete type 'tensorflow::jpeg::jpeg_destination_mgr'
struct jpeg_destination_mgr pub;
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:33:3: error: 'JOCTET' does not name a type
JOCTET *buffer;
^/tensorflow/core/lib/jpeg/jpeg_handle.h:40:26: error: field 'pub' has incomplete type 'tensorflow::jpeg::jpeg_source_mgr'
struct jpeg_source_mgr pub;
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:13: error: variable or field 'SetSrc' declared void
void SetSrc(j_decompress_ptr cinfo, const void *data,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:13: error: 'j_decompress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:46:37: error: expected primary-expression before 'const'
void SetSrc(j_decompress_ptr cinfo, const void *data,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:47:13: error: expected primary-expression before 'unsigned'
unsigned long int datasize, bool try_recover_truncated_jpeg);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:47:41: error: expected primary-expression before 'bool'
unsigned long int datasize, bool try_recover_truncated_jpeg);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:14: error: variable or field 'SetDest' declared void
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:14: error: 'j_compress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:36: error: expected primary-expression before 'void'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:51:50: error: expected primary-expression before 'int'void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:14: error: variable or field 'SetDest' declared void
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:14: error: 'j_compress_ptr' was not declared in this scope
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:36: error: expected primary-expression before 'void'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:54:50: error: expected primary-expression before 'int'
void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:55:21: error: expected primary-expression before '' token
string *destination);
^
./tensorflow/core/lib/jpeg/jpeg_handle.h:55:22: error: 'destination' was not declared in this scope
string *destination);
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:32:17: error: variable or field 'CatchError' declared void
void CatchError(j_common_ptr cinfo) {
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:32:17: error: 'j_common_ptr' was not declared in this scope
tensorflow/core/lib/jpeg/jpeg_handle.cc:45:25: error: variable or field 'MemInitDestination' declared void
void MemInitDestination(j_compress_ptr cinfo) {
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:45:25: error: 'j_compress_ptr' was not declared in this scope
tensorflow/core/lib/jpeg/jpeg_handle.cc:177:1: error: expected '}' at end of input
} // namespace tensorflow
^
tensorflow/core/lib/jpeg/jpeg_handle.cc:177:1: error: expected '}' at end of input
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 205.726s, Critical Path: 66.17s

How to solve it ? Thanks

from tensorflow-on-raspberry-pi.

samjabrahams avatar samjabrahams commented on August 17, 2024

Hi @Sundy1219 - I discovered the fix to this yesterday, and will update the GUIDE later today.

In the meantime, here's what you need to do:

  1. Delete this line in tensorflow/core/platform/platform.h
  2. Build with the following command:
$ bazel build -c opt --copt="-mfpu=neon" --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package

The --copt="-mfpu=neon" flag is necessary to make certain libraries compile correctly.

from tensorflow-on-raspberry-pi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.