# Image Embedding with data2vec
*author: David Wang*
< br / >
## Description
This operator extracts features for image with [data2vec ](https://arxiv.org/abs/2202.03555 ). The core idea is to predict latent representations of the full input data based on a masked view of the input in a self-distillation setup using a standard Transformer architecture.
< br / >
## Code Example
Load an image from path './towhee.jpg' to generate an image embedding.
*Write the pipeline in simplified style* :
```python
import towhee
towhee.glob('./towhee.jpg') \
.image_decode.cv2() \
.image_embedding.data2vec(model_name='facebook/data2vec-vision-base-ft1k') \
.show()
```
< img src = "./result1.png" alt = "result1" style = "height:20px;" / >
*Write a same pipeline with explicit inputs/outputs name specifications:*
```python
import towhee
towhee.glob['path']('./towhee.jpg') \
.image_decode.cv2['path', 'img']() \
.image_embedding.data2vec['img', 'vec'](model_name='facebook/data2vec-vision-base-ft1k') \
.select['img', 'vec']() \
.show()
```
< img src = "./result2.png" alt = "result2" style = "height:60px;" / >
< br / >
## Factory Constructor
Create the operator via the following factory method
***data2vec(model_name='facebook/data2vec-vision-base')***
**Parameters:**
** *model_name***: *str*
The model name in string.
The default value is "facebook/data2vec-vision-base-ft1k".
Supported model name:
- facebook/data2vec-vision-base-ft1k
- facebook/data2vec-vision-large-ft1k
< br / >
## Interface
An image embedding operator takes a [towhee image ](link/to/towhee/image/api/doc ) as input.
It uses the pre-trained model specified by model name to generate an image embedding in ndarray.
**Parameters:**
** *img:*** *towhee.types.Image (a sub-class of numpy.ndarray)*
The decoded image data in towhee.types.Image (numpy.ndarray).
**Returns:** *numpy.ndarray*
The image embedding extracted by model.