MCPcopy Create free account
hub / github.com/CompVis/zigma / get_data_generator

Function get_data_generator

train_acc.py:287–325  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

285 model_fn = ema_model.forward
286
287 def get_data_generator():
288 _init = train_steps
289 while True:
290 for data in tqdm(
291 loader,
292 disable=not accelerator.is_main_process,
293 initial=_init,
294 desc="train_steps",
295 ):
296 if args.use_latent:
297 if has_text(args):
298 _cap_feats = data["caption_feature"]
299 B, N, T, C = _cap_feats.shape # each image has N captions
300 yield data["img_feature"].to(device), _cap_feats[
301 :, random.randint(0, N - 1)
302 ].to(device)
303 elif "facehq" in str(args.data.name):
304 yield data["latent"].to(device), None
305 elif "ucf101" in str(args.data.name):
306 yield data["frame_feature256"].to(device), data["cls_id"].to(
307 device
308 )
309 elif "celebav" in str(args.data.name):
310 _start = random.randint(
311 0,
312 data["frame_feature256"].shape[1]
313 - args.model.params.video_frames
314 - 1,
315 )
316 _video = data["frame_feature256"][
317 :, _start : _start + args.model.params.video_frames
318 ].to(device)
319 yield _video, None
320 else:
321 raise NotImplementedError(
322 f"latent data not supported, args.data.name={args.data.name}"
323 )
324 else:
325 yield data["image"].to(device), None
326
327 def get_real_img_generator(): # [0,255]
328 while True:

Callers 1

mainFunction · 0.70

Calls 2

has_textFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected