| """Configuration for NAPGuard Patch Detector model.""" | |
| from transformers import PretrainedConfig | |
| class NAPGuardPatchDetectorConfig(PretrainedConfig): | |
| """Config for NAPGuard patch detector that accepts PIL images directly. | |
| Reference: Wu et al., CVPR 2024, "NAPGuard: Detecting Naturalistic | |
| Adversarial Patches" | |
| """ | |
| model_type = "napguard-patch-detector" | |
| def __init__( | |
| self, | |
| input_size: int = 416, | |
| conf_thres: float = 0.1, | |
| iou_thres: float = 0.45, | |
| use_nfsi: bool = True, | |
| nfsi_sigma: float = 3.0, | |
| nfsi_threshold_factor: float = 2.0, | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.input_size = input_size | |
| self.conf_thres = conf_thres | |
| self.iou_thres = iou_thres | |
| self.use_nfsi = use_nfsi | |
| self.nfsi_sigma = nfsi_sigma | |
| self.nfsi_threshold_factor = nfsi_threshold_factor | |