Implementation:Norrrrrrr lyn WAInjectBench Image Folder Data Schema
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Computer_Vision |
| Last Updated | 2026-02-14 16:00 GMT |
Overview
Concrete data schema for image-based prompt injection benchmark folders used by the WAInjectBench image detection pipeline.
Description
Image data is organized as numbered image files within scenario subfolders, nested under benign/ and malicious/ parent directories. The pipeline iterates subfolders via parent_path.iterdir() and counts files via folder_path.glob("*").
Usage
Prepare image data in this folder structure before running any image detector. The --data_dir argument (default "data/image") points to the root directory.
Code Reference
Source Location
- Repository: WAInjectBench
- File: data/image/ (data layout), main_image.py (L77-84 for folder discovery)
Signature
# Folder discovery in main_image.py
for folder_name in ["benign", "malicious"]:
parent_path = data_dir / folder_name
for sub_folder in parent_path.iterdir():
if sub_folder.is_dir():
res = process_folder(sub_folder, detector, detector_name,
is_malicious=(folder_name == "malicious"))
Import
from pathlib import Path
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Image folders | Directory | Yes | Subfolders containing numbered image files |
| Directory structure | Filesystem | Yes | benign/ and malicious/ parent directories |
Outputs
| Name | Type | Description |
|---|---|---|
| Subfolder paths | List[Path] | Discovered scenario folders from iterdir() |
| is_malicious flag | bool | Derived from parent directory name |
| total_num | int | Count of files via glob("*") |
Usage Examples
Directory Layout
data/image/
├── benign/
│ ├── normal_photos/
│ │ ├── 1.png
│ │ ├── 2.jpg
│ │ └── 3.png
│ └── documents/
│ ├── 1.png
│ └── 2.png
└── malicious/
├── text_overlay_attack/
│ ├── 1.png
│ ├── 2.png
│ └── 3.png
└── steganographic_attack/
├── 1.png
└── 2.png
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment