File size: 8,348 Bytes
be5c319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# πŸ–ΌοΈ Example Images for Testing

This directory contains sample images for testing the ViT Auditing Toolkit across different analysis types.

## πŸ“ Directory Structure

```
examples/
β”œβ”€β”€ basic_explainability/    # Images for testing prediction and explanation
β”œβ”€β”€ counterfactual/          # Images for robustness testing
β”œβ”€β”€ calibration/             # Images for confidence calibration
β”œβ”€β”€ bias_detection/          # Images for bias analysis
└── general/                 # General test images
```

## 🎯 Recommended Test Images by Tab

### Tab 1: Basic Explainability (πŸ”)
**Purpose**: Test prediction accuracy and explanation quality

**Recommended Images**:
- **Clear single objects**: Cat, dog, car, bird (high confidence predictions)
- **Complex scenes**: Multiple objects, cluttered backgrounds
- **Ambiguous images**: Similar classes (husky vs wolf, muffin vs chihuahua)
- **Different angles**: Top view, side view, close-up

**Examples to add**:
```
basic_explainability/
β”œβ”€β”€ cat_portrait.jpg          # Clear cat face
β”œβ”€β”€ dog_playing.jpg           # Dog in action
β”œβ”€β”€ bird_flying.jpg           # Bird in flight
β”œβ”€β”€ car_sports.jpg            # Sports car
β”œβ”€β”€ multiple_objects.jpg      # Complex scene
β”œβ”€β”€ ambiguous_animal.jpg      # Hard to classify
└── unusual_angle.jpg         # Non-standard viewpoint
```

### Tab 2: Counterfactual Analysis (πŸ”„)
**Purpose**: Test prediction robustness and identify critical regions

**Recommended Images**:
- **Simple backgrounds**: Easy to see perturbation effects
- **Centered objects**: Better for patch analysis
- **Distinct features**: Eyes, wheels, wings (test if they're critical)
- **Varying complexity**: Simple to complex objects

**Examples to add**:
```
counterfactual/
β”œβ”€β”€ face_centered.jpg         # Test facial feature importance
β”œβ”€β”€ car_side_view.jpg         # Test wheel/door importance
β”œβ”€β”€ building_architecture.jpg # Test structural elements
β”œβ”€β”€ simple_object.jpg         # Baseline robustness test
└── textured_object.jpg       # Test texture vs shape
```

### Tab 3: Confidence Calibration (πŸ“Š)
**Purpose**: Test if model confidence matches accuracy

**Recommended Images**:
- **High quality**: Should have high confidence
- **Low quality**: Blurry, dark, pixelated
- **Edge cases**: Partial objects, occluded views
- **Various difficulties**: Easy to hard classifications

**Examples to add**:
```
calibration/
β”œβ”€β”€ clear_high_quality.jpg    # Should be high confidence
β”œβ”€β”€ slightly_blurry.jpg       # Medium confidence expected
β”œβ”€β”€ very_blurry.jpg           # Low confidence expected
β”œβ”€β”€ dark_lighting.jpg         # Test lighting robustness
β”œβ”€β”€ partial_object.jpg        # Occluded/cropped
└── mixed_quality_set/        # Batch of varied quality
```

### Tab 4: Bias Detection (βš–οΈ)
**Purpose**: Detect performance variations across subgroups

**Recommended Images**:
- **Same subject, different conditions**: Lighting, weather, seasons
- **Demographic variations**: Different breeds, ages, sizes
- **Environmental context**: Indoor vs outdoor, urban vs rural
- **Quality variations**: Professional vs amateur photos

**Examples to add**:
```
bias_detection/
β”œβ”€β”€ day_lighting.jpg          # Same scene in daylight
β”œβ”€β”€ night_lighting.jpg        # Same scene at night
β”œβ”€β”€ sunny_weather.jpg         # Clear conditions
β”œβ”€β”€ rainy_weather.jpg         # Poor conditions
β”œβ”€β”€ indoor_scene.jpg          # Controlled environment
β”œβ”€β”€ outdoor_scene.jpg         # Natural environment
└── subgroup_sets/            # Organized by demographic
    β”œβ”€β”€ lighting/
    β”œβ”€β”€ weather/
    β”œβ”€β”€ quality/
    └── environment/
```

## 🌐 Where to Get Test Images

### Free Image Sources (Royalty-Free)

1. **Unsplash** (https://unsplash.com)
   - High quality, free to use
   - Good for professional-looking tests
   ```bash
   # Example downloads
   curl -L "https://unsplash.com/photos/[photo-id]/download" -o image.jpg
   ```

2. **Pexels** (https://www.pexels.com)
   - Free stock photos and videos
   - Good variety of subjects

3. **Pixabay** (https://pixabay.com)
   - Free images and videos
   - Commercial use allowed

4. **ImageNet Sample** (https://image-net.org)
   - Validation set samples
   - Directly relevant to ViT training

### Quick Download Scripts

#### Download Sample Images
```bash
# Create directories
mkdir -p examples/{basic_explainability,counterfactual,calibration,bias_detection,general}

# Download sample cat image
curl -L "https://images.unsplash.com/photo-1574158622682-e40e69881006?w=800" \
  -o examples/basic_explainability/cat_portrait.jpg

# Download sample dog image
curl -L "https://images.unsplash.com/photo-1543466835-00a7907e9de1?w=800" \
  -o examples/basic_explainability/dog_portrait.jpg

# Download sample bird image
curl -L "https://images.unsplash.com/photo-1444464666168-49d633b86797?w=800" \
  -o examples/basic_explainability/bird_flying.jpg

# Download sample car image
curl -L "https://images.unsplash.com/photo-1583121274602-3e2820c69888?w=800" \
  -o examples/basic_explainability/sports_car.jpg
```

#### Use Your Own Images
```bash
# Simply copy your images to the appropriate directory
cp /path/to/your/image.jpg examples/basic_explainability/
```

## πŸ“‹ Image Requirements

### Technical Specifications
- **Format**: JPG, PNG, WebP
- **Size**: Any size (will be resized to 224Γ—224)
- **Color**: RGB (grayscale will be converted)
- **Quality**: Higher quality = better analysis

### Recommended Guidelines
- **Resolution**: At least 224Γ—224 pixels (higher is fine)
- **Aspect Ratio**: Any (will be center-cropped)
- **File Size**: < 10MB for faster upload
- **Content**: Clear, well-lit subjects work best

## πŸ§ͺ Testing Checklist

### Basic Testing
- [ ] Upload works for all image formats (JPG, PNG)
- [ ] Predictions are reasonable
- [ ] Visualizations render correctly
- [ ] Interface is responsive

### Tab-Specific Testing

#### Basic Explainability
- [ ] Attention maps show relevant regions
- [ ] GradCAM highlights correctly
- [ ] SHAP values make sense
- [ ] All layers/heads accessible

#### Counterfactual Analysis
- [ ] Perturbations are visible
- [ ] Sensitivity maps are informative
- [ ] All perturbation types work
- [ ] Metrics are calculated

#### Confidence Calibration
- [ ] Calibration curves render
- [ ] Metrics are reasonable
- [ ] Bin settings work correctly

#### Bias Detection
- [ ] Subgroups are compared
- [ ] Variations are generated
- [ ] Metrics show differences

## πŸ’‘ Tips for Good Test Images

### Do's βœ…
- Use clear, well-lit images
- Test with ImageNet classes the model knows
- Try edge cases and challenging examples
- Test with images from different sources
- Use consistent naming conventions

### Don'ts ❌
- Don't use copyrighted images (use free sources)
- Don't use extremely large files (> 50MB)
- Don't use corrupted or invalid image files
- Don't rely on a single image type

## 🎯 Creating Your Own Test Set

```bash
#!/bin/bash
# Script to organize your test images

# Create structure
mkdir -p examples/{basic_explainability,counterfactual,calibration,bias_detection}

# Organize by category
echo "Organizing images..."

# Move or copy your images to appropriate folders
# Rename for consistency
mv unclear_image.jpg examples/basic_explainability/01_cat.jpg
mv another_image.jpg examples/basic_explainability/02_dog.jpg

echo "βœ… Test image set ready!"
```

## πŸ“Š ImageNet Classes Reference

Common classes the ViT models can recognize (examples):

- **Animals**: cat, dog, bird, fish, horse, elephant, bear, tiger, etc.
- **Vehicles**: car, truck, bus, motorcycle, bicycle, airplane, boat, etc.
- **Objects**: chair, table, bottle, cup, keyboard, phone, book, etc.
- **Nature**: tree, flower, mountain, beach, forest, etc.
- **Food**: pizza, burger, cake, fruit, vegetables, etc.

See full list: https://github.com/anishathalye/imagenet-simple-labels

## πŸ”— Quick Links

- **Unsplash API**: https://unsplash.com/developers
- **Pexels API**: https://www.pexels.com/api/
- **ImageNet**: https://image-net.org/
- **COCO Dataset**: https://cocodataset.org/

---

**Ready to test?** Add your images to the appropriate directories and start analyzing! πŸš€