DD1_3 / README.md
MoreGeometrico's picture
Upload folder using huggingface_hub
c2a13fd verified
|
Raw
History Blame Contribute Delete
6.79 kB
metadata
pretty_name: DD1 Cropped OT VQA Classification
tags:
  - visual-question-answering
  - image-classification
  - industrial
  - additive-manufacturing
  - sft
task_categories:
  - visual-question-answering
  - image-classification

DD1 Cropped OT VQA Classification

Answer-only VQA/SFT binary classification data derived from Croped Defects/OT. 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/OT
  • Source images: 1550 Good full frames and 1124 Defects crops
  • Original Good geometry: 2000x2000
  • Retained Defects crops: 1061
  • Excluded Defects crops: 63
  • Paired Good crops generated: 1061
  • Final records: 2122

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.

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 819 819 1638
validation 131 131 262
test 111 111 222

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. They do not prove that every background or border correlation is causal. An OT nuisance-feature audit found 50.0% test accuracy from geometry alone, 85.1% from outer-border statistics and 92.8% from global brightness/texture statistics. The latter measurements can contain genuine defect signal, but they also flag residual sensitivity to crop composition. For robust deployment, evaluate 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_ot_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

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:

record = ds["train"][0]
model_input = {
    "query": record["query"],
    "image": record["image"],
}
target = record["annot"]

Reproduce

python3 -m pip install -r requirements.txt
python3 build_dd1_cropped_ot_vqa.py \
  --source /path/to/Croped\ Defects/OT \
  --output /path/to/DD1_OT_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.