|
| 1 | + |
| 2 | +# Examples |
| 3 | + |
| 4 | +The general command format for running a benchmark is: |
| 5 | +```bash |
| 6 | +thunder benchmark <MODEL> <DATASET> <TASK> [OPTIONS] |
| 7 | +``` |
| 8 | + |
| 9 | +In the following examples, we illustrate how to use THUNDER through both the **command-line interface (CLI)** and the **Python API**. |
| 10 | +As example, we will use **Hoptimus1** as the model, **MHIST** as the classification dataset, and **PanNuke** for segmentation. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## 1. View Benchmark Help |
| 15 | + |
| 16 | +### **CLI** |
| 17 | + |
| 18 | +```bash |
| 19 | +thunder benchmark --help |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 2. Download Datasets |
| 25 | + |
| 26 | +### **CLI** |
| 27 | + |
| 28 | +```bash |
| 29 | +thunder download-datasets mhist pannuke |
| 30 | +``` |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## 3. Generate Data Splits |
| 35 | + |
| 36 | +### **CLI** |
| 37 | + |
| 38 | +```bash |
| 39 | +thunder generate-data-splits pannuke mhist |
| 40 | +``` |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## 4. Download Pretrained Models |
| 45 | + |
| 46 | +### **CLI** |
| 47 | + |
| 48 | +```bash |
| 49 | +thunder download-models hoptimus1 |
| 50 | +``` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +# Benchmarking Examples |
| 55 | + |
| 56 | +Below are examples for multiple tasks using the **Hoptimus1** model. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Pre-computing Embeddings |
| 61 | + |
| 62 | +### **CLI** |
| 63 | + |
| 64 | +```bash |
| 65 | +thunder benchmark hoptimus1 mhist pre_computing_embeddings |
| 66 | +thunder benchmark hoptimus1 pannuke pre_computing_embeddings |
| 67 | + |
| 68 | +``` |
| 69 | + |
| 70 | +### **API** |
| 71 | + |
| 72 | +```python |
| 73 | +from thunder import benchmark |
| 74 | + |
| 75 | +benchmark( |
| 76 | + "hoptimus1", |
| 77 | + dataset="mhist", |
| 78 | + task="pre_computing_embeddings", |
| 79 | +) |
| 80 | + |
| 81 | +benchmark( |
| 82 | + "hoptimus1", |
| 83 | + dataset="pannuke", |
| 84 | + task="pre_computing_embeddings", |
| 85 | +) |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 6. K-NN Classification |
| 91 | + |
| 92 | +### **CLI** |
| 93 | + |
| 94 | +```bash |
| 95 | +thunder benchmark hoptimus1 mhist knn |
| 96 | +``` |
| 97 | + |
| 98 | +### **API** |
| 99 | + |
| 100 | +```python |
| 101 | +from thunder import benchmark |
| 102 | + |
| 103 | +benchmark( |
| 104 | + "hoptimus1", |
| 105 | + dataset="mhist", |
| 106 | + task="knn", |
| 107 | +) |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## 7. Linear Probing |
| 113 | + |
| 114 | +Using pre-loaded embeddings. |
| 115 | + |
| 116 | +### **CLI** |
| 117 | + |
| 118 | +```bash |
| 119 | +thunder benchmark hoptimus1 mhist linear_probing --loading-mode=embedding_pre_loading |
| 120 | +``` |
| 121 | + |
| 122 | +### **API** |
| 123 | + |
| 124 | +```python |
| 125 | +from thunder import benchmark |
| 126 | + |
| 127 | +benchmark( |
| 128 | + "hoptimus1", |
| 129 | + dataset="mhist", |
| 130 | + task="linear_probing", |
| 131 | + loading_mode="embedding_pre_loading", |
| 132 | +) |
| 133 | +``` |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## 8. Segmentation (PanNuke) |
| 138 | + |
| 139 | +### **CLI** |
| 140 | + |
| 141 | +```bash |
| 142 | +thunder benchmark hoptimus1 pannuke segmentation --loading-mode=embedding_pre_loading |
| 143 | +``` |
| 144 | + |
| 145 | +### **API** |
| 146 | + |
| 147 | +```python |
| 148 | +from thunder import benchmark |
| 149 | + |
| 150 | +benchmark( |
| 151 | + "hoptimus1", |
| 152 | + dataset="pannuke", |
| 153 | + task="segmentation", |
| 154 | + loading_mode="embedding_pre_loading", |
| 155 | +) |
| 156 | +``` |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## 9. SimpleShot Classification |
| 161 | + |
| 162 | +### **CLI** |
| 163 | + |
| 164 | +```bash |
| 165 | +thunder benchmark hoptimus1 mhist simple_shot --loading-mode=embedding_pre_loading |
| 166 | +``` |
| 167 | + |
| 168 | +### **API** |
| 169 | + |
| 170 | +```python |
| 171 | +from thunder import benchmark |
| 172 | + |
| 173 | +benchmark( |
| 174 | + "hoptimus1", |
| 175 | + dataset="mhist", |
| 176 | + task="simple_shot", |
| 177 | + loading_mode="embedding_pre_loading", |
| 178 | +) |
| 179 | +``` |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## 10. Transformation Invariance |
| 184 | + |
| 185 | +### **CLI** |
| 186 | + |
| 187 | +```bash |
| 188 | +thunder benchmark hoptimus1 mhist transformation_invariance |
| 189 | +``` |
| 190 | + |
| 191 | +### **API** |
| 192 | + |
| 193 | +```python |
| 194 | +from thunder import benchmark |
| 195 | + |
| 196 | +benchmark( |
| 197 | + "hoptimus1", |
| 198 | + dataset="mhist", |
| 199 | + task="transformation_invariance", |
| 200 | +) |
| 201 | +``` |
| 202 | + |
| 203 | +--- |
| 204 | + |
| 205 | +## 11. Adversarial Attack Robustness |
| 206 | + |
| 207 | +### **CLI** |
| 208 | + |
| 209 | +```bash |
| 210 | +thunder benchmark hoptimus1 mhist adversarial_attack |
| 211 | +``` |
| 212 | + |
| 213 | +### **API** |
| 214 | + |
| 215 | +```python |
| 216 | +from thunder import benchmark |
| 217 | + |
| 218 | +benchmark( |
| 219 | + "hoptimus1", |
| 220 | + dataset="mhist", |
| 221 | + task="adversarial_attack", |
| 222 | +) |
| 223 | +``` |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +# 12. Results Summary |
| 228 | + |
| 229 | +### **CLI** |
| 230 | + |
| 231 | +To display all collected benchmark results, simply run the command below after your experiments have finished. |
| 232 | + |
| 233 | +```bash |
| 234 | +thunder results-summary |
| 235 | +``` |
0 commit comments