{"record":{"id":"4c56b8eefc0703be","repo":"tracel-ai/burn","slug":"unrecognized-image-color-type","errorCode":null,"errorMessage":"Unrecognized image color type","messagePattern":"Unrecognized image color type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-dataset/src/vision/image_folder.rs","lineNumber":261,"sourceCode":"    // Image as Vec<PixelDepth>\n    // if rgb8 or rgb16, keep only the first channel assuming all channels are the same\n\n    match image.color() {\n        ColorType::L8 => image.into_luma8().iter().map(|&x| x as usize).collect(),\n        ColorType::L16 => image.into_luma16().iter().map(|&x| x as usize).collect(),\n        ColorType::Rgb8 => image\n            .into_rgb8()\n            .iter()\n            .step_by(3)\n            .map(|&x| x as usize)\n            .collect(),\n        ColorType::Rgb16 => image\n            .into_rgb16()\n            .iter()\n            .step_by(3)\n            .map(|&x| x as usize)\n            .collect(),\n        _ => panic!(\"Unrecognized image color type\"),\n    }\n}\n\n/// Parse the image annotation to the corresponding type.\nfn parse_image_annotation(\n    annotation: &AnnotationRaw,\n    classes: &HashMap<String, usize>,\n) -> Annotation {\n    // TODO: add support for other annotations\n    // - [ ] Object bounding boxes\n    // - [x] Segmentation mask\n    // For now, only image classification labels and segmentation are supported.\n\n    // Map class string to label id\n    match annotation {\n        AnnotationRaw::Label(name) => Annotation::Label(*classes.get(name).unwrap()),\n        AnnotationRaw::MultiLabel(names) => Annotation::MultiLabel(\n            names","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-dataset/src/vision/image_folder.rs#L243-L279","documentation":"Exhaustiveness guard in `segmentation_mask_to_vec_usize`: only L8, L16, Rgb8, and Rgb16 image color types are converted; any other `image::ColorType` (e.g. RGBA, palette, or alpha-bearing formats) reaching the loader triggers the panic. The failing input is an image file whose color type the image folder dataset does not support for segmentation masks.","triggerScenarios":"Thrown at crates/burn-dataset/src/vision/image_folder.rs:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pre-convert mask images to 8-bit grayscale or RGB (no alpha) before placing them in the dataset folder.","Re-save PNG masks as palette-free `L` or `RGB` mode (e.g. with ImageMagick or PIL) to drop RGBA/palette color types.","Extend the match to handle additional ColorTypes such as Rgba8/A8 if masks legitimately use alpha channels."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}