Wednesday, August 2, 2023

Step by Step Demo of Image Captioning in AI

This is a step by step guide to use AI to caption an image. This is a complete demo of installing and running locally salesforce blip image model to caption any image. 

Commands Used:

import os

import io

import IPython.display

from PIL import Image

import base64 

hf_api_key = '<Your Hugging Face API Token>'

!pip install transformers

from transformers import pipeline

get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")

def summarize(input):

    output = get_completion(input)

    return output[0]['generated_text']

image_url = ""



No comments: