Views
No views yet
1from transformers import SegformerImageProcessor
2from PIL import Image
3import requests
4
5from optimum.onnxruntime import ORTModelForSemanticSegmentation
6
7image_processor = SegformerImageProcessor.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
8model = ORTModelForSemanticSegmentation.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
9
10url = "http://images.cocodataset.org/val2017/000000039769.jpg"
11image = Image.open(requests.get(url, stream=True).raw)
12
13inputs = image_processor(images=image, return_tensors="pt").to(device)
14outputs = model(**inputs)
15logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)1from transformers import SegformerImageProcessor, pipeline
2from optimum.onnxruntime import ORTModelForSemanticSegmentation
3
4image_processor = SegformerImageProcessor.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
5model = ORTModelForSemanticSegmentation.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
6
7url = "http://images.cocodataset.org/val2017/000000039769.jpg"
8pipe = pipeline("image-segmentation", model=model, feature_extractor=image_processor)
9pred = pipe(url)1@article{DBLP:journals/corr/abs-2105-15203,
2 author = {Enze Xie and
3 Wenhai Wang and
4 Zhiding Yu and
5 Anima Anandkumar and
6 Jose M. Alvarez and
7 Ping Luo},
8 title = {SegFormer: Simple and Efficient Design for Semantic Segmentation with
9 Transformers},
10 journal = {CoRR},
11 volume = {abs/2105.15203},
12 year = {2021},
13 url = {https://arxiv.org/abs/2105.15203},
14 eprinttype = {arXiv},
15 eprint = {2105.15203},
16 timestamp = {Wed, 02 Jun 2021 11:46:42 +0200},
17 biburl = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib},
18 bibsource = {dblp computer science bibliography, https://dblp.org}
19}