Skip to content

mlin12321/blip2-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLIP Image Captioning API

Installation

  1. Clone the repository:

    git clone https://github.com/askaresh/blip-image-captioning-api.git
    
  2. Navigate to the project directory:

    cd blip-image-captioning-api
    
  3. Run the run.sh file

    bash run.sh
    

    The API will be accessible at http://localhost:8004.

Usage

API Endpoint

The API provides a single endpoint for generating image captions:

  • POST /caption: Generate a caption for an image.

Request

To generate a caption for a list of images, send a POST request to the /caption endpoint with the following parameters:

  • image (required): The image file to generate a caption for. The image should be sent as a multipart form data.
  • text (optional): An optional text input to guide the caption generation process. This can be used for conditional image captioning.

Example using cURL:

curl -X POST -F "image=@path/to/image.jpg" -F "text=optional text input" http://localhost:8000/caption

See also ex_sample.sh.

An example for generating captions in python is in test-blip2.py.

Response

The API will respond with a JSON object containing the generated captions:

{
  "caption": ["a person riding a bike on a city street"]
}

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgements

About

A GitHub repository that showcases an image captioning API built using the FastAPI web framework and the BLIP (Bootstrapping Language-Image Pre-training) model from Hugging Face Transformers. This project demonstrates how to leverage state-of-the-art deep learning techniques to automatically generate descriptive captions for images.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 93.6%
  • Shell 6.4%