Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read Android Demo Detection Model Priors.pb file ? #6670

Closed
AlexandreBriot opened this issue Jan 5, 2017 · 5 comments
Closed

How to read Android Demo Detection Model Priors.pb file ? #6670

AlexandreBriot opened this issue Jan 5, 2017 · 5 comments
Assignees
Labels
type:support Support issues

Comments

@AlexandreBriot
Copy link

Hello !

I would like to look into the assets file : multibox_location_priors.pb which contains boxpriors locations.
I want to use them in a iPythonNotebook to test the model with offline images but I don't know how to access properly to the values for all locations.
Is there any easy way to parse the file and get the locations values like it is possible to do with graph.pb file using these lines

with tf.gfile.FastGFile("graph.pb", 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

Thanks in advance for your help
Alex

@andrewharp
Copy link
Contributor

@AlexandreBriot The easiest thing to do would be to add tensorflow/examples/android/proto/box_coder.proto to CORE_PROTO_SRCS in tensorflow/core/BUILD (you may need to copy the file), and then you should be able to rebuild TF with support for reading it. It's not there already simply because it's a very model-specific proto only currently used for the demo.

@AlexandreBriot
Copy link
Author

@andrewharp Hello Andrew and thank you for your precious help !
I followed your instructions and here is where I am.

  • I modified CORE_PROTO_SRCS in tensorflow/core/BUILD adding "framework/box_coder.proto",

  • I copied box_coder.proto in the corresponding core/framework/ directory

  • I rebuild tensorflow from source but get some errors related to proto version 2 vs 3

  • I modified box_coder.proto by doing these changes

    • Change syntax = "proto2"; to syntax = "proto3";
    • Changepackage org_tensorflow_demo;to package tensorflow;
    • Removing all optional and all default value
      ex : optional float mean = 1 [default = 0.0]; becomes float mean = 1;
    • Suppressing all ; after message section

    Is that correct ? Or is there some inexact/unappropriate changes ?

  • Now I am able to import this freshly built tensorflow in my iPythonNotebook
    The new proto definition is supposed to decode my box-priors.pb file
    I want to do so using the lines as I can do for GraphDef but I don't know which Object I should create to replace GraphDef one and then loading data with ParseFromString method ...

with tf.gfile.FastGFile("box-priors.pb", 'rb') as f:
    priors = tf._?Object?_()
    priors.ParseFromString(f.read())

Could you give me your advice on that part ?
Thanks in advance for your help
Alex

@andrewharp
Copy link
Contributor

andrewharp commented Jan 13, 2017

@AlexandreBriot We'll probably update the code soon to just load from a txt file, as separately supporting a proto build in the Android example adds disproportionate overhead.

In the meantime, I've exported the entire box prior proto to text, which you should be able to easily load into your Python code:

https://gist.github.com/andrewharp/136b07af1f221e9c95b383889f9911e0

edit: leaving this issue open to track until the discussed conversion is complete

@AlexandreBriot
Copy link
Author

@andrewharp Thanks for your answer !

@caisq caisq closed this as completed in ff151c9 Jan 19, 2017
benoitsteiner pushed a commit to benoitsteiner/tensorflow that referenced this issue Jan 27, 2017
…n reading from a proto file in C++ code, in order to reduce code/build complexity.

New model file archive with corresponding changes has been uploaded to https://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1a.zip

Resolves tensorflow#6670
Change: 144872035
@azainab
Copy link

azainab commented Sep 19, 2017

@andrewharp I have a trained spam detection model trained using keras and have got the .pb I am trying it to implement it into a mobile app. Can you please guide me to the right documentation please. It will be of great help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:support Support issues
Projects
None yet
Development

No branches or pull requests

4 participants