Git Product home page Git Product logo

mahadev0811 / text2imagedescription Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 893 KB

Text2ImageDescription retrieves relevant images from Pascal VOC 2012 dataset using OpenAI CLIP, based on text queries, and generates descriptions using quantized Mistral-7b model.

License: MIT License

Jupyter Notebook 100.00%
ctransformers image-embeddings llm mistral-7b openai-clip pandas-python pascal-voc pytorch transformers vector-database

text2imagedescription's Introduction

Text2ImageDescription

The project has 2 main parts:

  1. Image Retrieval: Given a text query, retrieve images from a dataset that are relevant to the query.
  2. Image Description Generation: Given a text query, generate a description for the image that is most relevant to the query.

Image Retrieval

The image retrieval part of the project uses a pre-trained openai CLIP model(https://github.com/openai/clip) to retrieve images from a dataset that are relevant to a given text query. The dataset used for this project is the Pascal VOC 2012 dataset. The dataset contains around 3500 images (train + validation). The CLIP model is used to encode the text query and the images in the dataset. The similarity between the text query and the images is calculated using cosine similarity. The images are then ranked based on the similarity score and the top k images are returned.

Image Description Generation

The image description generation part of the project uses a pre-trained Mistral-7b (https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF) model to generate descriptions for the give input query.

Usage

To run the project, follow the steps below:

  1. Clone the repository
  2. Run the notebook code.ipynb

Performance

  • Resource: 12 GB GPU (nvidia T4)
  • Image search: ~ 50 milliseconds.
  • Description generation: Streaming starts within approximately 2.5 seconds, achieving a rate of 40 tokens per second.

Results

Check out the demo video to see Text2ImageDescription in action:

demo.mp4

License

This project is licensed under the MIT License - see the LICENSE file for details.

text2imagedescription's People

Contributors

imtonystank avatar mahadev0811 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.