xISSAx / Alpha-Co-Vision

A real-time video caption to conversation bot that captures frames generates captions and creates conversational responses using a Large Language Models base to create interactive video descriptions.
MIT License
119 stars 17 forks source link
deep-learning real-time-video-captioning video-to-caption video-to-llm video-to-text

Alpha-Co-Vision

https://github.com/xISSAx/Alpha-Co-Vision/assets/86708276/736978ab-5c66-4335-a2cf-2daaa64250a0

A real-time video-to-text bot that captures frames generates captions and creates conversational responses using a Large Language Models base to create interactive video descriptions. Powered by BLIP (Bootstrapping Language-Image Pre-training) and Cohere AI, this bot is capable of unified vision-language understanding and generation using transformers.

Description:

Alpha-Co-Vision is the first step in a series of upcoming projects focused on real-time generations to ultimately create a Pet-Toy-Robot capable of understanding its environment to better interact with humans.

The main goal of this project was to efficiently run a VideoFrames-To-Text MultiModal-esk capable of understanding the world while combining it with the power of cutting-edge Large-Language-Models to better interact with the natural environment running BLIP in half-precision (float16) on MacBook M1 to gain maximum performance.

The project is currently under development and will improve over time with more support for other Chat models, such as GPT-4 and GPT-3.5 Turbo and locally running LLMs like LlaMa and Alpaca.

This was hacked in a couple of nights and maybe optimized incorrectly/poorly. Moreover, this project is for educational purposes only. Future updates, with growing community support, will include ‘Cuda ‘ support, voice input/output support, GPT-3.5 and GPT-4 for extended generations with Chat Support, and much more.

Requirements

⬆️ Recent Updates

You can install the required packages using the following command:

pip install cohere opencv-python Pillow torch transformers openai

Project Structure, Usage, and Customization

BLIP: 🔗 

Cohere AI: 🔗

Project Structure

Usage

  1. Set up your API keys in the config.py file: cohere_api_key = **"YOUR_COHERE_API_KEY"**
  2. cohere_api_key = **"YOUR_COHERE_API_KEY"**& in `config.py

    1. Run the main.py file:

      python main.py

    2. Press ‘q’ on the ‘Camera Window’ to quit.

Have fun! Make sure to do some activity for the camera for maximum fun! Show your surroundings, more objects, people, or pets! Also, overtime it increases its understanding of your surroundings and would keep generating better & better outputs.

Use your iPhone as a webcam on Mac: 🔗

MacOS CPU/GPU Support:

Install PyTorch For M1:

PT tutorial is live, follow these instructions to install PyTorch on Apple Silicon: https://medium.com/@vkkvben10/how-to-install-pytorch-on-apple-silicon-mac-m1-m2-easiest-guide-d31a7c683367

Pre: macOS Version PyTorch is supported on macOS 10.15 (Catalina) or above.

Install TensorFlow For M1:

Tensorflow Model was recently added to Hugging Face. TF update coming soon. Meanwhile:

🔗 ← Follow the instructions to install TensorFlow on your own. (Currently Optional)

(Option to switch between Mac CPU & GPU soon.)

How it works

  1. The program captures webcam frames.
  2. Frames are converted to PIL images.
  3. Captions are generated using the BLIP captioning model.
  4. Conversational responses are generated based on the captions using the Cohere AI's API.
  5. Captions and responses are displayed on the webcam feed in real time.

Example

The bot captures an image of a person working on their computer:

Customizing the bot

You can customize the bot by modifying the Prompt in the response_generation.py file or adjusting the settings, such as max_tokens and temperature, when calling the Cohere API.

Notes

Credits

This project utilizes the BLIP model for generating image captions. Special thanks Salesforce's Research team for their work on BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation using Transformers. Their research and model have greatly contributed to developing this video caption to interaction bot.

Special Thanks

Thank you to Cohere AI for their unwavering support and motivation throughout this project. Your encouragement and cutting-edge technology have played a crucial role in our success, and I'm grateful for the opportunity to collaborate and innovate together. Here's to pushing boundaries and shaping the future of AI!

Future Updates:

  1. An API Rate Limiter.
  2. GPT-3.5 and GPT-4 for more extended generations and Chat Support.
  3. Llama, Alpaca and other LLMs support for running everything locally.
  4. Chat Input messages to have a conversation.
  5. Voice Input & Output Support
  6. Ability to fine-tune BLIP (Caption Model)
  7. Ability to fine-tune LLMs
  8. CPU & ‘Cuda’ Support
  9. Ability to Switch between Full-precision & Half-precision.