Skip to content

Compression defense against adversarial attacks in OCR systems

Notifications You must be signed in to change notification settings

ShiffnaMerza/ShieldOCR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DEFENSE OCR

Compression defense against adversarial attacks in OCR systems

Installation

1.Install all dependencies for the research component using the following command

pip install -r requirements.txt
Required: Tensorflow:1.14.0, Python

2.Install the node modules for frontend using command
npm install
Required: Nodejs, Angularcli version: 9.0.3

3.Install flask
pip install flask flask-jsonpify flask-sqlalchemy flask-restful
pip install -U flask-cors
Required: Python

Dataset

Synthetic data generator was used to generate dataset (TRDG) https://textrecognitiondatagenerator.readthedocs.io/en/latest/tutorial.html

Training data tested on: 72000 samples
Test data tested: 8000 images

Add data to data folder (both train/ test images)

Train Model

Train model running the python file with following arguments
python run.py --train -ex ../data/train

NOTE: The model will be saved in the form of tensorflow checkpoints. The checkpoints are saved in the folder CRNN/CRNN/model

Test Model for batches of images

To test the model the saved trained model should be loaded using following
python run.py -ex ../data/test --test --restore

Attack model for batches of images

To take place attack for batches of images and obtain predictions for research purposes.
python run.py -ex ../data/test --attack --restore

In addition attack parameters should be passed
Attack name = fgsm, attack_parameters = {eps: 8}

Defend model for batches of images

To take place defense for batches of images and obtain predictions for research purposes.
python run.py -ex ../out/attacked/batch --defend --restore

In addition defense parameters should be passed
Defense name = compr, defense_parameters = {quality: 50}

Frontend server

Run ng serve -o
Navigate to http://localhost:4200/

Backend server

Run app.py

NOTE: only a single image can be uploaded for experiments from the frontend. Here the parameters for the action (attack/defense/test) is passed from the frontend itself. Batches of image predictions can be tested by running the run.py file with the appropriate arguments

About

Compression defense against adversarial attacks in OCR systems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published