# Segformer from HuggingFace

In this tutorial we're going to demonstrate how well we are integrated with amazing HugginFace libraries by deploying SegFormer computer vision model with zero effort.&#x20;

## How to deploy SegFormer on Everinfer

Install Everinfer and HuggingFace transformers library.

Convert the model to ONNX format:

```python
!python3 -m transformers.onnx --model=nvidia/segformer-b0-finetuned-ade-512-512 onnx_segformer/
```

Authenticate on Everinfer using your API key, upload the model, and create inference engine:

```python
from everinfer import Client
client = Client('my_api_key') # hit us up on hello@everinfer.ai to get your key
pipeline = client.register_pipeline('segformer', ['onnx_segformer/model.onnx'])
runner = client.create_engine(pipeline['uuid'])
```

You are ready to go, only 4 lines of code to deploy your model to remote GPUs!

Since HuggingFace image preprocessors are fully compatible with Everinfer expected input format, you can feed tokenizer outputs directly to the deployed model:

```python
from transformers import SegformerFeatureExtractor
from PIL import Image
import requests

feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b0-finetuned-ade-512-512")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = feature_extractor(images=image, return_tensors="np")

preds = runner.predict([inputs]) # runs on remote hardware!
```

Everinfer is highly efficient as it is, even while transferring tensors over the network, let's check how fast the deployed model is:&#x20;

<figure><img src="/files/esttPkMVQ3vP1DmQln6u" alt=""><figcaption><p>Decent performance even without any additional data transfer optimization! </p></figcaption></figure>

{% hint style="info" %}
It is possible to speed up that deployment even further by fusing pre-processing step into an ONNX graph and transferring only raw .jpg images over the network.&#x20;

Check out our [Faster-RCNN tutorial](/getting-started/faster-rcnn-example.md) as an example
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.everinfer.ai/examples/segformer-from-huggingface.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
