Catalog PyPI
Back to packageRELEASE DETAILS

0.1.1

PyPI

advhash

Adversarial attacks for perceptual image hashing functions

adversarialattackshashingimage
Published31 Jul 2021
Direct dependencies3
Transitive dependenciesNot calculated

README

Version 0.1.1 documentation

AdvHash: Adversarial collision attacks on perceptual hashing functions

CircleCI codecov.io PyPI Version Python Version License: GPL v3

Summary

AdvHash is a Python package that provides a simple to use interface for performing adversarial collision attacks on perceptual hashing functions.

PyTorch is used to re-create the target hashing functions and generating adversarial examples. AdvHash supports both CPU and GPU computations. Install the CUDA enabled version of PyTorch to use a GPU with AdvHash and specify device='cuda' when instantiating an attack or hash.

Adversarial collision attacks on image hashing functions

Adversarial cat Currently AdvHash supports collision attacks on hashing functions from the popular imagehash package using methods described in Adversarial collision attacks on image hashing functions.

Components

AdvHash is divided into multiple granular components:

ComponentDescription
advhasha PyTorch based library for performing adversarial attacks
advhash.attackadversarial attack methods
advhash.hashperceptual hashing functions
advhash.utilsutility functions for performing common resizing, conversion, and comparison operations

Getting Started

Installation

pip install advhash

*Install a CUDA enabled version of PyTorch to use a GPU with AdvHash.

Example Usage

This example shows how the L2Attack can be used to perform an adversarial collision attack on dHash using the resize method as the target split point.

import torch
import numpy as np
from PIL import Image
from advhash.attack.l2 import L2Attack

target_img = Image.open('forest.jpg')
source_img = Image.open('cat.jpg')

target = torch.tensor((np.array(target_img).astype('float32')))
source = torch.tensor((np.array(source_img).astype('float32')))

l2 = L2Attack(hash_fn='dhash', split_point='resize')

im_adv = l2.attack(target, source)

Attacks

Collision Attacks for Image Hashing

  • advhash.attack.l2.L2Attack
  • advhash.attack.hinge.HingeAttack

The above attacks accept a source image, target image, and hashing function as an input. The source image will be perturbed to create an adversarial image that has the same hash as the target image when hashed by the selected hashing function. Some attacks require additional configuration.

Hashing Functions

Future Development

Hashing Functions

  • pHash
  • aHash
  • pqd

Attack Methods

  • TBD

Defense Methods

  • TBD

Contributing

Contributions are welcome! If you plan to contribute new features, methods, or enhancements, please open an issue to discuss the addition further, or comment on an existing issue.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
torch
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.5",
  "evaluation": "NOT_EVALUATED"
}
torch (>=1.8.1)runtime
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.5",
  "evaluation": "NOT_EVALUATED"
}
numpy (>=1.19.2)runtime
tqdm
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.5",
  "evaluation": "NOT_EVALUATED"
}
tqdm (==4.61.0)runtime

Distribution files

2 collected
advhash-0.1.1-py3-none-any.whl

bdist_wheel · 25.2 KB · Python py3

Source file
advhash-0.1.1.tar.gz

sdist · 22.73 KB · Python source

Source file

Repository

PENDING
mattpodolak/advhash

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:03 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:2e2044657af82fcb4a3b86fdfd4325d395bb31f6363384dc231e2ebb3eb42cee

Other collected versions

View all collected versions →