# Image-To-Text task on Inference Endpoint

**URL:** <https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367>\
**Category:** Inference Endpoints on the Hub\
**Created:** [June 24, 2023, 3:31am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367 "2023-06-24T03:31:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorikawa](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thorikawa/32/17063_2.png) [@thorikawa](https://discuss.huggingface.co/u/thorikawa)\
**Post date:** [June 24, 2023, 3:31am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/1 "2023-06-24T03:31:27Z")

</div>

I would like to deploy an Image-To-Text model on an Inference Endpoint. For example, the following model.

> **[Salesforce/blip-image-captioning-base · Hugging Face](https://huggingface.co/Salesforce/blip-image-captioning-base)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

When I try to deploy this model, the task is set to `custom`, but it fails to start because there is no handler.py.

The error log indicates that there is a task called `image-to-text` , but this one cannot be selected from the Inference Endpoint configuration screen.

> KeyError: “Unknown task custom, available tasks are [‘audio-classification’, ‘automatic-speech-recognition’, ‘conversational’, ‘depth- estimation’, ‘document-question-answering’, ‘feature-extraction’, ‘fill-mask’, ‘image-classification’, ‘image-segmentation’, ‘image-to- text’, ‘ner’, ‘object-detection’, ‘question-answering’, ‘sentiment-analysis’, ‘summarization’, ‘table-question-answering’, ‘text- classification’, ‘text-generation’, ‘text2text-generation’, ‘token-classification’, ‘translation’, ‘video-classification’, ‘visual- question-answering’, ‘vqa’, ‘zero-shot-audio-classification’, ‘zero-shot-classification’, ‘zero-shot-image-classification’, ‘zero-shot- object-detection’, ‘translation\_XX\_to\_YY’]”

Is it not possible to set image-to-text to task in my Inference Endpoint? And if the only way is to set the task to custom, is there a handler.py template for image-to-text somewhere?

---

<div class="post-metadata">

**Author:** ![harry-ploy](https://avatars.discourse-cdn.com/v4/letter/h/b9bd4f/32.png) [@harry-ploy](https://discuss.huggingface.co/u/harry-ploy)\
**Post date:** [July 14, 2023, 2:27pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/2 "2023-07-14T14:27:57Z")

</div>

Hi, wondering if there was any update to this? Looking for the same problem

---

<div class="post-metadata">

**Author:** ![philschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philschmid/32/38022_2.png) [@philschmid](https://discuss.huggingface.co/u/philschmid)\
**Post date:** [July 19, 2023, 7:09am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/3 "2023-07-19T07:09:51Z")

</div>

Working on adding it as zero-code deployment. Will keep you posted.

---

<div class="post-metadata">

**Author:** ![rishabhgupta7696](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rishabhgupta7696/32/17915_2.png) [@rishabhgupta7696](https://discuss.huggingface.co/u/rishabhgupta7696)\
**Post date:** [July 25, 2023, 10:29am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/4 "2023-07-25T10:29:10Z")

</div>

Hello,  
Is there any alternate solution to this?

---

<div class="post-metadata">

**Author:** ![mgultekin](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@mgultekin](https://discuss.huggingface.co/u/mgultekin)\
**Post date:** [July 28, 2023, 1:38pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/5 "2023-07-28T13:38:34Z")

</div>

Any update?

---

<div class="post-metadata">

**Author:** ![mgultekin](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@mgultekin](https://discuss.huggingface.co/u/mgultekin)\
**Post date:** [July 29, 2023, 1:37pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/6 "2023-07-29T13:37:58Z")

</div>

I have used this model [https://huggingface.co/prasanna2003/blip-image-captioning](https://huggingface.co/prasanna2003/blip-image-captioning). You can use its own API url.

---

<div class="post-metadata">

**Author:** ![wmccc](https://avatars.discourse-cdn.com/v4/letter/w/dec6dc/32.png) [@wmccc](https://discuss.huggingface.co/u/wmccc)\
**Post date:** [October 4, 2023, 2:16pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/7 "2023-10-04T14:16:56Z")

</div>

I am trying to do the same. Is there any help here? If i put it to Image-Classification its asking for input\_ids, which i am not able to provide neither ui nor through my request.

---

<div class="post-metadata">

**Author:** ![pdichone](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pdichone/32/20154_2.png) [@pdichone](https://discuss.huggingface.co/u/pdichone)\
**Post date:** [October 10, 2023, 12:10am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/8 "2023-10-10T00:10:31Z")

</div>

Any updates on this? I need to do the same thing and with no success.

---

<div class="post-metadata">

**Author:** ![pdichone](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pdichone/32/20154_2.png) [@pdichone](https://discuss.huggingface.co/u/pdichone)\
**Post date:** [October 10, 2023, 12:12am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/9 "2023-10-10T00:12:46Z")

</div>

The problem when I try to generate an inference endpoint, I get this warning:  
**Warning:** deploying this model may fail because a

“handler.py”

file was not found in the repository. Try selecting a different model or creating a [custom handler](https://huggingface.co/docs/inference-endpoints/guides/custom_handler).

---

<div class="post-metadata">

**Author:** ![pdichone](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pdichone/32/20154_2.png) [@pdichone](https://discuss.huggingface.co/u/pdichone)\
**Post date:** [October 10, 2023, 12:13am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/10 "2023-10-10T00:13:27Z")

</div>

Hi @philschmid,  
any updates on this?

---

<div class="post-metadata">

**Author:** ![ckandemir](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ckandemir/32/22679_2.png) [@ckandemir](https://discuss.huggingface.co/u/ckandemir)\
**Post date:** [October 12, 2023, 4:36pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/11 "2023-10-12T16:36:52Z")

</div>

@pdichone  
This is how you do it through custom endpoints:

> **[handler.py · ckandemir/relyst at main](https://huggingface.co/ckandemir/relyst/blob/main/handler.py)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

However, I think the optimum method now is do follow along what  
@philschmid has shared today for Sagemaker implementation

> **[Deploy Idefics 9B & 80B on Amazon SageMaker](https://www.philschmid.de/sagemaker-idefics)**
>
> Learn how to deploy Hugging Face Idefics 9B & 80B to Amazon SageMaker and send requests with images and text to the model.

---

<div class="post-metadata">

**Author:** ![ckandemir](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ckandemir/32/22679_2.png) [@ckandemir](https://discuss.huggingface.co/u/ckandemir)\
**Post date:** [October 13, 2023, 7:05am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/12 "2023-10-13T07:05:06Z")

</div>

@thorikawa also you can use this one is for the blip model:

> **[handler.py · ckandemir/blip-image-captioning-large-inference at main](https://huggingface.co/ckandemir/blip-image-captioning-large-inference/blob/main/handler.py)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![pdichone](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pdichone/32/20154_2.png) [@pdichone](https://discuss.huggingface.co/u/pdichone)\
**Post date:** [October 14, 2023, 4:23pm UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/13 "2023-10-14T16:23:04Z")

</div>

@ckandemir You are a legend!  
Thank you so much.  
My struggle was that I once I had cloned the repo (the blip model repo), I wasn’t able to generate the correct dependencies like the pythorch\_bin and the weights needed for me to be able to then attach my custom handler.py and then create the inference endpoint.

Do you mind sharing how you were able to do the whole process ( sorry, I am a newby when it comes to this stuff, if you can’t tell… lol).

For the handler.py, I don’t want the payload to be a list of images, I just want to be able to attach 1 image to be processed…

Anyway, you’ve been a lot of help already, I would totally understand if this is too much to ask 🙂

---

<div class="post-metadata">

**Author:** ![ckandemir](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ckandemir/32/22679_2.png) [@ckandemir](https://discuss.huggingface.co/u/ckandemir)\
**Post date:** [October 17, 2023, 12:22am UTC](https://discuss.huggingface.co/t/image-to-text-task-on-inference-endpoint/44367/14 "2023-10-17T00:22:30Z")

</div>

@pdichone basically when you are creating a custom endpoint handler your are reconfiguring the forward method to align with the generate function of the model you are using behind the endpoint, and thus tweaking the payload accordingly to the underlying mode’s accepted input type. @philschmid please correct me if I am wrong

I would recommend to follow this documentation [here](https://huggingface.co/docs/inference-endpoints/guides/custom_handler) to build couple random endpoints to get a hold on it. Then you can easily spot whats going on in the logs when you deploy your endpoints.

You can tweak this code [here](https://huggingface.co/ckandemir/blip-image-captioning-large-inference) to serve your use case
