go-tflite icon indicating copy to clipboard operation
go-tflite copied to clipboard

Add support for newer tf light

Open plord12 opened this issue 2 years ago • 2 comments

The docs says only 2.2.0-rc3 is supported ... to build this requires an old version of bazel which requires old version of jdk. In short pretty hard to build on recent linux since dependencies arn't easily available.

Will a more recent release of tensorflow work ?

plord12 avatar Nov 04 '22 08:11 plord12

I see newer versions of tensorflow make use of cmake. So this worked for me ( linux arm64 ) :

git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
cd tensorflow_src
git checkout v2.10.0
# https://github.com/tensorflow/tensorflow/issues/56125
sed -i 's/common\.c/common\.cc/' ./tensorflow/lite/c/CMakeLists.txt
cd ..
mkdir tflite_build
cd tflite_build
cmake ../tensorflow_src/tensorflow/lite/c
cmake --build . -j 1

Then

export CGO_CFLAGS=-I$HOME/src/tensorflow/tensorflow_src
export CGO_LDFLAGS=-L$HOME/src/tensorflow/tflite_build
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/src/tensorflow/tflite_build

git clone https://github.com/mattn/go-tflite.git
cd go-tflite/_example/label_image
go run main.go 
85: peacock: 0.976471

plord12 avatar Nov 04 '22 12:11 plord12

I was able to make Tensorflow 2.14.0 work on macOS with these steps, and it includes fix for "common.c" issue so that step can be skipped

tphakala avatar Oct 09 '23 16:10 tphakala