来了!TwelveLabs视频理解模型登陆Bedrock

今年早些时候,亚马逊云科技曾预告TwelveLabs视频理解模型即将登陆Amazon Bedrock。现在,这些模型已正式上线Amazon Bedrock,可助力用户精准可靠地完成视频内容检索、场景分类、内容摘要生成及视频信息提取等任务。
TwelveLabs推出的两款视频模型分别为:
1.擅长执行搜索与分类等任务的视频嵌入模型Marengo。
2.能够基于视频数据生成文本的视频语言模型Pegasus。
两款模型在Amazon SageMaker HyperPod上进行训练,可实现突破性的视频分析功能,提供文本摘要、元数据生成以及创意优化服务。
使用Amazon Bedrock中的TwelveLabs模型,您可以通过自然语言视频搜索功能,精准定位视频特定片段。例如输入“比赛中首个达阵瞬间”或“主角首次相遇场景”,即可立即跳转到视频对应画面。
此外,用户还能开发应用程序来解析视频内容,自动生成标题、主题、话题标签、摘要、章节或精彩片段等描述性文本,无需预先设定标签或分类,即可快速挖掘视频中的关键信息与内在关联。
例如,您可以在客户反馈中发现反复出现的主题,或识别出此前未曾察觉的产品使用模式。无论您拥有数百小时还是数千小时的视频内容,都能将整个视频库转化为可搜索的知识资源,同时确保企业级的安全性和性能表现。
您可点击观看TwelveLabs的Marengo和Pegasus模型演示视频。
借助这些模型,各行各业都能优化视频工作流程,例如:
媒体制作人和编辑可即时定位特定场景或对话,无需耗费数小时筛选素材,从而能够专注于叙事创作。
营销团队通过快速定制个性化内容,引发不同受众群体的共鸣,从而优化广告工作流程。
安保团队则利用该技术,跨多个视频流识别模式,主动预判潜在风险。
在Amazon Bedrock中
开始使用TwelveLabs模型
在开始使用前,如果您是首次接触TwelveLabs模型,请前往Amazon Bedrock控制台,在左下角的导航面板中选择“模型访问”。
如需使用最新版本的TwelveLabs模型,请在TwelveLabs平台申请Marengo Embed 2.7和Pegasus 1.2模型的访问权限。

要在Amazon Bedrock中使用TwelveLabs模型,请在左侧导航面板的“测试”部分下选择“聊天或文本交互界面”。点击“选择模型”,将类别选为“TwelveLabs”,模型选为“Pegasus”,然后点击“应用”。

要从视频中搜索或生成文本,您需将视频上传至Amazon S3存储桶,或输入以Base64格式编码的视频字符串。
本例将使用借助Amazon Nova Reel生成的示例视频进行演示,该视频的生成提示词为:一只可爱的水獭在水下弹吉他。
输入已上传视频的Amazon S3 URI以及Amazon S3存储桶所有者信息,然后运行提示指令:按时间线向我介绍视频内容。

模型生成回复如下:
The video opens with an underwater scene featuring a sandy seabed and swaying seaweed, creating a serene atmosphere. At around 5 seconds, a raccoon appears, swimming towards the camera with a curious expression. By 10 seconds, the raccoon is seen swimming near the seabed. The focus then shifts to a group of koi fish swimming gracefully near the seabed from 11 to 13 seconds.
At 14 seconds, the scene transitions to an ukulele resting on the seabed, with the camera zooming in to highlight its details. The raccoon reappears at 20 seconds, swimming among the koi fish, and by 23 seconds, it begins to play the ukulele. The raccoon continues to play the ukulele from 29 to 41 seconds, with the koi fish swimming around it, adding a lively and colorful touch to the underwater setting.
From 42 to 49 seconds, the raccoon is shown playing the ukulele with the koi fish swimming around it. The video concludes with a screen displaying "Video generated with Amazon Novo Reel 1.1" and "Available in Amazon Bedrock" from 50 to 54 seconds, followed by the Amazon Web Services logo from 55 to 57 seconds.
借助Amazon Bedrock Converse API,可轻松将TwelveLabs模型集成至您的应用程序中。
使用Amazon Web Services Python(Boto3)调用TwelveLabs Pegasus模型的示例如下。
import boto3import jsonimport os
AWS_REGION = "us-east-1"MODEL_ID = "twelvelabs.pegasus-1-2-v1:0"VIDEO_PATH = "sample.mp4"
def read_file(file_path: str) -> bytes: """Read a file in binary mode.""" try: with open(file_path, 'rb') as file: return file.read() except Exception as e: raise Exception(f"Error reading file {file_path}: {str(e)}")
bedrock_runtime = boto3.client( service_name="bedrock-runtime", region_name=AWS_REGION)
request_body = { "messages": [ { "role": "user", "content": [ { "inputPrompt": "tell me about the video", "mediaSource": { "base64String": read_file(VIDEO_PATH) } }, ], } ]}
response = bedrock_runtime.converse( modelId=MODEL_ID, messages=request_body["messages"])
print(response["output"]["message"]["content"][-1]["text"])左右滑动查看完整示意
TwelveLabs Marengo Embed 2.7模型可从视频、文本、音频或图像输入中,生成向量嵌入,并可用于相似性搜索、聚类分析及其他机器学习任务。该模型通过Amazon Bedrock AsyncInvokeModel API支持异步推理。
对于视频源,您可以使用AsyncInvokeModel API,为TwelveLabs Marengo Embed 2.7模型请求生成.json格式的输出。
{ "modelId": "twelvelabs.marengo-embed-2.7", "modelInput": { "inputType": "video", "mediaSource": { "s3Location": { "uri": "s3://your-video-object-s3-path", "bucketOwner": "your-video-object-s3-bucket-owner-account" } } }, "outputDataConfig": { "s3OutputDataConfig": { "s3Uri": "s3://your-bucket-name" } }}左右滑动查看完整示意
您可将响应结果传输至指定的Amazon S3存储位置。
{ "embedding": [0.345, -0.678, 0.901, ...], "embeddingOption": "visual-text", "startSec": 0.0, "endSec": 5.0}左右滑动查看完整示意
为帮助您快速上手,特别为您提供了针对多种应用场景和不同编程语言的丰富代码示例。
更多信息,请参阅亚马逊云科技文档中关于TwelveLabs Pegasus 1.2和TwelveLabs Marengo Embed 2.7的详细说明。
代码示例:
https://docs.aws.amazon.com/bedrock/latest/userguide/service_code_examples.html
TwelveLabs Pegasus 1.2详细说明:
https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-pegasus.html
TwelveLabs Marengo Embed 2.7详细说明:
https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-marengo.html
现已可用
TwelveLabs模型现已在Amazon Bedrock中全面上线:
Marengo模型可在美国东部(弗吉尼亚北部)、欧洲(爱尔兰)和亚太(首尔)区域使用。
Pegasus模型则可在美国西部(俄勒冈)和欧洲(爱尔兰)区域使用,且支持从美国和欧洲区域进行跨区域推理调用。
您可参阅完整区域列表,获取未来更新信息。更多信息,请参阅Amazon Bedrock产品页面上的TwelveLabs专区以及Amazon Bedrock定价页面。
立即在Amazon Bedrock控制台中,开始体验TwelveLabs模型!
完整区域列表:
https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html?trk=769a1a2b-8c19-4976-9c45-b6b1226c7d20&sc_channel=el
TwelveLabs专区:
https://aws.amazon.com/bedrock/twelvelabs/?trk=769a1a2b-8c19-4976-9c45-b6b1226c7d20&sc_channel=el
Amazon Bedrock定价页面:
https://aws.amazon.com/bedrock/pricing/?trk=769a1a2b-8c19-4976-9c45-b6b1226c7d20&sc_channel=el
本篇作者

Channy Yun
亚马逊云科技云的首席开发者布道师。作为一位务实的开发者和博客作者,他热爱社区驱动的技术学习和分享。


星标不迷路,开发更极速!
关注后记得星标「亚马逊云开发者」
听说,点完下面4个按钮
就不会碰到bug了!

点击阅读原文查看博客!获得更详细内容!
更多推荐
所有评论(0)