Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fixed C++ inference tutorial #15280

Closed
wants to merge 4 commits into from
Closed

Conversation

NRauschmayr
Copy link
Contributor

Description

Tutorial did not properly preprocess images and as such produce incorrect predictions. The example would set default values for mean but not for std_dev. So if the user does not provide the file that contains those values, the example would crash. The C++ example predicts now the same class as in the Python example. However, the probabilities differ (9.72 versus 10.411) and we should to look into that

Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix! LGTM: )

@Roshrini
Copy link
Member

@NRauschmayr Thank you for fixing the example. Can you please fix failing CI?
@leleamol Can you take a look?

@Roshrini Roshrini added Example pr-awaiting-review PR is waiting for code review labels Jun 20, 2019
@NRauschmayr
Copy link
Contributor Author

I think we have to update the unit-test: it is using an outdated and not maintained model https://github.com/apache/incubator-mxnet/blob/a9458caec285d3c28d16588fef6aef5e219c7472/cpp-package/example/inference/unit_test_inception_inference.sh
The test should rather use a model from the official model zoo. According to https://mxnet.incubator.apache.org/api/python/gluon/model_zoo.html pre-processing has to be done the following way

image = image/255
normalized = mx.image.color_normalize(image,
                                      mean=mx.nd.array([0.485, 0.456, 0.406]),
                                      std=mx.nd.array([0.229, 0.224, 0.225]))

@karan6181
Copy link
Contributor

@NRauschmayr Could you please resolve the merge conflicts??

@nswamy @szha Could you please review it? Thanks!

@piyushghai
Copy link
Contributor

@NRauschmayr Can you rebase with the latest master please ?

@leleamol Gentle ping for review.

@NRauschmayr
Copy link
Contributor Author

Sorry for the late reply. I have not done the rebase yet, because I saw that the files I modified were deleted by the following commit #15164 I wanted to check first whether or not it makes sense to re-add those files, but I did not have the time yet to compile the latest c++ tutorial of the master branch.

@szha szha self-assigned this Sep 7, 2020
@szha szha changed the base branch from master to v1.x September 9, 2020 04:20
@szha
Copy link
Member

szha commented Sep 9, 2020

@mxnet-bot run ci [all]

@szha
Copy link
Member

szha commented Sep 9, 2020

OK looks like this part is already refactored into the imagenet_inference.cpp example and it's handling the mean values correct. Still, thanks for proposing the patch.

@szha szha closed this Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Example pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants