finnickniu / tensorflow_object_detection_tflite Goto Github PK
View Code? Open in Web Editor NEWThis is a repo for training and implementing the mobilenet-ssd v2 to tflite with c++ on x86 and arm64
License: MIT License
This is a repo for training and implementing the mobilenet-ssd v2 to tflite with c++ on x86 and arm64
License: MIT License
CMakeFiles/demo.dir/demo.cpp.o: In function test()': demo.cpp:(.text+0x862): undefined reference to
tflite::InterpreterBuilder::InterpreterBuilder(tflite::FlatBufferModel const&, tflite::OpResolver const&)'
demo.cpp:(.text+0x87b): undefined reference to tflite::InterpreterBuilder::operator()(std::unique_ptr<tflite::Interpreter, std::default_delete<tflite::Interpreter> >*)' demo.cpp:(.text+0x88a): undefined reference to
tflite::InterpreterBuilder::~InterpreterBuilder()'
demo.cpp:(.text+0xaf9): undefined reference to tflite::Interpreter::AllocateTensors()' demo.cpp:(.text+0xbd9): undefined reference to
tflite::Interpreter::SetAllowFp16PrecisionForFp32(bool)'
demo.cpp:(.text+0xbf5): undefined reference to tflite::Interpreter::SetNumThreads(int)' demo.cpp:(.text+0xc0c): undefined reference to
tflite::Interpreter::Invoke()'
demo.cpp:(.text+0x1521): undefined reference to tflite::InterpreterBuilder::~InterpreterBuilder()' CMakeFiles/demo.dir/demo.cpp.o: In function
std::default_deletetflite::Interpreter::operator()(tflite::Interpreter*) const':
demo.cpp:(.text.ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1[ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1]+0x1e): undefined reference to `tflite::Interpreter::~Interpreter()'
collect2: error: ld returned 1 exit status
CMakeFiles/demo.dir/build.make:111: recipe for target 'demo' failed
make[2]: *** [demo] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/demo.dir/all' failed
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I'm not able to resolve this error. Can someone help me?
First of all, thanks for sharing the code publicly, thanks for share a c++ code with tensorflow. I was working on codes with OpenCV, Tensorflow and many vision libs and i saw in your code the score is focusing on num_detections instead of "score outputs".
In the line
float score = expit(nums[count]); // How has this to be done?
where nums
came from num_detections
, this should have been from output scores like:
scores = interpreter->tensor(interpreter->outputs()[2]);
auto scrs = scores->data.f;
In this position, interpreter gives you "the score outputs" and then this line would change to:
float score = expit(scrs[count]);
After all these changes, we can see how expit
function has make more sense values. I hope this helps you.
@finnickniu I retrained an SSD Mobilenet model and converted it to tflite. I'm able to get accurate detections using the python code however while inferencing with C++ code, the score seems to be incorrect and therefore I'm getting a lot of false detections. Also the score seems to be always 0.9995.
In the python code the score is taken from the 3rd output tensor, but in the C++ code it is extracted by calling the expit function with nums[count] as argument. Why is this so ?
Also, I'm only trying to detect one class.
A quick reply will be really appreciated as I'm in a race against time. Thanks
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./demo'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:238
238 ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: No such file or directory.
[Current thread is 1 (Thread 0x7fadc938c9c0 (LWP 27232))]
Hi,
I was working with TFLite. I tried the infernece code for the tflite model in your repo. It is working good.
But when i run the code with the SSD mobilenet V2 tflite model, i get wrong classes and also boxes make no sense...Is this something you noticed?
Can you please help me?
I convert the model using following commands.
python object_detection/export_tflite_ssd_graph.py
--pipeline_config_path=$CONFIG_FILE
--trained_checkpoint_prefix=$CHKPT_DIR
--output_directory=$MODEL_DIR
--add_postprocessing_op=true
tflite_convert --graph_def_file $MODEL_DIR/tflite_graph.pb --output_file $MODEL_DIR/detect.tflite
--input_arrays=normalized_input_image_tensor
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3'
--input_shapes=1,300,300,3 --inference_type=QUANTIZED_UINT8
--mean_values=128 --std_dev_values=128
--change_concat_input_ranges=false --allow_custom_ops
--default_ranges_min=0 --default_ranges_max=255
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.