-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun_DAG.py
46 lines (37 loc) · 1.24 KB
/
run_DAG.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import argparse
from detectron2.config import get_cfg
from detectron2_1.adv import DAGAttacker
from detectron2 import model_zoo
from detectron2_1.datasets import BenignMapper
def main(args):
print("Preparing config file...")
cfg = get_cfg()
cfg.merge_from_file(args.cfg_path)
cfg.MODEL.WEIGHTS = args.weights_path
print("Initializing attacker...")
# Using custom DatasetMapper
attacker = DAGAttacker(cfg, mapper=BenignMapper)
print("Start the attack...")
coco_instances_results = attacker.run_DAG(
results_save_path=args.results_save_path, vis_save_dir=args.vis_save_dir
)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--cfg-path",
required=True,
help="Path to configuration file used to train the model",
)
parser.add_argument("--weights-path", required=True, help="Path to model weights")
parser.add_argument(
"--results-save-path",
required=True,
help="Path to save the prediction results as a JSON file",
)
parser.add_argument(
"--vis-save-dir",
required=False,
help="Directory to save visualized bbox prediction images",
)
args = parser.parse_args()
main(args)