I have uploaded a test video to S3 and am trying to get Nova to understand it. This should be fairly straightforward, and I believe I followed the code samples accurately, but I'm getting an error that I haven't been able to resolve.
My input:
{
"schemaVersion": "messages-v1",
"messages": [
{
"role": "user",
"content": [
{
"video": {
"format": "mp4",
"source": {
"s3Location": {
"uri": "s3://my-bucket/sample_video_for_understanding.mp4"
}
}
}
},
{
"text": "Provide a description of the video"
}
]
}
],
"system": [
{
"text": "You are an expert media analyst. When the user provides you with a video, analyze it carefully to answer the questions"
}
],
"inferenceConfig": {
"maxTokens": 600,
"topP": 0.9,
"topK": 20,
"temperature": 0.3
}
}
My code snippet:
MODEL_ID = "arn:aws:bedrock:us-west-2:<myaccountid>:inference-profile/us.amazon.nova-pro-v1:0"
client = boto3.client(
"bedrock-runtime",
aws_access_key_id = AWS_ACCESS_KEY_ID,
aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
aws_session_token = AWS_SESSION_TOKEN,
region_name="us-west-2",
)
response = client.invoke_model(
modelId=MODEL_ID,
body=json.dumps(native_request)
)
The error:
An error occurred (ValidationException) when calling the InvokeModel operation: Invalid Input: The input does not adhere to the expected standards. Please refer to the model user guide and adjust the input before trying again.
File "C:\Users\\src\tools\nova_test\video_understanding.py", line 76, in analyze_video
response = client.invoke_model(
File "C:\Users\\src\tools\nova_test\video_understanding.py", line 93, in <module>
resp = analyze_video(path)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Invalid Input: The input does not adhere to the expected standards. Please refer to the model user guide and adjust the input before trying again.
I can't find what I did wrong. Can you?
I have uploaded a test video to S3 and am trying to get Nova to understand it. This should be fairly straightforward, and I believe I followed the code samples accurately, but I'm getting an error that I haven't been able to resolve.
My input:
{
"schemaVersion": "messages-v1",
"messages": [
{
"role": "user",
"content": [
{
"video": {
"format": "mp4",
"source": {
"s3Location": {
"uri": "s3://my-bucket/sample_video_for_understanding.mp4"
}
}
}
},
{
"text": "Provide a description of the video"
}
]
}
],
"system": [
{
"text": "You are an expert media analyst. When the user provides you with a video, analyze it carefully to answer the questions"
}
],
"inferenceConfig": {
"maxTokens": 600,
"topP": 0.9,
"topK": 20,
"temperature": 0.3
}
}
My code snippet:
MODEL_ID = "arn:aws:bedrock:us-west-2:<myaccountid>:inference-profile/us.amazon.nova-pro-v1:0"
client = boto3.client(
"bedrock-runtime",
aws_access_key_id = AWS_ACCESS_KEY_ID,
aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
aws_session_token = AWS_SESSION_TOKEN,
region_name="us-west-2",
)
response = client.invoke_model(
modelId=MODEL_ID,
body=json.dumps(native_request)
)
The error:
An error occurred (ValidationException) when calling the InvokeModel operation: Invalid Input: The input does not adhere to the expected standards. Please refer to the model user guide and adjust the input before trying again.
File "C:\Users\\src\tools\nova_test\video_understanding.py", line 76, in analyze_video
response = client.invoke_model(
File "C:\Users\\src\tools\nova_test\video_understanding.py", line 93, in <module>
resp = analyze_video(path)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Invalid Input: The input does not adhere to the expected standards. Please refer to the model user guide and adjust the input before trying again.
I can't find what I did wrong. Can you?
Share Improve this question asked Mar 22 at 3:07 NevoNevo 9583 gold badges12 silver badges31 bronze badges2 Answers
Reset to default 0It seems you may mistakenly be using the batch inference format when using the invoke_model
method.
Have a look at the samples on this page of the Video Understanding Guide that show how to correctly build the prompt for video understanding.
Here is an example of how to build the request for a video object residing in an S3 bucket. Copying directly from the linked resource:-
MODEL_ID = "us.amazon.nova-lite-v1:0"
# Define your system prompt(s).
system_list = [
{
"text": "You are an expert media analyst. When the user provides you with a video, provide 3 potential video titles"
}
]
# Define a "user" message including both the video and a text prompt.
message_list = [
{
"role": "user",
"content": [
{
"video": {
"format": "mp4",
"source": {
"s3Location": {
"uri": "s3://my_bucket/my_video.mp4",
"bucketOwner": "111122223333"
}
}
}
},
{
"text": "Provide video titles for this clip."
}
]
}
]
# Configure the inference parameters.
inf_params = {"maxTokens": 300, "topP": 0.1, "topK": 20, "temperature": 0.3}
native_request = {
"schemaVersion": "messages-v1",
"messages": message_list,
"system": system_list,
"inferenceConfig": inf_params,
}
# Invoke the model and extract the response body.
response = client.invoke_model(modelId=MODEL_ID,
You're using AWS Nova in cross-region setting, but it seems that currently, as to this day, Nova doesn't support cross-region in the same way as other models. You need to always specify "us-east-1" and it will have access to all of the regions for S3, etc.
Example, you're using in "us-west-2" region. But you should use:
client = boto3.client(
"bedrock-runtime",
aws_access_key_id = AWS_ACCESS_KEY_ID,
aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
aws_session_token = AWS_SESSION_TOKEN,
region_name="us-east-1",
)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744326071a4568653.html
评论列表(0条)