Gemini Omni Flash (gemini-omni-flash-preview) là một mô hình đa phương thức hiệu suất cao, được thiết kế để tạo và chỉnh sửa video ở tốc độ cao, cũng như kiểm soát chất lượng điện ảnh.
Gemini Omni được xây dựng dựa trên những chức năng cốt lõi sau đây, giúp phân biệt mô hình này với các mô hình video trước đây:
- Đa phương thức tự nhiên: Gemini xử lý đồng thời văn bản, hình ảnh, âm thanh và video, mang đến cho bạn kết quả nhất quán, mạch lạc và dễ kiểm soát hơn.
- Chỉnh sửa bằng ngôn ngữ tự nhiên: được hỗ trợ bởi Interactions API, tính năng này cho phép bạn tinh chỉnh và chỉnh sửa video nhiều lần thông qua cuộc trò chuyện bằng ngôn ngữ tự nhiên. Mô tả nội dung bạn muốn thay đổi và mô hình sẽ áp dụng nội dung chỉnh sửa trong khi vẫn giữ lại những phần bạn muốn giữ lại trong video.
- Kiến thức về thế giới: Gemini Omni kết hợp kiến thức về vật lý với kiến thức của Gemini về lịch sử, khoa học và bối cảnh văn hoá, thu hẹp khoảng cách từ tính chân thực của ảnh đến khả năng kể chuyện có ý nghĩa.
Tạo video từ văn bản
Tạo video từ câu lệnh văn bản. Mô hình này tạo video có âm thanh dựa trên nội dung mô tả bằng văn bản của bạn. Viết câu lệnh có các thông tin chi tiết như nội dung mô tả cảnh, chuyển động của camera, ánh sáng và tâm trạng để có kết quả tốt nhất.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input="A marble rolling fast on a chain reaction style track, continuous smooth shot."
)
with open("marble.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: 'A marble rolling fast on a chain reaction style track, continuous smooth shot.',
});
if (interaction.output_video?.data) {
fs.writeFileSync('marble.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": "A marble rolling fast on a chain reaction style track, continuous smooth shot."
}'
Giản đồ phản hồi REST
Trường tiện ích interaction.output_video là chỉ dành cho SDK.
Nhận đầu ra video từ mảng steps khi sử dụng trực tiếp API REST.
Cấu trúc JSON REST thô:
{
"steps": [
{ "type": "user_input", "content": [{"type": "text", "text": "..."}] },
{ "type": "thought", "content": [{"text": "...", "type": "thought"}] },
{
"type": "model_output",
"content": [
{
"type": "video",
"mime_type": "video/mp4",
"data": "AAAAIGZ0eXBpc29t..." // Base64 encoded video data
}
]
}
],
"id": "v1_...",
"status": "completed",
"model": "gemini-omni-flash-preview",
"object": "interaction"
}
Kiểm soát tỷ lệ khung hình
Đặt aspect_ratio thành "9:16" để tạo video dọc. Hướng ngang (16:9) là hướng mặc định.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input="A futuristic city with neon lights and flying cars, cyberpunk style",
response_format={
"type": "video", # optional
"aspect_ratio": "9:16" # Supported values: "9:16", "16:9"
}
)
with open("example.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: 'A futuristic city with neon lights and flying cars, cyberpunk style',
response_format: {
type: 'video', // optional
aspect_ratio: '9:16' // Supported values: '9:16', '16:9'
},
});
if (interaction.output_video?.data) {
fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": "A futuristic city with neon lights and flying cars, cyberpunk style",
"response_format": {
"type": "video",
"aspect_ratio": "9:16"
}
}'
Tạo video từ hình ảnh
Bạn có thể cung cấp một hình ảnh tham khảo cùng với câu lệnh dạng văn bản. Tuỳ thuộc vào câu lệnh của bạn, mô hình sẽ quyết định cách sử dụng hình ảnh. Tính năng này hữu ích khi bạn muốn làm cho ảnh chụp sản phẩm, hình minh hoạ hoặc ảnh chụp trở nên sống động.
Ví dụ sau đây cho thấy cách sử dụng hình ảnh tham khảo của một bức vẽ con cá nhảy ra khỏi mặt nước:
Với câu lệnh sau:
turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video
Để tạo video chân thực về bản vẽ.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input=[
{"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
{"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
],
)
with open("clownfish.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: [
{ type: 'image', data: base64Image, mime_type: 'image/jpeg' },
{ type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
]
});
if (interaction.output_video?.data) {
fs.writeFileSync('clownfish.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": [
{"type": "image", "data": "'"$BASE64_IMAGE"'", "mime_type": "image/jpeg"},
{"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
]
}'
Tham chiếu đối tượng
Bạn có thể tạo một video có chứa các chủ đề cụ thể được cung cấp dưới dạng hình ảnh tham khảo. Ví dụ: mã sau đây cho biết cách cung cấp 2 hình ảnh về một con mèo và cuộn len để tạo video về con mèo đang chơi với cuộn len.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input=[
{"type": "image", "data": cat_b64, "mime_type": "image/png"},
{"type": "image", "data": yarn_b64, "mime_type": "image/png"},
{"type": "text", "text": "A cat playfully batting at a ball of yarn."}
],
)
with open("cat.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: [
{ type: 'image', data: catData, mime_type: 'image/png' },
{ type: 'image', data: yarnData, mime_type: 'image/png' },
{ type: 'text', text: 'A cat playfully batting at a ball of yarn.' }
]
});
if (interaction.output_video?.data) {
fs.writeFileSync('cat.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": [
{"type": "image", "data": "'"$CAT_B64"'", "mime_type": "image/png"},
{"type": "image", "data": "'"$YARN_B64"'", "mime_type": "image/png"},
{"type": "text", "text": "A cat playfully batting at a ball of yarn."}
]
}'
Tham số Tasks
Sử dụng tham số task trong video-config để cho biết rõ hành vi dự kiến. Ví dụ: nếu bạn muốn mô hình tạo video từ một hình ảnh, bạn có thể đặt tham số thành image_to_video. Nếu bạn không đặt thuộc tính này, mô hình sẽ suy luận những gì bạn muốn từ câu lệnh.
Sau đây là các giá trị được phép:
text_to_videoimage_to_videoreference_to_videoedit
Ví dụ sau đây cho thấy cách thiết lập điều này cho ví dụ về hình ảnh thành video mà bạn thấy trước đó.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input=[
{"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
{"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
],
generation_config={
"video_config": {
"task": "image_to_video",
}
},
)
with open("example.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from "@google/genai";
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: [
{ type: 'image', data: base64Image, mime_type: 'image/jpeg' },
{ type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
],
generationConfig: {
videoConfig: {
task: 'image_to_video',
}
}
});
if (interaction.output_video?.data) {
fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}