-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
C++ and the phase_train node #357
Comments
Hi,
|
Hi, |
Hi, Ferris, Have you work out the C++ code? |
@AnshanTJU Works pulled me away from this for now, so I haven't been able to do any decent development. Hopefully things will spin back around sooner or later and I can work more on it. |
Hi,Ferri,i am also doing transfer the facenet to c++,and i has a question,how you realize the svm training code and how to read the .pkl model file,i hope you can help me ,thank you |
@lingbao00 |
OK,thanks,by the way,i had get the output tensor using read image by for loop,But i found the library example using decode to get image data to graph,why you do not use this way. |
@lingbao00 |
OK,i know,any way thank you very much. |
i am sorry to disturb you again, i had a problem,when i use opencv svm to train, i need the traindata ,a Mat,but Mat data defaultly is uchar, how you transfer the tensorflow data,the float data to uchar. |
@lingbao00
Basically, each row of the outputMat will be one of the output tensors. You'll also need to keep track of which labels go with which tensor, as that's a required input for the SVM. When you get it working, can you let me know what sort of tensor outputs you get when the phase_train node is false vs. when its true? I can see no reason why I get null values, so some confirmation I've done something wrong somewhere would be good. |
i had transfer the classifier.py and compare.py to c++,and get the thensor i use your way,weather i set the phase_tensor true or false ,ii can get value not null,but to do classifier i should set it to true the value is same as python get,and to do compare i should set it to false the value is same to python get.the reason i still do not know . |
i am sorry t disturb you again, i am want to ask you a question: which function can set tensorflow to use cpu only. |
@lingbao00 So did you use my method to go from opencv matrix to tensors? Or did you get it working with the tensorflow DecodeJpeg/DecodePng functions? I think you can do something like this to set device: |
@lingbao00 |
@jamesFerris This is the complete program
Am I missing something in initializing tensorFlow which might be the reason I am getting nan irrespective of phase_train ? Thanks |
@mndar As for getting NaN with .jpg...I'm not too sure. Thats kinda my problem as well. Start by confirming your input images are 160x160 pixels, as facenet expects. That should be throwing an error though if that was the case. |
@jamesFerris The output doesn't match that of CLASSIFY in src/classfier.py (I compared the emb_array produced by classifier.py). |
@mndar Thanks for posting those, hopefully they'll help me with my experimenting, when I can get back to it properly. |
This is my initial effort |
Maybe use this code ,you can get the same result with the python code.
|
@knighthappy Can you explain your reasoning behind those steps? |
@jamesFerris |
@knighthappy |
@jamesFerris |
@knighthappy Regardless, this does solve the original issue and everything is working as intended, so I suppose I should finally close this. Thank you everyone for your assistance. If I ever work out exactly what was going on I'll give an update. |
The preprocessing code was originally written by knighthappy on davidsandberg/facenet#357
Can I please know how to avoid nan values for .jpg images, haven't tried with .png images though. |
@ashokbugude |
So I've finally jumped back into this little project after a long distraction. Which meant I'd forgotten why'd I'd done anything, so needed to start looking at things from the ground up. This means I'm pretty sure I've worked out why I was getting the NaN values, and why adding in the prewhiten() step solves it. It was pretty fundamental, and I'm annoyed I didn't pick up on it the first time. All Inception graphs require the input matrices to have normalised values, [-1,1]. The prewhiten() step does this. |
http://ruishu.io/2016/12/27/batchnorm/ it will give you an answer... for what is phase_train and when to keep it false and when to true. |
@mndar : I tried to run your above program for single image and i am getting the following error: |
I've been trying to see if I can convert the classifier.py program into a c++ equivalent. As far as I can tell I've been able to accurately simulate everything to get the graph outputs, but I've been getting strange values. If I set the phase_train node to false, as is done in the python code, my output tensor is made entirely of Nan values. If I set it to true, then I get actual values in the output that appear to match with what the python code gives.
Changing the phase_train node to true in the python code doesn't change its outputs.
What exactly does the phase_train do in this case? Why would setting it to false give such vastly different results in a C++ implementation? I gather this should not be the case, so what could be causing this?
Here is the relevant section of what I'm working on:
The text was updated successfully, but these errors were encountered: