File size: 649 Bytes
152228b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import typing

import bittensor as bt

from perturbnet.constants import MODEL_NAME


class AttackChallenge(bt.Synapse):
    """
    Validator -> Miner challenge payload.

    Miner output is only `perturbed_image_b64`.
    """

    task_id: str
    model_name: str = MODEL_NAME
    clean_image_b64: str
    true_label: str
    epsilon: float = 0.12
    norm_type: str = "Linf"
    min_delta: float = 0.002
    timeout_seconds: int = 60

    # Miner response payload.
    perturbed_image_b64: typing.Optional[str] = None

    def deserialize(self) -> typing.Optional[str]:
        return self.perturbed_image_b64