MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / detect_frames

Function detect_frames

diffsynth/extensions/FastBlend/api.py:151–179  ·  view source on GitHub ↗
(frames_path, keyframes_path)

Source from the content-addressed store, hash-verified

149
150
151def detect_frames(frames_path, keyframes_path):
152 if not os.path.exists(frames_path) and not os.path.exists(keyframes_path):
153 return "Please input the directory of guide video and rendered frames"
154 elif not os.path.exists(frames_path):
155 return "Please input the directory of guide video"
156 elif not os.path.exists(keyframes_path):
157 return "Please input the directory of rendered frames"
158 frames = [os.path.split(i)[-1] for i in search_for_images(frames_path)]
159 keyframes = [os.path.split(i)[-1] for i in search_for_images(keyframes_path)]
160 if len(frames)==0:
161 return f"No images detected in {frames_path}"
162 if len(keyframes)==0:
163 return f"No images detected in {keyframes_path}"
164 matched_keyframes = KeyFrameMatcher().match_filenames(frames, keyframes)
165 max_filename_length = max([len(i) for i in frames])
166 if sum([i is not None for i in matched_keyframes])==0:
167 message = ""
168 for frame, matched_keyframe in zip(frames, matched_keyframes):
169 message += frame + " " * (max_filename_length - len(frame) + 1)
170 message += "--> No matched keyframes\n"
171 else:
172 message = ""
173 for frame, matched_keyframe in zip(frames, matched_keyframes):
174 message += frame + " " * (max_filename_length - len(frame) + 1)
175 if matched_keyframe is None:
176 message += "--> [to be rendered]\n"
177 else:
178 message += f"--> {matched_keyframe}\n"
179 return message
180
181
182def check_input_for_interpolating(frames_path, keyframes_path):

Callers

nothing calls this directly

Calls 3

KeyFrameMatcherClass · 0.85
match_filenamesMethod · 0.80
search_for_imagesFunction · 0.70

Tested by

no test coverage detected