image

Standardizes ImageNet eval preprocessing with square resize, center crop, and normalization for torchvision pipelines.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill image-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: image
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/experiment-tips/image
Command: npx skills add https://github.com/zjunlp/Mechanist --skill image-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torchvision.

What problem does it solve? ImageNet eval preprocessing has a silent trap: Resize(256) (int, short-side) and Resize((256, 256)) (tuple, square) extract different patches from non-square images, so top-k activating images, neuron labels, and interpretability scores silently diverge between pipelines that look identical. ## Core Features & Use Cases - Drop-in transform: Provides a canonical imagenet_eval_transform (square 256x256 resize, 224 center crop, ImageNet mean/std) ready to paste into any Dataset/DataLoader. - Convention comparison: Documents when to use square resize, classic ResNet short-side 256, torchvision V2 (232), or CLIP preprocessing, so the choice is intentional rather than accidental. - Audit workflow: Supplies grep commands and decision rules for reviewing an existing repo's torchvision.transforms / PIL pipeline and patching misapplied resizes. - Use Case: While collecting hooked activations from a frozen ResNet backbone, you notice top-k activating images differ from a colleague's run; this Skill identifies the int-vs-tuple Resize mismatch and unifies both pipelines. ## Quick Start Ask the assistant to audit my experiment's torchvision preprocessing pipeline and align it with the canonical ImageNet eval transform.

Frequently Asked Questions about image

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the difference between Resize(256) and Resize((256, 256)) in torchvision?

Resize(256) with an int resizes the short side to 256 while preserving aspect ratio, so a 500x800 image becomes 256x410. Resize((256, 256)) with a tuple forces a square 256x256 output, distorting aspect ratio. After CenterCrop(224), the two extract different patches from non-square images.

How do I write canonical ImageNet eval preprocessing in torchvision?

Compose Resize((256, 256), antialias=True), CenterCrop(224), ToTensor(), and Normalize with mean (0.485, 0.456, 0.406) and std (0.229, 0.224, 0.225). The explicit antialias flag removes version-dependent warnings across torchvision 0.15 and later.

Why do my top-k activating images differ between runs or repos?

A common cause is mismatched resize conventions: one pipeline uses short-side Resize(256) while another uses square Resize((256, 256)). The shifted center crop changes which pixels each image contributes, altering activation rankings and every downstream interpretability artefact.

Should I use ImageNet preprocessing for a CLIP encoder?

No. CLIP expects Resize(224, BICUBIC), CenterCrop(224), and its own mean [0.48145, 0.45783, 0.40821] and std [0.26863, 0.26130, 0.27578]. Mixing ImageNet statistics into a CLIP encoder shifts the input distribution away from what the model was trained on.

When should I not override a model's own image_processor?

Do not override Hugging Face image_processor or timm resolve_data_config pipelines, since they match the distribution the model was trained on. Also leave Resize(232) paired with IMAGENET1K_V2 weights alone, as it intentionally reproduces torchvision V2 accuracy.