MCPcopy
hub / github.com/fudan-generative-vision/champ / validate

Function validate

train_s2.py:81–126  ·  view source on GitHub ↗
(
    ref_img_path,
    guid_folder,
    guid_types,
    guid_start_idx,
    clip_length,
    width, height,
    pipe,
    generator,
    denoising_steps=20,
    guidance_scale=3.5,
    aug_type="Resize",
)

Source from the content-addressed store, hash-verified

79
80
81def validate(
82 ref_img_path,
83 guid_folder,
84 guid_types,
85 guid_start_idx,
86 clip_length,
87 width, height,
88 pipe,
89 generator,
90 denoising_steps=20,
91 guidance_scale=3.5,
92 aug_type="Resize",
93):
94 ref_img_pil = Image.open(ref_img_path)
95 if aug_type =="Padding":
96 ref_img_pil = padding_pil(ref_img_pil, height)
97 guid_folder = Path(guid_folder)
98 guid_img_pil_lst = []
99 for guid_type in guid_types:
100 guid_img_lst = sorted((guid_folder / guid_type).iterdir())
101 guid_img_clip_lst = guid_img_lst[guid_start_idx: guid_start_idx + clip_length]
102 single_guid_pil_lst = []
103 for guid_img_path in guid_img_clip_lst:
104 if guid_type == "semantic_map":
105 mask_img_path = guid_folder / "mask" / guid_img_path.name
106 guid_img_pil = mask_to_bkgd(guid_img_path, mask_img_path)
107 else:
108 guid_img_pil = Image.open(guid_img_path).convert("RGB")
109 if aug_type == "Padding":
110 guid_img_pil = padding_pil(guid_img_pil, height)
111 single_guid_pil_lst += [guid_img_pil]
112 guid_img_pil_lst.append(single_guid_pil_lst)
113
114 val_videos = pipe(
115 ref_img_pil,
116 guid_img_pil_lst,
117 guid_types,
118 width,
119 height,
120 clip_length,
121 denoising_steps,
122 guidance_scale,
123 generator=generator,
124 ).videos
125
126 return val_videos, ref_img_pil, guid_img_pil_lst
127
128
129def log_validation(

Callers 1

log_validationFunction · 0.70

Calls 2

mask_to_bkgdFunction · 0.90
padding_pilFunction · 0.70

Tested by

no test coverage detected