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.
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.
cohere
opencv-python
Pillow
torch
transformers
OpenAI (optional)
main2exp.py
You can install the required packages using the following command:
pip install cohere opencv-python Pillow torch transformers openai
config.py
: Contains API keys and other configurations.image_processing.py
: Contains functions related to image processing.caption_generation.py
: Contains functions related to caption generation using the Blip model.response_generation.py
: Contains functions related to response generation using the Cohere AI API.main.py
: The main file that runs the program.config.py
file: cohere_api_key = **"YOUR_COHERE_API_KEY"**
cohere_api_key = **"YOUR_COHERE_API_KEY"**
& in `config.py
Run the main.py
file:
python main.py
Press ‘q’ on the ‘Camera Window’ to quit.
def process_frame(frame):
current_time - last_generation_time >= 3
for more or less LLM generations. Optimal ‘captions > 2 .’def main_loop():
current_time - last_process_time >= 2:
to generate more or less image processing (captions) ‘2’ = optimal, ‘0’ = realtimeHave 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.
python main.py
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.
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.)
The bot captures an image of a person working on their computer:
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.
float16
); future updates to include support for Cuda.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.
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!