-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreference_to_video.py
More file actions
68 lines (52 loc) · 1.82 KB
/
reference_to_video.py
File metadata and controls
68 lines (52 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Seedance 2.0 Reference-to-Video example (fal.ai).
Model: bytedance/seedance-2.0/fast/reference-to-video
Docs: https://fal.ai/models/bytedance/seedance-2.0/fast/reference-to-video/api
Provide up to 9 images, 3 videos, and 3 audio clips as references. Refer to
them inside the prompt as @Image1, @Video1, @Audio1, etc. The total number of
files across all modalities must not exceed 12.
Run:
export FAL_KEY="your_fal_api_key"
pip install -r ../../requirements.txt
python reference_to_video.py
"""
import os
import sys
import fal_client
MODEL_ID = os.environ.get(
"SEEDANCE_MODEL", "bytedance/seedance-2.0/fast/reference-to-video"
)
REF_IMAGE = (
"https://v3b.fal.media/files/b/0a8eba37/"
"Cqg-4Uwzyz4DELfceT1CF_a17e588773ec45b1a9e6f100a787b80b.jpg"
)
def on_queue_update(update):
if isinstance(update, fal_client.InProgress):
for log in update.logs or []:
print(log["message"])
def main() -> int:
if not os.environ.get("FAL_KEY"):
print("Error: FAL_KEY environment variable is not set.", file=sys.stderr)
return 1
result = fal_client.subscribe(
MODEL_ID,
arguments={
"prompt": (
"The character in @Image1 walks through a bustling night market, "
"neon signs reflecting in puddles, cinematic dolly-in, ambient "
"market chatter and distant music."
),
"image_urls": [REF_IMAGE],
"resolution": "720p",
"duration": "8",
"aspect_ratio": "16:9",
"generate_audio": True,
},
with_logs=True,
on_queue_update=on_queue_update,
)
print("\nDone.")
print("Video URL:", result["video"]["url"])
print("Seed: ", result["seed"])
return 0
if __name__ == "__main__":
raise SystemExit(main())