Open raininglixinyu opened 7 years ago
@raininglixinyu The 6ms is only for inference after both the image and model have already been loaded. I actually changed the code, so that the BGRA color space is being enforced for any kind of UIImage that is passed to the Caffe2 wrapper, so that could have some impact as well.
@RobertBiehl really thanks for your explaining of my question!but i still have a little problem, for example, my testing code is below, is it right to count the time cost of the inference process?
`
let start = CACurrentMediaTime()
if let res = caffe?.predict(imageView.image!) {
let end = CACurrentMediaTime()
print("time cost is : \(end - start)")
}
`
this is the way that i got the 35ms result.
@raininglixinyu @RobertBiehl I also met that problem. The forward costs 30ms on iphone 7p. Is there some special setting I missed ?
I met the same problem.It costs more than 100ms when the example is running on my iphone 6.I don't know the causes of the difference.Can you give me some suggestions?Thanks.
time cost is : 0.171864499803632 Result 291: 🦁 lion, king of beasts, Panthera leo 77.1947% 244: Tibetan mastiff 11.4962% 231: 🐕 collie 5.40875% 260: chow, chow chow 4.47408% 152: Japanese spaniel 0.846499% 256: Newfoundland, Newfoundland dog 0.125846%
Hey, can you let me know how large the image is?
The image size will affect performace: the benchmark in the README.md was with an image at 128x128, I think the current example runs with 256x256px
You can also enforce a certain neural net input size by setting
caffe2.imageInputDimensions = CGSize(width: 128, height: 128)
which resizes the image if needed before feeding it into the network.
And there is always the preprocessing step to map the image to BGRA colors before feeding the image into the network. This is currently mandatory and it's performance is also affected by the image size.
@iwst121 Make sure you are only benchmarking the predict step, not instantiating caffe, loading the model and the image.
@RobertBiehl I have done the resize work(128*128), but it still costs 25-30ms on my iphone6. And i am sure that i just benchmark the predict step:
//Caffe2.mm
double start = clock();
_predictor->run(input_vec, &output_vec);
double end = clock();
printf("The time was: %f\n\n", (double)(end - start) / CLOCKS_PER_SEC);
Looking forward to your help.
@austingg @iwst121 hey bro, is the problem solved?
@raininglixinyu I'm sorry that I don't pay attention to the problem now.
Report
What did you do?
ℹ Please replace this with what you did.
What did you expect to happen?
ℹ Please replace this with what you expected to happen.
What happened instead?
ℹ Please replace this with of what happened instead.
Project that demonstrates the issue
ℹ Please link to a project we can download that reproduces the issue. You can delete this section if your issue is unrelated to build problems,