File size: 6,802 Bytes
b6d508c | 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 | ---
pretty_name: DD1 Cropped PB VQA Classification
tags:
- visual-question-answering
- image-classification
- industrial
- additive-manufacturing
- sft
task_categories:
- visual-question-answering
- image-classification
---
# DD1 Cropped PB VQA Classification
Answer-only VQA/SFT binary classification data derived from
`Croped Defects/PB`. This is a patch-classification dataset, not an
object-detection dataset. Each record asks the model to answer exactly `good`
or `defect`.
## Source and construction
- Source: `/Users/duoduo/Downloads/research/DD1-Annotated Image Dataset for defects detection in Laser Powder Bed Fusion/Croped Defects/PB`
- Source images: 1108 Good full frames and
1530 Defects crops
- Original Good geometry: 1280x1024
- Retained Defects crops: 1399
- Excluded Defects crops: 131
- Paired Good crops generated: 1399
- Final records: 2798
Defects crops with either side below 32 pixels
are excluded. Their source path, dimensions, reason, split and split group are
stored in `excluded_defects.jsonl`.
For every retained Defects crop, the builder creates one Good crop with exactly
the same width and height. Candidate Good sources are restricted to the same
build and split. It evaluates
12 deterministic random crops and
selects the candidate whose coarse grayscale mean and standard deviation most
closely match the Defects crop.
The PB source has a channel-format mismatch: Good full frames are grayscale,
while nearly all Defects crops are RGB. Both labels are converted to RGB and
re-encoded using the same Pillow JPEG pipeline: quality
95, 4:4:4 subsampling, non-progressive.
This removes source channel/encoder configuration as a direct label cue,
although JPEG byte size may still reflect genuine visual complexity.
Thirty fixed English query templates are assigned deterministically from the
derived image SHA-256. The complete list is in `query_templates.json`.
## Schema
| field | type | meaning |
|---|---|---|
| `query` | string | one of 30 deterministic classification prompts |
| `image` | Image | JPEG bytes embedded in Parquet |
| `annot` | string | exact gold answer: `good` or `defect` |
| `reasoning` | null | answer-only dataset |
| `cate` | string | `C` |
| `task` | string | `T-C1` |
| `metadata` | string | JSON provenance, geometry, crop, hash and split |
`annot` is the direct SFT answer and `reasoning` is null on every row.
## Split counts
| split | good | defect | total |
|---|---:|---:|---:|
| train | 1131 | 1131 | 2262 |
| validation | 111 | 111 | 222 |
| test | 157 | 157 | 314 |
Adjacent layer IDs are grouped into blocks of
20 before deterministic split hashing.
All images derived from a split group remain in one split. Validation confirms
that no split group appears in multiple splits.
## Shortcut control
- Good and Defect labels are balanced in every split.
- Every pair has identical width, height, area and aspect ratio.
- Good crops use the same build and split as their geometry template.
- Both labels use the same RGB/JPEG encoding pipeline.
- Exact derived-image duplicates are rejected.
- Source hashes, derived hashes, crop coordinates and pair IDs are retained.
These controls remove the original full-frame-versus-crop size shortcut and
the PB grayscale-versus-RGB shortcut. They do not prove that every background
or border correlation is causal. A dedicated PB nuisance-feature audit is not
included in this release. Before deployment, evaluate classifiers based only
on outer-border/global statistics and test random crop translation, context
expansion, padding and defect occlusion.
## Training input contract
Use only `query` and decoded image pixels as model input. Use `annot` as the
target.
Do not serialize `image.path` or `metadata` into the prompt. The embedded image
path and provenance metadata intentionally contain source/condition information
for auditing and can reveal the label to a text model. If a training framework
automatically exposes paths, replace them with neutral hash-based names first.
## Metadata
`metadata` is a JSON string containing:
- dataset identity: `schema_version`, `family`, `representation`, `modality`
- label/provenance: `condition`, `source_file`, `derivation`,
`geometry_template`
- geometry: `image_width`, `image_height`, `aspect_ratio`,
`crop_xywh_in_good_source`
- grouping: `build_id`, `layer_id`, `split`, `split_group`, `pair_id`
- integrity: `source_sha256`, `image_sha256`
- generation: `query_variant`, `jpeg_reencoded`, `jpeg_quality`,
`jpeg_subsampling`, `appearance_match_distance`, `appearance_candidates`
- policy: `reasoning_policy`, `label_scope`
## Files
- `data/train-00000-of-00001.parquet`
- `data/validation-00000-of-00001.parquet`
- `data/test-00000-of-00001.parquet`
- `build_dd1_cropped_pb_vqa.py`: reproducible builder
- `build_report.json`: parameters, counts, SHA-256 values and validation result
- `excluded_defects.jsonl`: rejected source crops and rejection reasons
- `query_templates.json`: all 30 deterministic prompts
- `requirements.txt`: pinned build dependencies
- `README.md`: this document
## Load
```python
from datasets import load_dataset
ds = load_dataset(
"parquet",
data_files={
"train": "data/train-00000-of-00001.parquet",
"validation": "data/validation-00000-of-00001.parquet",
"test": "data/test-00000-of-00001.parquet",
},
)
```
Example SFT mapping:
```python
record = ds["train"][0]
model_input = {
"query": record["query"],
"image": record["image"],
}
target = record["annot"]
```
## Reproduce
```bash
python3 -m pip install -r requirements.txt
python3 build_dd1_cropped_pb_vqa.py \
--source /path/to/Croped\ Defects/PB \
--output /path/to/DD1_PB_VQA_classification
```
The build is deterministic and refuses to overwrite an existing output.
## Validation
The builder and an independent post-build check verify:
- exact seven-column order
- embedded, decodable JPEG bytes
- RGB output and stored dimensions
- balanced labels in every split
- complete Good/Defect pairs with identical geometry and split
- `annot`/`metadata.condition` consistency
- `cate=C`, `task=T-C1`, `reasoning=null`
- unique derived-image SHA-256 values
- no split-group overlap
- Parquet SHA-256 values recorded in `build_report.json`
## Limitations
- `good` and `defect` inherit the source folder labels; `good` does not prove
absence of every possible manufacturing anomaly.
- Defects and Good images still originate from different crop-generation
histories, so border/background correlations may remain.
- A Good full frame may supply more than one crop, always within one split.
- Crops below the legibility threshold are intentionally omitted.
- This dataset supports binary classification; it does not provide a
localization answer.
|