Namburger / edgetpu-minimal-example

minimal example with native build instructions
Apache License 2.0
24 stars 6 forks source link

Segmentation fault (core dumped) #1

Closed Eashwar93 closed 4 years ago

Eashwar93 commented 4 years ago

System info

Issue @Namburger I'm trying to write an application to do classification of video-stream from the inbuilt camera in my laptop using edgetpu. I have used OpenCV to read, decode and vectorize the input to the model. As a first step I wanted to check the compatilibitty of images decoded by OpenCV with TFlite interpretors. So I have written the following code adapted from minimal.cc. I have not made any changes in building the tf interpreter, but the TFlite interpreter doesn't build and I get the following error. I have added a few debug messages to understand where exactly the problem lies nothing else. I could pin point that it is building the interpreter but beyond that I have no idea. The minimal executable runs fine with no issues having the same codes to build the interpreter which is what making me think that I have done something wrong here. Code snippet and error message for your reference. The source file is attached here for your reference.

std::unique_ptr model = tflite::FlatBufferModel::BuildFromFile(model_path.c_str()); if (model == nullptr) { std::cerr << "Fail to build FlatBufferModel from file: " << model_path << std::endl; std::abort(); } else { std::cout << "model loaded successfully" << std::endl; }

// Build interpreter. std::shared_ptr edgetpu_context = edgetpu::EdgeTpuManager::GetSingleton()->OpenDevice();

std::unique_ptr interpreter; if (!edgetpu_context) { interpreter = std::move(coral::BuildInterpreter(model)); } else { std::cout << "opening of edgtpu successful, building interpretor" <<std :: endl; interpreter = std::move(coral::BuildEdgeTpuInterpreter(model, edgetpu_context.get())); } std::cout << "Interpreter built";

Screenshot from 2020-05-01 12-34-31

Would be nice if this issue is resolved Edit

Namburger commented 4 years ago

@Eashwar93 Unfortunately, changing the commit number will not work with libedgetpu because the 1 is dependent of the other. The current released version of libedgetpu was build on this commit which is the required commit. All this complexity will soften up as soon as we opensource libedgetpu, at that time you can build both libraries on any commits you want :)

Eashwar93 commented 4 years ago

@Namburger I'm sorry I just copied the wrong commit number from another post. I did not replace the TF repo that comes with this package. It is the same as d855adfc5a0195788bf5f92c3c7352e638aa1109.

Sorry for the confusion. My bad. In-spite of the correct TF commit the above error persists.

Namburger commented 4 years ago

@Eashwar93 I see, I'll take a look, I'll get back with you on this later today! [edit] Humn, I'm really confused, this is still working for me, did it ever work for you? Could you try adding something like this to see if the tpu can still be recognize?

const auto& available_tpus =
      edgetpu::EdgeTpuManager::GetSingleton()->EnumerateEdgeTpu();
auto tpupath = available_tpus[0].path;
cout << tpupath;
Eashwar93 commented 4 years ago

@Namburger Sorry for the delayed response I forgot to check. The TPU is recognized during the runtime. Please refer to the screenshot below: Screenshot from 2020-05-05 12-15-20

Also as I mentioned earlier the minimal executable runs fine. Do you think I would have meesed up my cmake file? Cmake file attached here for your reference

[edit]I think I found the issue, will correct it and repost

Eashwar93 commented 4 years ago

The issue was in casting the variables. I tested the code it works completely fine. if someone is interested in video classification using coral, then you can use this as a reference. apart from edgetpu and tflite libraries you need to have OpenCV installed as well for the code that I have written. Please also modify your Cmake file accordingly. The source code and cmake lists can be found here for your reference. I will also create a repo soon regarding video tasks in coral in the future and will attach a link here in the upcoming days.

@Namburger a big thanks to you for making our lives easier

Namburger commented 4 years ago

@Eashwar93 oops, sorry, I just realized I never responded to you and I just now saw the notification :( Sorry it has been a busy time :) Very nice, saw that you've also got a hang of cmake, this will come very handy. I guess if you want object detection with video stream also, then you can check this repo Cheers