> For the complete documentation index, see [llms.txt](https://boinc-ai.gitbook.io/optimum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boinc-ai.gitbook.io/optimum/furiosa/reference/models.md).

# Models

## Models

### Generic model classes

The following Furiosa classes are available for instantiating a base model class without a specific head.

#### FuriosaAIModel

#### class optimum.furiosa.FuriosaAIModel

[\<source>](https://github.com/huggingface/optimum.furiosa/blob/vr_/optimum/furiosa/modeling.py#L68)

( model config: PretrainedConfig = None compute\_metrics: Optional = None label\_names: Optional = None \*\*kwargs )

**evaluation\_loop**

[\<source>](https://github.com/huggingface/optimum.furiosa/blob/vr_/optimum/furiosa/modeling.py#L102)

( dataset: Dataset )

Parameters

* **dataset** (`datasets.Dataset`) — Dataset to use for the evaluation step.

Run evaluation and returns metrics and predictions.

**to**

[\<source>](https://github.com/huggingface/optimum.furiosa/blob/vr_/optimum/furiosa/modeling.py#L90)

( device: str )

Use the specified `device` for inference. For example: “cpu” or “gpu”. `device` can be in upper or lower case. To speed up first inference, call `.compile()` after `.to()`.

### Computer vision

The following classes are available for the following computer vision tasks.

#### FuriosaAIModelForImageClassification

#### class optimum.furiosa.FuriosaAIModelForImageClassification

[\<source>](https://github.com/huggingface/optimum.furiosa/blob/vr_/optimum/furiosa/modeling.py#L161)

( model = None config = None \*\*kwargs )

Parameters

* **model** (`furiosa.runtime.model`) — is the main class used to run inference.
* **config** (`transformers.PretrainedConfig`) — [PretrainedConfig](https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig) is the Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the `~furiosa.modeling.FuriosaAIBaseModel.from_pretrained` method to load the model weights.
* **device** (`str`, defaults to `"CPU"`) — The device type for which the model will be optimized for. The resulting compiled model will contains nodes specific to this device.
* **furiosa\_config** (`Optional[Dict]`, defaults to `None`) — The dictionnary containing the informations related to the model compilation.
* **compile** (`bool`, defaults to `True`) — Disable the model compilation during the loading step when set to `False`.

FuriosaAI Model with a ImageClassifierOutput for image classification tasks.

This model inherits from `optimum.furiosa.FuriosaAIBaseModel`. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving)

**forward**

[\<source>](https://github.com/huggingface/optimum.furiosa/blob/vr_/optimum/furiosa/modeling.py#L175)

( pixel\_values: Union \*\*kwargs )

Parameters

* **pixel\_values** (`torch.Tensor`) — Pixel values corresponding to the images in the current batch. Pixel values can be obtained from encoded images using [`AutoFeatureExtractor`](https://huggingface.co/docs/transformers/autoclass_tutorial#autofeatureextractor).

The [FuriosaAIModelForImageClassification](https://huggingface.co/docs/optimum.furiosa/pr_/en/package_reference/modeling#optimum.furiosa.FuriosaAIModelForImageClassification) forward method, overrides the `__call__` special method.

Although the recipe for forward pass needs to be defined within this function, one should call the `Module` instance afterwards instead of this since the former takes care of running the pre and post processing steps while the latter silently ignores them.

Example of image classification using `transformers.pipelines`:

Copied

```
>>> from transformers import AutoFeatureExtractor, pipeline
>>> from optimum.furiosa import FuriosaAIModelForImageClassification

>>> preprocessor = AutoFeatureExtractor.from_pretrained("microsoft/resnet50")
>>> model = FuriosaAIModelForImageClassification.from_pretrained("microsoft/resnet50", export=True, input_shape_dict="dict('pixel_values': [1, 3, 224, 224])", output_shape_dict="dict("logits": [1, 1000])",)
>>> pipe = pipeline("image-classification", model=model, feature_extractor=preprocessor)
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> outputs = pipe(url)
```
