Image-to-Text Model This project implements an image-to-text model using the BLIP (Bootstrapped Language-Image Pre-training) model. It allows users to input an image (via URL), and the model generates both conditional and unconditional captions describing the content of the image.
Table of Contents 1)Introduction 2)Features 3)Installation 4)Usage 5)Examples
1)Introduction
The Image-to-Text Model leverages the BLIP model to generate captions for images. The model can generate captions in two modes:
Conditional Captions: A description generated with an initial prompt. Unconditional Captions: A description generated without any prompt. The model is useful for various tasks, such as:
Automatic image annotation. Assisting visually impaired individuals by describing images. Image-based content generation.
2)Features
Conditional Captioning: Generates a caption with the context of a prompt (e.g., "a photography of ..."). Unconditional Captioning: Generates a general caption for the image without a prompt. Streamlit Web App: Easy-to-use web interface for uploading images and generating captions. Hugging Face Transformers: Uses the Salesforce BLIP model for robust image-caption generation.
3)Installation
Clone the repository:
bash Copy code git clone https://github.com/Computer-Vision-Projects.git
Create and activate a virtual environment (optional but recommended):
bash Copy code python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate Install the required dependencies:
Copy code pip install -r requirements.txt Install additional dependencies if required for Streamlit:
Copy code pip install streamlit Usage Running the Streamlit App Start the Streamlit web app:
Copy code streamlit run app.py Access the app at http://localhost:8501. Input an image URL to generate captions.
Examples Here is an example of what the model outputs:
Input Image URL: https://example.com/sample_image.jpg
Output Conditional Caption: A photography of a dog playing on the beach. Unconditional Caption: A dog is running across the sand on a beach.