dgschwend / zynqnet

Master Thesis "ZynqNet: An FPGA-Accelerated Embedded Convolutional Neural Network"
GNU General Public License v3.0
743 stars 297 forks source link

Convert jpeg to binary #36

Open snxoxopy opened 6 years ago

snxoxopy commented 6 years ago

Hi :) I've got some issues. Would you check it up for me? I found a different result from the example you uploaded(indata.bin) while trying to convert puppy-500x350.jpg to test.bin. After converting the puppy-500x350.jpg, I compared test.bin with indata.bin except for noise padding parts and I used half-fill, half-crop by uncommenting your code. Unfortunately, they don't have the same value exactly. Here are my results. [Note. Black pixels mean different values and White pixels are equivalent values] image

I worried that I would get wrong binary files in this way when I converted other jpg/jpeg files. Actually, I checked the low accuracy of test.bin I converted around 75% when trying in CPU simulation, which means whereas the original file (indata.bin) shows the accuracy around 88% but I couldn't get.

Below the image shows the result of CPU simulation. [Note. Left one uses indata.bin Right one uses test.bin] image

Plus, I attached files containing Python code I rewrote(JUST REMOVE comments and import matplotlib to display images), indata.bin and indata-puppy-rgb.bin(test.bin). Binary files were converted with Python 2.7. suzinee_issue.zip

Could you tell me why I could't get the same result with yours? and happy new year!

dgschwend commented 6 years ago

Hi

I‘m not sure why there‘s a binary difference. Can you check how much the individual pixel values differ? E.g. by how many percent you‘re off from the original image, for some test pixels? It‘s normal that floating-point computations give slightly different results on different machines, but it should be only a very small difference.

Then, what you‘re referring to as 88% vs. 75%„accuracy“ has nothing to do with actual CNN accuracy. It‘s just the Softmax probability that the network assigns to the „dog“ class. As long as your network also assigns the highest probability to class 207 („dog“), all is fine. If you want to measure the CNN’s accuracy, you have to convert and infer the entire ImageNet test set and measure the percentage of correct guesses.

Regards David

Am 21.02.2018 um 02:17 schrieb suzinee notifications@github.com:

Hi :) I've got some issues. Would you check it up for me? I found a different result from the example you uploaded(indata.bin) while trying to convert puppy-500x350.jpg to test.bin. After converting the puppy-500x350.jpg, I compared test.bin with indata.bin except for noise padding parts and I used half-fill, half-crop by uncomment your code. Unfortunately, they don't have the same value exactly. Here are my results. [Note. Black pixels mean different values and White pixels are equivalent values]

I worried that I would get wrong binary files in this way when I converted other jpg/jpeg files. Actually, I checked the low accuracy of test.bin I converted around 75% when trying in CPU simulation, which means whereas the original file (indata.bin) shows the accuracy around 88% but I couldn't get.

Below the image shows the result of CPU simulation. [Note. Left one uses indata.bin Right one uses test.bin]

Could you tell me why didn't I get the accuracy? and happy new year!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

snxoxopy commented 6 years ago

Thank you for your reply:)

OHhh there was the confusing word "ACCURACY" I wrote. As you said, it's just the probabilities calculated from the Softmax function. What I wanted to tell you was that I got the lower probabilities when I used test.bin than indata.bin.

Plus, I counted how many pixels are different from the original image and I can see 40,167 pixels equivalent to the original image, which shows pixels of about 24%(40,167/162,816(256(Width) x 212(Height) x 3(Channels)) are white. I guess this results should not be ignored, but I have no idea how and where I have to revise your code. When it comes to machines, I also use ZynqNet so I guess the right probabilities have to equal the left. Did you use "convert_jpeg_to_bin.py" to convert puppy-500x350.jpg to indata.bin? Or is there another pre-processing?

Anyway, since the result of top-1 class is equivalent to "207", I don't need to care any problem to use the code I removed comments when I use new images converted by the code I uploaded, do I?

Regards Sujin

dgschwend commented 6 years ago

Yes, as long as the top-1 class is the same and has a clearly higher Softmax class probability than the rest of the classes, you don‘t need to care.

The network was trained with „half-crop-half-fill“ images, so I assume this method is also reasonable for inference. You would have to try and measure the impact on accuracy...

Am 28.02.2018 um 01:47 schrieb suzinee notifications@github.com:

Thank you for your reply:)

OHhh there was the confusing word "ACCURACY" I wrote. As you said, it's just the probabilities calculated from the Softmax function. What I wanted to tell you was that I got the lower probabilities when I used test.bin than indata.bin.

Anyway, since the result of top-1 class is equivalent to "207", I don't care any problem to use the code I removed comments when I use new images converted by the code I uploaded, do I?

Regards Sujin

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

snxoxopy commented 6 years ago

It's very nice of you to say so. Thank you, David!