MCPcopy Create free account
hub / github.com/Trustworthy-AI-Group/TransferAttack / preprocess

Function preprocess

transferattack/generation/diffattack.py:352–357  ·  view source on GitHub ↗
(image, res=512)

Source from the content-addressed store, hash-verified

350 return out.cpu() if is_cpu else out
351
352def preprocess(image, res=512):
353 image = image.resize((res, res), resample=Image.LANCZOS)
354 image = np.array(image).astype(np.float32) / 255.0
355 image = image[None].transpose(0, 3, 1, 2)
356 image = torch.from_numpy(image)[:, :3, :, :].cuda()
357 return 2.0 * image - 1.0
358
359
360def encoder(image, model, res=512):

Callers 2

diffattackMethod · 0.85
encoderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected