コード例 #1
0
def main():
    if not os.path.exists(args.output):
        os.makedirs(args.output)
    model, img_shape = getmodel(args.model)
    attacker = attack.Evolutionary(
        model=model,
        goal=args.goal,
        distance_metric=args.distance,
        max_queries=args.iters,
        threshold=threshold[args.model]['cos'],
    )
    path = os.path.join('data', 'cfp-{}x{}'.format(img_shape[0], img_shape[1]))
    Attacker = lambda xs, ys, pairs: attacker.batch_attack(xs, ys, pairs=pairs)
    run_white(path, Attacker, model, args, threshold[args.model]['cos'])
コード例 #2
0
def main():
    model, img_shape = getmodel(args.model)
    config = {
        'eps': args.eps,
        'method': attack.FGSM,
        'goal': args.goal,
        'distance_metric': args.distance,
        'threshold': threshold_cfp[args.model]['cos'],
        'steps': args.steps,
        'bin_steps': args.bin_steps,
        'model': model,
    }

    path = os.path.join('data', 'cfp-{}x{}'.format(img_shape[0], img_shape[1]))
    Attacker = lambda xs, ys, pairs: binsearch_basic(
        xs=xs, ys=ys, pairs=pairs, **config)
    run_white(path, Attacker, model, args, threshold_cfp[args.model]['cos'])
コード例 #3
0
def main():
    if not os.path.exists(args.output):
        os.makedirs(args.output)
    model, img_shape = getmodel(args.model)
    attacker = attack.CW(model=model,
        goal=args.goal, 
        distance_metric=args.distance, 
        iteration=args.iters,
        threshold=threshold_cfp[args.model]['cos'],
        search_steps=args.steps,
        binsearch_steps=args.bin_steps,
        confidence=args.confidence,
        learning_rate=args.lr,
        c=args.c
    )
    path = os.path.join('data', 'cfp-{}x{}'.format(img_shape[0], img_shape[1]))
    Attacker = lambda xs, ys, pairs: attacker.batch_attack(xs, ys, pairs=pairs)
    run_white(path, Attacker, model, args, threshold_cfp[args.model]['cos'])
コード例 #4
0
def main():
    if not os.path.exists(args.output):
        os.makedirs(args.output)
    model, img_shape = getmodel(args.model)
    config = {
        'eps': args.eps,
        'method': attack.MIM,
        'goal': args.goal,
        'distance_metric': args.distance,
        'threshold': threshold_cfp[args.model]['cos'],
        'steps': args.steps,
        'bin_steps': args.bin_steps,
        'model': model,
        'mu': args.mu,
        'iters': args.iters,
    }
        
    path = os.path.join('data', 'cfp-{}x{}'.format(img_shape[0], img_shape[1]))
    Attacker = lambda xs, ys, pairs: binsearch_alpha(xs=xs, ys=ys, pairs=pairs, **config)
    run_white(path, Attacker, model, args, threshold_cfp[args.model]['cos'])