{"record":{"id":"5bbae6a720b08323","repo":"huggingface/pytorch-image-models","slug":"csatv2-is-designed-for-3-channel-rgb-input-in-cha","errorCode":null,"errorMessage":"CSATv2 is designed for 3-channel RGB input. in_chans={in_chans} may not work correctly with the DCT stem.","messagePattern":"CSATv2 is designed for 3-channel RGB input\\. in_chans=(.+?) may not work correctly with the DCT stem\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"timm/models/csatv2.py","lineNumber":563,"sourceCode":"    def __init__(\n            self,\n            num_classes: int = 1000,\n            in_chans: int = 3,\n            dims: Tuple[int, ...] = (32, 72, 168, 386),\n            depths: Tuple[int, ...] = (2, 2, 8, 6),\n            transformer_depths: Tuple[int, ...] = (0, 0, 2, 2),\n            drop_path_rate: float = 0.0,\n            transformer_drop_path: bool = False,\n            ls_init_value: Optional[float] = None,\n            global_pool: str = 'avg',\n            device=None,\n            dtype=None,\n            **kwargs,\n    ) -> None:\n        dd = dict(device=device, dtype=dtype)\n        super().__init__()\n        if in_chans != 3:\n            warnings.warn(\n                f'CSATv2 is designed for 3-channel RGB input. '\n                f'in_chans={in_chans} may not work correctly with the DCT stem.'\n            )\n        self.num_classes = num_classes\n        self.in_chans = in_chans\n        self.global_pool = global_pool\n        self.grad_checkpointing = False\n\n        self.num_features = dims[-1]\n        self.head_hidden_size = self.num_features\n\n        # Build feature_info dynamically\n        self.feature_info = [dict(num_chs=dims[0], reduction=8, module='stem_dct')]\n        reduction = 8\n        for i, dim in enumerate(dims):\n            if i > 0:\n                reduction *= 2\n            self.feature_info.append(dict(num_chs=dim, reduction=reduction, module=f'stages.{i}'))","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/csatv2.py#L545-L581","documentation":"The CSATv2 architecture uses a DCT-based stem tuned for 3-channel RGB input; instantiating it with a different in_chans triggers this warning that behavior may be incorrect. It is a heads-up, not a hard failure — the model still builds.","triggerScenarios":"Passing in_chans=1 (grayscale), in_chans=4, or other values != 3 to csatv2_tiny/small/base or via timm.create_model('csatv2_*', in_chans=...).","commonSituations":"Reusing pretrained CSATv2 weights on grayscale medical/satellite imagery, or adding an alpha channel by accident; fine-tuning scripts that blanket-set in_chans for all models.","solutions":["Convert your input to 3-channel RGB before the model (repeat/interpolate channels) and keep in_chans=3","If channel mismatch is required, verify the DCT stem actually supports it — test forward pass output sanity","Use a model with a standard conv stem if single-channel input is a hard requirement"],"exampleFix":"# before\nmodel = timm.create_model('csatv2_tiny', in_chans=1, pretrained=True)\n# after\nmodel = timm.create_model('csatv2_tiny', in_chans=3, pretrained=True)\nx = x.repeat(1, 3, 1, 1)  # grayscale -> RGB","handlingStrategy":"validation","validationCode":"in_chans = 1\nif in_chans != 3:\n    raise ValueError('CSATv2 expects 3-channel RGB input; convert input or pick another model')\nmodel = timm.create_model('csatv2_tiny', in_chans=in_chans, pretrained=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set per-model in_chans in config, not a global value","Convert grayscale inputs with x.repeat(1,3,1,1) at the dataset level","Sanity-check first-batch forward output shapes/stats"],"tags":["timm","csatv2","in-chans","input-shape"],"backgroundTag":"input-channel-mismatch","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}