MCPcopy
hub / github.com/lllyasviel/FramePack / callback

Function callback

demo_gradio_f1.py:204–220  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

202 transformer.initialize_teacache(enable_teacache=False)
203
204 def callback(d):
205 preview = d['denoised']
206 preview = vae_decode_fake(preview)
207
208 preview = (preview * 255.0).detach().cpu().numpy().clip(0, 255).astype(np.uint8)
209 preview = einops.rearrange(preview, 'b c t h w -> (b h) (t w) c')
210
211 if stream.input_queue.top() == 'end':
212 stream.output_queue.push(('end', None))
213 raise KeyboardInterrupt('User ends the task.')
214
215 current_step = d['i'] + 1
216 percentage = int(100.0 * current_step / steps)
217 hint = f'Sampling {current_step}/{steps}'
218 desc = f'Total generated frames: {int(max(0, total_generated_latent_frames * 4 - 3))}, Video length: {max(0, (total_generated_latent_frames * 4 - 3) / 30) :.2f} seconds (FPS-30). The video is being extended now ...'
219 stream.output_queue.push(('progress', (preview, desc, make_progress_bar_html(percentage, hint))))
220 return
221
222 indices = torch.arange(0, sum([1, 16, 2, 1, latent_window_size])).unsqueeze(0)
223 clean_latent_indices_start, clean_latent_4x_indices, clean_latent_2x_indices, clean_latent_1x_indices, latent_indices = indices.split([1, 16, 2, 1, latent_window_size], dim=1)

Callers

nothing calls this directly

Calls 4

vae_decode_fakeFunction · 0.90
make_progress_bar_htmlFunction · 0.90
topMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected