Spaces:
Sleeping
Sleeping
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! π
|