MCPcopy Create free account
hub / github.com/FreedomGu/Diffportrait360 / get_cond_control

Function get_cond_control

diffportrait360_release/code/inference.py:24–49  ·  view source on GitHub ↗
(args, batch_data, control_type, device, model=None,batch_size=None, train=True, seg_model=None)

Source from the content-addressed store, hash-verified

22 model.load_state_dict(state_dict, strict=strict)
23 del state_dict
24def get_cond_control(args, batch_data, control_type, device, model=None,batch_size=None, train=True, seg_model=None):
25 # Single-control
26 control_type = copy.deepcopy(control_type)[0]
27 if control_type == "GAN_Generated" :
28 if train:
29 #assert "pose_map" in batch_data
30 c_cat = batch_data["condition"].cuda()
31 cond_image = batch_data["condition_image"].cuda()
32 #import pdb;pdb.set_trace()
33
34 cond_image = model.get_first_stage_encoding(model.encode_first_stage(cond_image))
35 cond_img_cat = cond_image
36 else:
37 #assert "pose_map_list" in batch_data
38 pose_map_list = batch_data["condition"]
39 #print("Get Inference Control Type")
40 c_cat_list = pose_map_list
41 cond_image = batch_data["condition_image"].cuda()
42 cond_image = model.get_first_stage_encoding(model.encode_first_stage(cond_image))
43 cond_img_cat = cond_image.cuda()
44 else:
45 raise NotImplementedError(f"cond_type={control_type} not supported!")
46 if train:
47 return [ c_cat[:batch_size].to(device) ], [cond_img_cat[:batch_size].to(device) ]
48 else:
49 return pose_map_list, [cond_img_cat]
50
51def visualize(args, name, batch_data, infer_model, case, nSample):
52 infer_model.eval()

Callers

nothing calls this directly

Calls 2

encode_first_stageMethod · 0.45

Tested by

no test coverage detected