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

Alexnet Pre-processing #80

Open
silvaurus opened this issue Jul 14, 2018 · 7 comments
Open

Alexnet Pre-processing #80

silvaurus opened this issue Jul 14, 2018 · 7 comments

Comments

@silvaurus
Copy link

Hi! I've read the post #45 but still confused about preprocessing and the --normalize argument.
Alexnet preprocessing includes (1)turn RGB To BGR (2)crop image size to 227 (3)rescale pixels from 0-1 to 0-225 (4)Subtract the mean of the Imagenet dataset ([104.00698793 116.66876762 122.67891434])

Could you help me with which of those can be done by adding arguments like --normalize, and which of those need to change the prototxt file?

Thank you so much!

@smsharif1991
Copy link
Contributor

smsharif1991 commented Jul 16, 2018

Hi @silvaurus ,

You can use the below command:
./nvdla_runtime --loadable <loadable file> --image <image file> --normalize 1 --mean 104.00698793,116.66876762,122.67891434

Thanks.

@silvaurus
Copy link
Author

Thanks a lot for you reply! What about RGB channels?

Best Regards,

@silvaurus
Copy link
Author

Hi, I tried nvdla_runtime --help, it shows like this:

Usage: ./nvdla_runtime [-options] --loadable <loadable_file>
where options include:
    -h                    print this help message
    -s                    launch test in server mode
    --image <file>        input jpg/pgm file
    --normalize <value>   normalize value for input image
    --rawdump             dump raw dimg data

There doesn't seem to have a --mean argument.
The version of nvdla/sw is below:

commit fa83001e949287d596accdef9dc717abe93084c4
Author: Sharif Inamdar <isharif@nvidia.com>
Date:   Fri Jun 1 13:20:29 2018 +0530

@silvaurus
Copy link
Author

silvaurus commented Jul 17, 2018

I actually did what post #45 said, editing line 171 in file sw/umd/tests/runtime/TestUtils.cpp to switch the ooffset RGB channels, and editing line 180-185 to subtract the mean value of dataset.

I run one image taken from ILSVRS12, the result of which seems to make sense, but still different from running directly from Caffe. I use Caffe in python to run Alexnet similar with Caffe tutorial on Caffenet: https://github.com/BVLC/caffe/blob/master/examples/00-classification.ipynb

Caffe Top5 Result:
n01751748 sea snake 0.20199361
n02643566 lionfish 0.20070419
n01496331 electric ray, crampfish, numbfish, torpedo 0.1754305
n09256479 coral reef 0.08753312
n01498041 stingray 0.08341046
NVDLA Simulator Top5 Result:
n01914609 sea anemone, anemone 0.117065
n01737021 water snake 0.074707
n02423022 gazelle 0.0687866
n02643566 lionfish 0.0566101
n02447366 badger 0.0559387

Image:
imagenet_1

@silvaurus
Copy link
Author

silvaurus commented Jul 19, 2018

Update:
I just read that Caffe pre-process of RGB to BGR transform is due to the underlying OpenCV implementation of imread. In the case of NVDLA Simulator, since it doesn't use OpenCV to process the input, there is no need to do this transformation.

So I get rid of this part in the UMD source code, and get a simulator output like this:

NVDLA Simulator Top5 Result:
n02643566 0.265869 lionfish
n01496331 0.123657 electric ray, crampfish, numbfish, torpedo
n09256479 0.100159 coral reef
n01751748 0.0963135 sea snake
n02074367 0.0688477 dugong, Dugong dugon

The result definitely makes more sense now. But it's still different with Caffe output.

@baolihua
Copy link

Hi @silvaurus
I do some tests on FPGA and I'm surprise your results, how did you get this on FPGA or VP? what's the run command? thanks

@darrenleong
Copy link

Hi @silvaurus

Could you share how to edit "sw/umd/tests/runtime/TestUtils.cpp" for the image preprocessing?

Thanks.

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

No branches or pull requests

4 participants