File size: 4,521 Bytes
3b5d050
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Perturb v15 2000 图回测与离线优化完整数据集

本数据集包含 Perturb 子网 v15 在线攻击在 ImageNet-100 上 2000 张图的**完整图片 + 分数**,以及三轮离线预计算优化后的**最优对抗样本 + 分数**。

## 完成内容

1. **v15 在线攻击 2000 图基准**
   - 2000 张原图 (`*_clean.png`)
   - 2000 张 v15 对抗样本 (`*_adv.png`)
   - 每张图对应完整评分 JSON
   - 使用真实 validator `verify_and_score` 打分

2. **离线预计算优化**
   - 对 1198 张低分图进行离线优化
   - 保存每张图的最优离线对抗样本
   - 离线配置:v15@60s/120s + v13@60s/120s

3. **统一分数映射表**
   - 每张图的在线分数、离线最优分数、最终最佳分数
   - 对应图片文件路径

## 核心结果

| 阶段 | 2000 图平均分 | 提升 |
|------|--------------|------|
| 纯在线 v15 @25s | **0.9295** | baseline |
| 离线优化后最佳 | **0.9458** | **+0.0163** |

离线处理覆盖:1198 / 2000 张图

## 目录结构

```text
perturb_complete_package/
├── README.md                      # 本文件
├── REPORT.md                      # 详细迭代报告
├── upload_to_hf.py                # 上传到 HuggingFace 脚本
├── scripts/                       # 使用的脚本
│   ├── benchmark_2000.py
│   ├── offline_low_score_ensemble.py
│   ├── run_benchmark_workers.py
│   └── monitor_benchmark_feishu.py
├── scores/                        # 分数映射表
│   ├── v15_online_2000.json       # 2000 张 v15 在线分数 + 图片路径
│   ├── offline_best_2000.json     # 2000 张最终最佳分数 + 在线/离线图片路径
│   └── offline_processed_indices.json  # 哪些图做了离线优化
├── images/                        # 图片文件
│   ├── v15_online/                # 2000 张 clean + 2000 张 adv
│   │   ├── 0000000_clean.png
│   │   ├── 0000000_adv.png
│   │   └── ...
│   └── offline_best/              # 1198 张最优离线 adv
│       ├── 0000000_adv.png
│       └── ...
└── comparisons/                   # 108 张最困难图可视化对比
    ├── comparison.json
    ├── comparison.csv
    └── offline_comparison_images/
        ├── 00046679/
        │   ├── clean.png
        │   ├── online_adv.png
        │   └── offline_adv.png
        └── ...
```

## 分数文件格式

### `scores/v15_online_2000.json`

```json
{
  "count": 2000,
  "avg_score": 0.9295,
  "records": [
    {
      "ds_idx": 64135,
      "online_score": 0.9267,
      "v15_clean_image": "images/v15_online/0064135_clean.png",
      "v15_adv_image": "images/v15_online/0064135_adv.png",
      "norm": 0.00392,
      "rmse": 0.00272,
      "ssim": 0.9974,
      "margin": 5.19,
      "reason": "success",
      "attack_path": "v15_online/reservoir_t318",
      "time": 23.1
    }
  ]
}
```

### `scores/offline_best_2000.json`

```json
{
  "count": 2000,
  "online_avg": 0.9295,
  "offline_avg": 0.9458,
  "improvement": 0.0163,
  "records": [
    {
      "ds_idx": 64135,
      "online_score": 0.9267,
      "offline_score": 0.9501,
      "best_score": 0.9501,
      "v15_clean_image": "images/v15_online/0064135_clean.png",
      "v15_adv_image": "images/v15_online/0064135_adv.png",
      "offline_best_image": "images/offline_best/0064135_adv.png",
      "improved_by_offline": 0.0234,
      "offline_best_config": "v15@120.0s"
    }
  ]
}
```

## 环境要求

- Python 3.10+
- PyTorch 2.8.0+cu128
- bittensor==10.5.0
- datasets, pillow, numpy, requests, huggingface_hub

## 如何复现

```bash
# 1. 运行 v15 在线 benchmark
python scripts/benchmark_2000.py \
  --n 2000 --attack v15 --budget 25 \
  --output-dir benchmark_2000 --workers 4

# 2. 运行离线优化
python scripts/offline_low_score_ensemble.py \
  --online-dir benchmark_2000 \
  --indices-file low_score_indices.json \
  --output-dir offline_result \
  --workers 4 --configs v15:120 v13:120
```

## 上传到 HuggingFace

```bash
export HF_TOKEN=your_token
python upload_to_hf.py \
  --repo-id your-username/perturb-v15-benchmark \
  --zip-path perturb_complete_package_v20260821.zip \
  --create-repo
```

## 引用

- 攻击代码:`perturbnet/attacks/v15_online.py`
- 评分逻辑:`neurons/validator.py` 中的 `verify_and_score`
- 数据集:`clane9/imagenet-100` train split

详细分析参见 `REPORT.md`。