Gemini Omni Flash (gemini-omni-flash-preview) เป็นโมเดลแบบหลายรูปแบบที่มีประสิทธิภาพสูง ซึ่งออกแบบมาสำหรับการสร้างและตัดต่อวิดีโอด้วยความเร็วสูง รวมถึงการควบคุมแบบภาพยนตร์
Gemini Omni สร้างขึ้นโดยอาศัยความสามารถหลักต่อไปนี้ที่ทำให้โมเดลนี้แตกต่างจากโมเดลวิดีโอรุ่นก่อนๆ
- ความสามารถในการประมวลผลข้อมูลหลายรูปแบบในตัว: โมเดลนี้ประมวลผลข้อความ รูปภาพ เสียง และวิดีโอพร้อมกัน จึงให้เอาต์พุตที่สอดคล้องและควบคุมได้มากขึ้น
- การตัดต่อแบบสนทนา: โมเดลนี้ใช้ Interactions API เพื่อให้คุณปรับแต่ง และตัดต่อวิดีโอซ้ำๆ ได้ผ่านการสนทนาด้วยภาษาธรรมชาติ เพียงอธิบายสิ่งที่คุณต้องการเปลี่ยนแปลง แล้วโมเดลจะทำการแก้ไขโดยคงส่วนของวิดีโอที่คุณต้องการไว้
- ความรู้เกี่ยวกับโลก: Gemini Omni ผสานความเข้าใจด้านฟิสิกส์เข้ากับความรู้ด้านประวัติศาสตร์ วิทยาศาสตร์ และบริบททางวัฒนธรรมของ Gemini เพื่อเชื่อมช่องว่างระหว่างความสมจริงแบบภาพถ่ายกับการเล่าเรื่องที่มีความหมาย
การสร้างวิดีโอจากข้อความ
สร้างวิดีโอจากพรอมต์ข้อความ โมเดลจะสร้างวิดีโอพร้อมเสียงโดยอิงตามคำอธิบายข้อความของคุณ เขียนพรอมต์โดยระบุรายละเอียดต่างๆ เช่น คำอธิบายฉาก การเคลื่อนไหวของกล้อง แสง และอารมณ์ เพื่อให้ได้ผลลัพธ์ที่ดีที่สุด
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."
}'
สคีมาการตอบกลับ REST
ฟิลด์ interaction.output_video ที่ใช้งานง่ายนี้ใช้ได้กับ SDK เท่านั้น
รับเอาต์พุตวิดีโอจากอาร์เรย์ steps เมื่อใช้ REST API โดยตรง
โครงสร้าง JSON ของ REST แบบข้อมูลดิบ
{
"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"
}
ควบคุมสัดส่วนภาพ
ตั้งค่า aspect_ratio เป็น "9:16" เพื่อสร้างวิดีโอแนวตั้ง โดยค่าเริ่มต้นจะเป็นแนวนอน (16:9)
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"
}
}'
การสร้างวิดีโอจากรูปภาพ
คุณสามารถระบุรูปภาพอ้างอิงพร้อมกับพรอมต์ข้อความได้ โดยโมเดลจะตัดสินใจว่าจะใช้รูปภาพอย่างไร ทั้งนี้ขึ้นอยู่กับพรอมต์ ซึ่งมีประโยชน์ในการทำให้ภาพผลิตภัณฑ์ ภาพประกอบ หรือภาพถ่ายดูมีชีวิตชีวา
ตัวอย่างต่อไปนี้แสดงวิธีใช้รูปภาพอ้างอิงเป็นภาพวาดปลาที่กระโดดขึ้นมาจากน้ำ
โดยใช้พรอมต์ต่อไปนี้
turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video
เพื่อสร้างวิดีโอภาพวาดที่ดูสมจริง
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"}
]
}'
การอ้างอิงตัวแบบ
คุณสามารถสร้างวิดีโอที่รวมตัวแบบเฉพาะที่ระบุเป็นรูปภาพอ้างอิงได้ ตัวอย่างเช่น โค้ดต่อไปนี้แสดงวิธีระบุรูปภาพแมวและเส้นด้าย 2 ภาพเพื่อสร้างวิดีโอแมวเล่นกับเส้นด้าย
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."}
]
}'
พารามิเตอร์งาน
ใช้พารามิเตอร์ task ใน video-config เพื่อระบุลักษณะการทำงานที่ต้องการอย่างชัดเจน เช่น หากต้องการให้โมเดลสร้างวิดีโอจากรูปภาพ คุณสามารถตั้งค่าพารามิเตอร์เป็น image_to_video หากไม่ได้ตั้งค่า โมเดลจะอนุมานสิ่งที่คุณต้องการจากพรอมต์
ค่าที่อนุญาตมีดังนี้
text_to_videoimage_to_videoreference_to_videoedit
ตัวอย่างต่อไปนี้แสดงวิธีตั้งค่าพารามิเตอร์นี้สำหรับตัวอย่างการสร้างวิดีโอจากรูปภาพที่แสดงก่อนหน้านี้
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