Fix classification model card missing cover image when first category is empty (#24768)
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions

The cover image only checked the first category returned by the dataset
API (after skipping none/unknown) and gave up if it had no images. Since
category order follows the dataset directory listing, a model whose first
listed category is still empty showed the skeleton placeholder even when
other categories had plenty of images.

Use the first category that actually has images instead.
This commit is contained in:
David McNett
2026-10-24 08:12:33 -05:00
committed by GitHub
parent f7d532a09d
commit 04c62c2ce3
@@ -271,17 +271,16 @@ function ModelCard({ config, onClick, onUpdate, onDelete }: ModelCardProps) {
(key) => key != "none" && key.toLowerCase() != "unknown", (key) => key != "none" && key.toLowerCase() != "unknown",
); );
if (keys.length === 0) { const selectedKey = keys.find(
(key) => (dataset.categories[key]?.length ?? 0) > 0,
);
if (!selectedKey) {
return undefined; return undefined;
} }
const selectedKey = keys[0];
const images = dataset.categories[selectedKey]; const images = dataset.categories[selectedKey];
if (!images || images.length === 0) {
return undefined;
}
return { return {
name: selectedKey, name: selectedKey,
img: images[0], img: images[0],