Fix: Replace invalid model ID with valid SegFormer checkpoint in example code

#6

Description

The original example code attempts to load a model ID that does not exist on the Hugging Face Hub:

nvidia/segformer-b5-finetuned-ade-512-512

This triggers the following runtime error:

OSError: nvidia/segformer-b5-finetuned-ade-512-512 is not a valid model identifier listed on https://huggingface.co/models

Changes

Replaced:

feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-ade-512-512")
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-ade-512-512")

with:

feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-ade-640-640")
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-ade-640-640")

Testing

The code has been successfully tested and runs without error.

Note

This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.

LGTM!

(although I don't have permissions to merge)

Same, btw the feature extractor can be replaced by an image processor (SegformerImageProcessor).

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment