-
Notifications
You must be signed in to change notification settings - Fork 547
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
Different sizes of the same image give different results #906
Comments
Good question! There are a few factors to calculate into account. All images are resized for you to the same square. For inception it is 299x299. Given that your images are roughly the same dimensions, this shouldn't affect it too much. The resizing should be the same using a Bilinear Resize. I do know Inception is more attracted to details than other models, so it might be more sensitive. Can you try other models for me? If you resize your input images to 299x299 with bilinearresize, we can look at see if there are any major visual differences between them. |
Thank you for the reply. I was now going to test the images in different models as you asked. I'm not sure why, but when I test the same images in https://nsfwjs.com/ , with the same InceptionV3, I get different results... 1365 × 2048:
480 × 720:
I confirm the model files I'm using are exactly the same as the ones hosted in this repository. In my NodeJS script, I'm basically getting the image in a bytes array, then:
Which seems to match what is in the I sent the two images (big and small) to your gant@i*******.r** email, if you'd like to have a look! Many thanks!! |
I think this can be considered expected behaviour within the margin of error. When you resize an image, it loses some of the data as the number of pixels is now much less. This is how images work, hence why SVGs are a thing. In fact, you could try converting an image from PNG to JPEG or vice versa and you'll still see a slight difference. Anything that changes the file size of the image changes some of its details ever so slightly. In your case, you are resizing it by about 2.84 times which is quite a large size difference that would make the result slightly different. Although in your case the difference is about 6% typically it'll be 1% - 2% in my testing which I consider to be within the margin of error. You could maybe try using
FYI, on the website https://nsfwjs.com, it directly passes the image to the |
@haZya - Thank you very much for providing me the code for using I understand your explanation as well, regarding why the values are different in the website, and why the different sizes can make a difference. 👍🏻 |
Hey!
As per #253,
So, I'm confused why providing different sizes (keeping the aspect ratio) of a JPG brings me totally different outputs.
On this specific image I'm testing with (6794873 for my own reference), if I provide a 1365 × 2048 version of the image, it gives me:
But if I provide a resized version of it (480 × 720), it gives me:
To me, the output provided by the larger image is much more accurate, than the second output.
If anything, I'd give a higher
sexy
score, as there isn't anyporn
in the image (unless the lady in the image is an actress or so, I've no idea).But still, I'm not understanding why different sizes of the same image are giving such different results.
I tested with several other images, and the results do vary in all of them. Sometimes very close, sometimes very far (like this one).
Is there any expectancy to give the largest image possible to this API, for more accurate results, or the smaller, the better?
Using InceptionV3.
Many thanks!
The text was updated successfully, but these errors were encountered: