-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun.py
More file actions
26 lines (23 loc) · 929 Bytes
/
run.py
File metadata and controls
26 lines (23 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from GenoArmory import GenoArmory
import json
# You need to initialize GenoArmory with a model and tokenizer.
# For visualization, you don't need a real model/tokenizer, so you can use None if the method doesn't use them.
gen = GenoArmory(model=None, tokenizer=None)
params_file = '/projects/p32013/DNABERT-meta/scripts/PGD/pgd_dnabert.json'
# gen.visualization(
# folder_path='/projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test',
# output_pdf_path='/projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test'
# )
if params_file:
try:
with open(params_file, "r") as f:
kwargs = json.load(f)
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON in params file '{params_file}': {e}")
except FileNotFoundError:
raise FileNotFoundError(f"Params file '{params_file}' not found.")
gen.attack(
attack_method='pgd',
model_path='magicslabnu/GERM',
**kwargs
)