vrishv commited on
Commit
f4f8d1a
·
verified ·
1 Parent(s): 527b28a

10 fps clips with the first 8 frames trimmed

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +5 -3
README.md CHANGED
@@ -13,6 +13,6 @@ short_description: FLUX.1-schnell stills animated with LTX-Video
13
  # Graphics Studio
14
 
15
  1. **FLUX.1-schnell** (black-forest-labs) turns a prompt into a 1152×768 still in 4 steps.
16
- 2. **LTX-Video** (Lightricks) animates that still, or any uploaded image, into a 2 to 8 second clip at 768×512, 24 fps.
17
 
18
  Runs on ZeroGPU: set the Space hardware to **ZeroGPU** in Settings.
 
13
  # Graphics Studio
14
 
15
  1. **FLUX.1-schnell** (black-forest-labs) turns a prompt into a 1152×768 still in 4 steps.
16
+ 2. **LTX-Video** (Lightricks) animates that still, or any uploaded image, into a 2 to 8 second clip at 768×512, 10 fps.
17
 
18
  Runs on ZeroGPU: set the Space hardware to **ZeroGPU** in Settings.
app.py CHANGED
@@ -17,7 +17,8 @@ VIDEO_MODEL = "Lightricks/LTX-Video-0.9.5"
17
 
18
  IMAGE_WIDTH, IMAGE_HEIGHT = 1152, 768 # 3:2, multiples of 16 for FLUX
19
  VIDEO_WIDTH, VIDEO_HEIGHT = 768, 512 # 3:2, multiples of 32 for LTX-Video
20
- FPS = 24
 
21
  MAX_SEED = 2**31 - 1
22
 
23
  NEGATIVE_PROMPT = ("worst quality, inconsistent motion, blurry, jittery, distorted, "
@@ -63,7 +64,8 @@ def make_video(image, scene_prompt, motion_prompt, seconds, steps, seed, randomi
63
  if image is None:
64
  raise gr.Error("Make or upload an image first.")
65
  seed = pick_seed(seed, randomize_seed)
66
- num_frames = int(seconds * FPS) // 8 * 8 + 1 # LTX-Video wants 8n+1 frames
 
67
  # LTX-Video needs the scene AND the motion described, or it tends to hold the picture still
68
  motion = motion_prompt.strip() or "gentle cinematic camera motion, natural movement"
69
  prompt = f"{scene_prompt.strip()}. {motion}" if scene_prompt.strip() else motion
@@ -82,7 +84,7 @@ def make_video(image, scene_prompt, motion_prompt, seconds, steps, seed, randomi
82
  generator=torch.Generator("cpu").manual_seed(seed),
83
  ).frames[0]
84
  path = f"/tmp/video_{seed}.mp4"
85
- export_to_video(frames, path, fps=FPS)
86
  return path, seed
87
 
88
 
 
17
 
18
  IMAGE_WIDTH, IMAGE_HEIGHT = 1152, 768 # 3:2, multiples of 16 for FLUX
19
  VIDEO_WIDTH, VIDEO_HEIGHT = 768, 512 # 3:2, multiples of 32 for LTX-Video
20
+ FPS = 10
21
+ TRIM_FRAMES = 8 # Frames cut from the start of every clip, where the noise is
22
  MAX_SEED = 2**31 - 1
23
 
24
  NEGATIVE_PROMPT = ("worst quality, inconsistent motion, blurry, jittery, distorted, "
 
64
  if image is None:
65
  raise gr.Error("Make or upload an image first.")
66
  seed = pick_seed(seed, randomize_seed)
67
+ # Generate the clip plus the frames that get cut off. LTX-Video wants 8n+1 frames.
68
+ num_frames = -(-(int(seconds * FPS) + TRIM_FRAMES - 1) // 8) * 8 + 1
69
  # LTX-Video needs the scene AND the motion described, or it tends to hold the picture still
70
  motion = motion_prompt.strip() or "gentle cinematic camera motion, natural movement"
71
  prompt = f"{scene_prompt.strip()}. {motion}" if scene_prompt.strip() else motion
 
84
  generator=torch.Generator("cpu").manual_seed(seed),
85
  ).frames[0]
86
  path = f"/tmp/video_{seed}.mp4"
87
+ export_to_video(frames[TRIM_FRAMES:], path, fps=FPS)
88
  return path, seed
89
 
90