'line.py' and 'spot.py' contains code to generate adversarial samples with HLine, VLine and Spot respectively.
Download the dataset from this link or link .
Put the dataset inside the 'images/Segments_Sorted/' directory.
run 'ALPR.ipynb'
Configure 'data_path', and 'save_path' as necessary.
run 'main.py'
Configure 'mode', 'model_path', 'op_path, and 'output_path' as necessary.
The 'model_path' must be directed to the model intended to use.
To test the dataset on model
run 'AdversarialTraining.ipynb'
Configure 'save_path' as necessary.
run 'heatmap.py'
Configure 'model_path' and 'output_path' as necessary.
run 'gif_creation.py'
Consifure 'output_path'
Copy and paste code below at appropriate location in spot.py or line.py of which gif you want to create
pert_img = create_spot (img .copy (), center_i , radius , rgb )
pert_image = numpy_PIL_tensor (pert_img )
#Saving the perturbed image
output_path = 'outputs/gif3/'
output_file_name = f"{ radius } -{ center_i } .png"
os .makedirs (output_path , exist_ok = True )
pert_image = pert_image .view (3 , 160 , 105 )
save_image (pert_image , output_path + output_file_name )
Use the generated image to create gif from here .
Illustration of Adversarial Attack