Fix: Replace invalid model ID with valid SegFormer checkpoint in example code
Browse files## Description
The original example code attempts to load a model ID that does not exist on the Hugging Face Hub:
```python
nvidia/segformer-b5-finetuned-ade-512-512
```
This triggers the following runtime error:
```python
OSError: nvidia/segformer-b5-finetuned-ade-512-512 is not a valid model identifier listed on https://huggingface.co/models
```
## Changes
Replaced:
```python
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-ade-512-512")
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-ade-512-512")
```
with:
```python
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.
|
@@ -35,8 +35,8 @@ from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmenta
|
|
| 35 |
from PIL import Image
|
| 36 |
import requests
|
| 37 |
|
| 38 |
-
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-ade-
|
| 39 |
-
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-ade-
|
| 40 |
|
| 41 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 42 |
image = Image.open(requests.get(url, stream=True).raw)
|
|
|
|
| 35 |
from PIL import Image
|
| 36 |
import requests
|
| 37 |
|
| 38 |
+
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-ade-640-640")
|
| 39 |
+
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-ade-640-640")
|
| 40 |
|
| 41 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 42 |
image = Image.open(requests.get(url, stream=True).raw)
|