β Star us on GitHub, join our Discord, or follow us on XThis notebook demonstrates how to set up and leverage CAMELβs ability to do video analysis.In this notebook, youβll explore:
CAMEL: A powerful multi-agent framework that enables Retrieval-Augmented Generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.
Video Analysis: How to use CAMEL to read and generate descriptions of uploaded videos.
import osfrom getpass import getpass# Prompt for the API key securelyopenai_api_key = getpass('Enter your API key: ')os.environ["OPENAI_API_KEY"] = openai_api_key
Alternatively, if running on Colab, you could save your API keys and tokens as Colab Secrets, and use them across notebooks.To do so, comment out the above manual API key prompt code block(s), and uncomment the following codeblock.β οΈ Donβt forget granting access to the API key you would be using to the current notebook.
Copy
# import os# from google.colab import userdata# os.environ["OPENAI_API_KEY"] = userdata.get("OPENAI_API_KEY")
# Provide your video pathvideo_cctv = "/content/CCTV.mov"with open(video_cctv, "rb") as video_cctv: video_bytes_cctv = video_cctv.read()# Set user messageuser_msg_cctv = BaseMessage.make_user_message( role_name="User", content="These are frames from a video that I want to upload. Generate a" "compelling description that I can upload along with the video.", video_bytes=video_bytes_cctv,)# Get response informationresponse_cctv = camel_agent.step(user_msg_cctv)print(response_cctv.msgs[0].content)
Copy
# Provide your video pathvideo_help = "/content/help.mov"with open(video_help, "rb") as video_help: video_bytes_help = video_help.read()# Set user messageuser_msg_help = BaseMessage.make_user_message( role_name="User", content="These are frames from a video that I want to upload. Generate a" "compelling description that I can upload along with the video.", video_bytes=video_bytes_help,)# Get response informationresponse_help = camel_agent.step(user_msg_help)print(response_help.msgs[0].content)
Copy
# Provide your video pathvideo_content_mode = "/content/content mod.mov"with open(video_content_mode, "rb") as video_content_mode: video_bytes_content_mode = video_content_mode.read()# Set user messageuser_msg_content_mode = BaseMessage.make_user_message( role_name="User", content="These are frames from a video that I want to upload. Generate a" "compelling description that I can upload along with the video.", video_bytes=video_bytes_content_mode,)# Get response informationresponse_content_mode = camel_agent.step(user_msg_content_mode)print(response_content_mode.msgs[0].content)
This notebook has guided you through setting up an agent and analyzing videos using CAMEL.Now, you know how to generate description for uploaded videos.Thatβs everything: Got questions about π« CAMEL-AI? Join us on Discord! Whether you want to share feedback, explore the latest in multi-agent systems, get support, or connect with others on exciting projects, weβd love to have you in the community! π€Check out some of our other work: