Update README.md
Browse files
README.md
CHANGED
@@ -29,17 +29,17 @@ You can use the raw model for semantic segmentation. See the [model hub](https:/
|
|
29 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
30 |
|
31 |
```python
|
32 |
-
from transformers import
|
33 |
from PIL import Image
|
34 |
import requests
|
35 |
|
36 |
-
|
37 |
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b4-finetuned-cityscapes-1024-1024")
|
38 |
|
39 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
40 |
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
|
42 |
-
inputs =
|
43 |
outputs = model(**inputs)
|
44 |
logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)
|
45 |
```
|
|
|
29 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
30 |
|
31 |
```python
|
32 |
+
from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
|
33 |
from PIL import Image
|
34 |
import requests
|
35 |
|
36 |
+
processor = SegformerImageProcessor.from_pretrained("nvidia/segformer-b4-finetuned-cityscapes-1024-1024")
|
37 |
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b4-finetuned-cityscapes-1024-1024")
|
38 |
|
39 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
40 |
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
|
42 |
+
inputs = processor(images=image, return_tensors="pt")
|
43 |
outputs = model(**inputs)
|
44 |
logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)
|
45 |
```
|