natanielruiz / android-yolo

Real-time object detection on Android using the YOLO network with TensorFlow
Apache License 2.0
667 stars 212 forks source link

How to make ".pb" file #2

Closed LittleWat closed 7 years ago

LittleWat commented 7 years ago

Hello! Thank you for your nice implementation.

I would like to know how to make ".pb" file form output of darknet. Did you use this ( https://github.com/thtrieu/darkflow ) ?

I am really glad if you help me!

natanielruiz commented 7 years ago

Thanks !

You can definitely use the model definitions from that repo. I used this repo: https://github.com/gliese581gg/YOLO_tensorflow

What I did is I saved the graph structure using tf.train.write_graph(), then I merged the graph with the pre-trained weights using the freeze_graph utility in the TensorFlow repo. Then I stripped the unused nodes and voila, you have a .pb graph with weights that you can use in the tensorflow android demo.

Cheers !

LittleWat commented 7 years ago

Thank you!! I will try

xieyulai commented 7 years ago

Great work, thank you. @natanielruiz

Could you provide more details? Now I am using darknet to training a detector (only one class needs to be detected). But in this step making '.bp' file ,I always get this kind of error [[Node: save/RestoreV2_16/_1 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_75_save/RestoreV2_16", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]()]] I put tf.train.write_graph() in the last of build_networks() of YOLO_tiny_tf.py and use python freeze_graph.py --input_graph=test_tiny.pb --input_checkpoint=model_tiny.ckpt --output_graph=out.pb to merge .bp and .ckpt

Thank you in advance.

natanielruiz commented 7 years ago

Hi Xieyulai,

I have never used darknet to train a network. I belive you are also talking about a protobuff ".pb" file.

I don't understand where in your code you get that error, that would be helpful to know. Also I have never had that error before.

Cheers

agjayant commented 7 years ago

@natanielruiz Did you use the tiny-yolo version? If yes, how did you remove the Dropout Nodes(since they use ops that are not available in android - "realDiv" etc) ? Can you please share your code for removing unused nodes.