# Feature extraction for image with a hosted model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%3E%5C
**Category:** Beginners\
**Created:** [April 9, 2023, 8:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056 "2023-04-09T20:51:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![avivhu](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@avivhu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Favivhu)%5C
**Post date:** [April 9, 2023, 8:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F1 "2023-04-09T20:51:04Z")

</div>

Is there any hosted model on Hugging Face that performs image feature extraction and returns the features vector (aka image2vec, image embedding)?

I came across this one that is documented to do just that:  
[florentgbelidji/blip\_image\_embeddings · Hugging Face](https://huggingface.co/florentgbelidji/blip_image_embeddings)

But when I called it I got an error:  
`{'error': ['value is not a valid list: ` __root__ ` in `parameters`', 'str type expected: ` __root__ ` in `parameters`']}`

The test code:

```auto
import json
from typing import List
import requests as r
import base64

ENDPOINT_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fflorentgbelidji%2Fblip_image_embeddings"

def predict(path_to_image: str):
    with open(path_to_image, "rb") as i:
        b64 = base64.b64encode(i.read())
    payload = {"inputs": {"image": b64.decode("utf-8")}}
    response = r.post(
        ENDPOINT_URL, headers={"Authorization": f"Bearer {API_TOKEN}"}, json=payload
    )
    return response.json()

prediction = predict(path_to_image=img)
print(prediction)

```

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [April 10, 2023, 8:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F2 "2023-04-10T20:46:49Z")

</div>

hi @avivhu ,

I don’t think we have a feature-extration from images on our community pipelines, i.e. using our API Inference. The model you’ve linked is an example of a custom pipeline for our [Inference Endpoints](https://huggingface.co/inference-endpoints), cc @florentgbelidji the author.  
If you want it on our community API, for tests and prototypes you can open an issue here [Issues · huggingface/api-inference-community · GitHub](https://github.com/huggingface/api-inference-community/issues)

---

<div class="post-metadata">

**Author:** ![avivhu](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@avivhu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Favivhu)%5C
**Post date:** [April 11, 2023, 9:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F3 "2023-04-11T09:55:12Z")

</div>

Thanks @radames .  
I opened a feature request here:  
[Add image feature extraction to the Inference API [img2vec] · Issue #229 · huggingface/api-inference-community (github.com)](https://github.com/huggingface/api-inference-community/issues/229)

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [April 11, 2023, 6:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F4 "2023-04-11T18:19:56Z")

</div>

hi @avivhu , sorry I was able to update the custom pipeline to make it work on our public API,  
You can use from this model repo now, [radames/blip\_image\_embeddings · Hugging Face](https://huggingface.co/radames/blip_image_embeddings)

```python
import json
from typing import List
import requests as r
import base64
ENDPOINT_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fradames%2Fblip_image_embeddings"
HF_TOKEN = ""
def predict(path_to_image: str = None):
    with open(path_to_image, "rb") as i:
        b64 = base64.b64encode(i.read())
    payload = {"inputs": b64.decode("utf-8")}
    response = r.post(
        ENDPOINT_URL, headers={"X-Wait-For-Model": "true", "Authorization": f"Bearer {HF_TOKEN}"}, json=payload
    )
    return response.json()
prediction = predict(
    path_to_image="palace.jpg"
)

```

---

<div class="post-metadata">

**Author:** ![avivhu](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@avivhu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Favivhu)%5C
**Post date:** [April 12, 2023, 3:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F5 "2023-04-12T15:07:24Z")

</div>

That works perfectly. Thank you @radames .

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [December 20, 2023, 7:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F6 "2023-12-20T19:18:12Z")

</div>

Split this topic on December 20, 2023, 7:18pm UTC

A post was split to a new topic: [Deploying CLIP-Vit as an inference endpoint](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-clip-vit-as-an-inference-endpoint%2F66511)

---

<div class="post-metadata">

**Author:** ![timschott](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/timschott/32/31853_2.png) [@timschott](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftimschott)%5C
**Post date:** [September 20, 2024, 7:47pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-for-image-with-a-hosted-model%2F36056%2F7 "2024-09-20T19:47:34Z")

</div>

Hello! Trying this out and currently seeing

```auto
radames/blip_image_embeddings does not appear to have a file named config.json. Checkout 'https://huggingface.co/radames/blip_image_embeddings/tree/dace0eb439798ee47c0dc90f45c790ef87514770' for available files.

```

Any ideas on a fix for this?
