# Retrieve BlipForImageTextRetrieval image features

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fretrieve-blipforimagetextretrieval-image-features%2F55363%3E%5C
**Category:** 🤗Transformers\
**Created:** [September 17, 2023, 11:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fretrieve-blipforimagetextretrieval-image-features%2F55363 "2023-09-17T23:34:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saarstriker](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Saarstriker](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSaarstriker)%5C
**Post date:** [September 17, 2023, 11:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fretrieve-blipforimagetextretrieval-image-features%2F55363%2F1 "2023-09-17T23:34:37Z")

</div>

Hey!

I am trying to get the image features/embeddings from `BlipForImageTextRetrieval` .

According to the docs:

> - **image\_embeds** (`torch.FloatTensor` of shape `(batch_size, output_dim)` _optional_ returned when model is initialized with `with_projection=True`) — The image embeddings obtained by applying the projection layer to the pooler\_output

How can i set the `with_projection` to True, I can not find any information anywhere for this?  
Is there any other way to extract the features?

How would i go on and extract the text\_features (for a future use case)?

Thank you !

Edit: This is my current workaround

```auto
def get_vision_features(img_path, model, processor):
    vision_model = model.vision_model
    
    img = Image.open(img_path)
    processed_images = processor(img, return_tensors="pt")

    vision_embeddings = vision_model(pixel_values=processed_images.pixel_values, return_dict=True).pooler_output

    vision_features = model.vision_proj(vision_embeddings)

```
