Image captioning using image url only without blob?

Hi!, how can I use image captioning when I only have image url? the constraint is I can’t use function/method to open an image (blob) and using curl.

here’s what I did (this works because it’s an image blob):

curl https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large \
        -X POST \
        --data-binary '@pilates.jpg' \
        -H "Authorization: Bearer ${HF_API_TOKEN}"
# [{"generated_text": "there is a man doing a handstand on a rock in the woods"}]

But, is there any way to do a request where I only have image url?

@nappystock In my inference endpoint I got it working by downloading the image from the url then converting it to bytes then sending it to the model:

@ckandemir I saw it used a py script where i have to run it. What I mean is I can only use curl and image url only (no blob, no image opening (ie. with open("/content/demo.jpg", "rb") as image_file...)

If your underlying model accepts jpg in the payload you can try to download it directly with:

curl https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large \
     -X POST \
     --data-binary "$(curl -s [IMAGE_URL])"\
     -H "Authorization: Bearer ${HF_API_TOKEN}"