Skip to content

Image sorting

VelloSaurus edited this page Jul 4, 2026 · 1 revision

Image Sorting (Anomaly Detection)

Flags images whose predicted class doesn't match the expected category for that source folder. Two implementations:

Script Classifier Needs mapping file?
sort_images.py (deprecated/use clip instead) EfficientNet (classifier.py), ImageNet 1000-class softmax Yes — category_mapping.json
sort_images_clip.py CLIP (classifier_clip.py), zero-shot No — uses prompts.json

EfficientNet route (deprecated)

python3 preprocess/sort_images.py \
  --input-dir <src> --category "Recyclable Objects" \
  --output-dir <dest> --limit 500

Flags: --model (default efficientnet-b0), --mapping-file (default category_mapping.json), --min-confidence, --copy (copy instead of move).

Predicts the ImageNet class, looks it up in category_mapping.json to get a category, flags anomaly if the mapped category != --category or confidence < --min-confidence.

CLIP route (recommended)

python3 preprocess/sort_images_clip.py \
  --input-dir /path/to/RecyclableObjects \
  --category "Recyclable Objects" \
  --output-dir /path/to/sorted_result \
  --limit 500

Flags: --prompts-file (default prompts.json), --model (default ViT-B-32), --pretrained (default laion2b_s34b_b79k), --min-confidence, --copy.

Compares image embedding against averaged text-prompt embeddings per category in prompts.json; picks the best match directly — no ImageNet class mapping needed. To add a category, add a key + prompt list to prompts.json and rerun with --category "<NewCategory>".

Output structure (both scripts)

sorted_result/
  non_anomaly/
    Recyclable Objects/
    Electronic Objects/
    Organic Objects/
  anomaly/
    Recyclable Objects/
    Electronic Objects/
    Organic Objects/

Run once per source category folder, pointing --input-dir at each.

BDC Satria Data 2026


Competition


Pipeline


Quick Links

Clone this wiki locally