MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / get_batch

Function get_batch

sat/sample_video.py:41–58  ·  view source on GitHub ↗
(keys, value_dict, N: Union[List, ListConfig], T=None, device="cuda")

Source from the content-addressed store, hash-verified

39
40
41def get_batch(keys, value_dict, N: Union[List, ListConfig], T=None, device="cuda"):
42 batch = {}
43 batch_uc = {}
44
45 for key in keys:
46 if key == "txt":
47 batch["txt"] = np.repeat([value_dict["prompt"]], repeats=math.prod(N)).reshape(N).tolist()
48 batch_uc["txt"] = np.repeat([value_dict["negative_prompt"]], repeats=math.prod(N)).reshape(N).tolist()
49 elif key in value_dict.keys():
50 batch[key] = value_dict[key]
51
52 if T is not None:
53 batch["num_video_frames"] = T
54
55 for key in batch.keys():
56 if key not in batch_uc and isinstance(batch[key], torch.Tensor):
57 batch_uc[key] = torch.clone(batch[key])
58 return batch, batch_uc
59
60
61def save_video_as_grid_and_mp4(video_batch: torch.Tensor, save_path: str, fps: int = 5, args=None, key=None, ind=None, foldername=None):

Callers 1

sampling_mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected