-
Notifications
You must be signed in to change notification settings - Fork 32
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
Hash given here differs from hash in nnhash.py? #4
Comments
Thank you for opening this issue. A couple things contribute to the bug you described. One is that the optimization represents images with 32-bit floats per channel, whereas the saved image has 8 bits per channel. The adversarial example that is found is not necessarily "robust", so quantization could cause slight changes in the hash output. Another issue was that there was a bug in the code, where it did the gradient descent update step before saving the image, so the hash that as computed during the forward pass was not the hash of the saved image. These two issues should be fixed in 3cc3c19. With those changes, the issue is fixed with your example. $ python collide.py --image picard.png --target e34b2da852103c3c0828fbd1
...
iteration: 216/1000, best: 0, hash: e34b2da852103c3c0828fbd1, distance: 0, loss: 7.517
...
$ python nnhash.py out_iter=00216_dist=00.png
e34b2da852103c3c0828fbd1 For more on the topic of robust adversarial examples, you could take a look at this blog post or this paper. If I have some free time this weekend, I could try incorporating those techniques into this repo and maybe also address some of the other limitations mentioned in the README. |
Can confirm, this has fixed the issue, I'll close it. Thanks for your swift and helpful reply! =) |
By the way, I've implemented a couple of those techniques I mentioned above, so you can get a slightly nicer looking image now. See here for examples: https://github.com/anishathalye/neural-hash-collider#examples |
Very cool, thanks for the update! |
I have the following two images:
I then ask
nnhash.py
from AsuharietYgvar/AppleNeuralHash2ONNX for the NeuralHash of the second picture (as instructed by the README in this repo) and get a result.I then run the collider as instructed with that result as target hash and seem to find a collision:
Seems like everything worked fine, the hash displayed is equal to the target!
But! If I now run
nnhash.py
on one of the saved pictures, it gives me a slightly different hash than the target?e34b2da852103c3c0828fbd1
e24b2da85210343c0828fbd1
Is this expected behaviour that I don't understand? Do the two bytes not make a difference, somehow? Or is this only producing near-collisions instead of proper collisions?
The text was updated successfully, but these errors were encountered: