ares.defense package

class ares.defense.bit_depth_reduction.BitDepthReduction(device='cuda', compressed_bit=4)[source]

Bases: object

Bit depth reduction defense method.

__init__(device='cuda', compressed_bit=4)[source]
Parameters:
  • device (torch.device) – The device to perform autoattack. Defaults to ‘cuda’.

  • compressed_bit (int) – The compressed bit.

bit_depth_reduction(xs)[source]
class ares.defense.jpeg_compression.Jpeg_compression(device='cuda', quality=75)[source]

Bases: object

JPEG compression defense method.

__init__(device='cuda', quality=75)[source]
Parameters:
  • device (torch.device) – The device to perform autoattack. Defaults to ‘cuda’.

  • quality (int) – The compressed image quality.

jpegcompression(x)[source]
class ares.defense.randomization.Randomization(device='cuda', prob=0.8, crop_lst=[0.1, 0.08, 0.06, 0.04, 0.02])[source]

Bases: object

Random input transform defense method.

__init__(device='cuda', prob=0.8, crop_lst=[0.1, 0.08, 0.06, 0.04, 0.02])[source]
Parameters:
  • device (torch.device) – The device to perform autoattack. Defaults to ‘cuda’.

  • prob (float) – The probability of input transform.

  • crop_lst (list) – The list of the params of crop method.

input_transform(xs)[source]
random_resize_pad(xs)[source]