|
|
@@ -21,21 +21,21 @@ from mindspore.dataset.vision.py_transforms import ToTensor |
|
|
|
import mindspore.dataset.vision.py_transforms as P |
|
|
|
from mindspore.dataset.vision.py_transforms import ToPIL as ToPILImage |
|
|
|
from FaceRecognition.eval import get_net |
|
|
|
import AFR |
|
|
|
import adversarial_attack |
|
|
|
|
|
|
|
context.set_context(mode=context.GRAPH_MODE, device_target="GPU") |
|
|
|
|
|
|
|
|
|
|
|
imageize = ToPILImage() |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
""" |
|
|
|
The input image, target image and adversarial image are tested using the FaceRecognition model. |
|
|
|
""" |
|
|
|
|
|
|
|
image = AFR.load_data('photos/adv_input/') |
|
|
|
inputs = AFR.load_data('photos/input/') |
|
|
|
targets = AFR.load_data('photos/target/') |
|
|
|
image = adversarial_attack.load_data('photos/adv_input/') |
|
|
|
inputs = adversarial_attack.load_data('photos/input/') |
|
|
|
targets = adversarial_attack.load_data('photos/target/') |
|
|
|
|
|
|
|
tensorize = ToTensor() |
|
|
|
normalize = P.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) |
|
|
@@ -45,9 +45,8 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
resnet = get_net() |
|
|
|
|
|
|
|
image = mp.imread("./outputs/adversarial_example.jpg") |
|
|
|
adv = Tensor(normalize(tensorize(image))) |
|
|
|
|
|
|
|
|
|
|
|
adv = Tensor(normalize(tensorize(image[0]))) |
|
|
|
input_tensor = Tensor(normalize(tensorize(inputs[0]))) |
|
|
|
target_tensor = Tensor(normalize(tensorize(targets[0]))) |
|
|
|
|
|
|
|