File size: 1,635 Bytes
f0f0344 | 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 | --- Inference_Causal.py 2026-11-15 21:30:09.717290004 +0000
+++ inference_episode.py 2026-11-15 21:31:57.654121478 +0000
@@ -117,6 +117,25 @@
for i, batch_data in tqdm(enumerate(dataloader), disable=(local_rank != 0)):
idx = batch_data['idx'].item()
+ # [MOD 1] output name from CSV episode_id
+ import pandas as _pd
+ if i == 0:
+ _meta = _pd.read_csv(config.data_path)
+ episode_id = str(_meta["episode_id"][idx])
+ output_path = f"{args.output_folder}/{episode_id}.mp4"
+ # [MOD 3] skip if output exists with correct frame count (81 per shot)
+ if os.path.exists(output_path):
+ import subprocess as _sp
+ _expected = 81 * int(_meta["shot_num_from_caption"][idx])
+ _n = _sp.run(["ffprobe", "-v", "error", "-count_frames", "-select_streams", "v:0", "-show_entries",
+ "stream=nb_read_frames", "-of", "csv=p=0", output_path], capture_output=True, text=True).stdout.strip()
+ if _n == str(_expected):
+ print(f"[EPISODE] skip {episode_id} (exists, {_n} frames)", flush=True)
+ continue
+ # [MOD 2] per-episode seed
+ set_seed(args.seed)
+ print(f"[EPISODE] start {episode_id} seed={args.seed}", flush=True)
+
if isinstance(batch_data, dict):
batch = batch_data
elif isinstance(batch_data, list):
@@ -136,6 +155,5 @@
pipeline.vae.model.clear_cache()
- caption=batch['shots_captions'][0][-1][0][0]
- output_path = f"{args.output_folder}/{i:03d}_{caption[:50]}.mp4"
write_video(output_path, video[0], fps=16)
+ print(f"[EPISODE] saved {episode_id} -> {output_path}", flush=True)
|