Old version
Browse files28 unmodified lines293031323334357 unmodified lines434445464748299 unmodified lines34834935035135235335428 unmodified lines38338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241333 unmodified lines44744844945045145245345445545645745845946046146246320 unmodified lines48448548648748848949079 unmodified lines57057157257328 unmodified linesfree_mem_gb = get_cuda_free_memory_gb(gpu)high_vram = free_mem_gb > 60print(f'Free VRAM {free_mem_gb} GB')print(f'High-VRAM Mode: {high_vram}')7 unmodified linesfeature_extractor = SiglipImageProcessor.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='feature_extractor')image_encoder = SiglipVisionModel.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='image_encoder', torch_dtype=torch.float16).cpu()transformer = HunyuanVideoTransformer3DModelPacked.from_pretrained('lllyasviel/FramePack_F1_I2V_HY_20250503', torch_dtype=torch.bfloat16).cpu()vae.eval()299 unmodified linesreturn total_second_length_debug_value * 60return total_second_length * 60@spaces.GPU(duration=get_duration)def process(input_image, prompt,t2v=False,28 unmodified linesdefault_height, default_width = 640, 640input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255print("No input image provided. Using a blank white image.")else:composite_rgba_uint8 = input_image["composite"]# rgb_uint8 will be (H, W, 3), dtype uint8rgb_uint8 = composite_rgba_uint8[:, :, :3]# mask_uint8 will be (H, W), dtype uint8mask_uint8 = composite_rgba_uint8[:, :, 3]# Create backgroundh, w = rgb_uint8.shape[:2]# White background, (H, W, 3), dtype uint8background_uint8 = np.full((h, w, 3), 255, dtype=np.uint8)# Normalize mask to range [0.0, 1.0].alpha_normalized_float32 = mask_uint8.astype(np.float32) / 255.0# Expand alpha to 3 channels to match RGB images for broadcasting.# alpha_mask_float32 will have shape (H, W, 3)alpha_mask_float32 = np.stack([alpha_normalized_float32] * 3, axis=2)# alpha blendingblended_image_float32 = rgb_uint8.astype(np.float32) * alpha_mask_float32 + \background_uint8.astype(np.float32) * (1.0 - alpha_mask_float32)input_image = np.clip(blended_image_float32, 0, 255).astype(np.uint8)yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)33 unmodified linescss = make_progress_bar_css()block = gr.Blocks(css=css).queue()with block:gr.Markdown('# FramePack-F1')gr.Markdown(f"""### Video diffusion, but feels like image diffusion*FramePack F1 - a FramePack model that only predicts future frames from history frames*### *beta* FramePack Fill 🖋️- draw a mask over the input image to inpaint the video outputadapted from the officical code repo [FramePack](https://github.com/lllyasviel/FramePack) by [lllyasviel](lllyasviel/FramePack_F1_I2V_HY_20250503) and [FramePack Studio](https://github.com/colinurbs/FramePack-Studio) 🙌🏻""")with gr.Row():with gr.Column():input_image = gr.ImageEditor(type="numpy", label="Image", height=320, brush=gr.Brush(colors=["#ffffff"]))prompt = gr.Textbox(label="Prompt", value='')t2v = gr.Checkbox(label="do text-to-video", value=False)with gr.Row():start_button = gr.Button(value="Start Generation")20 unmodified linesmp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")with gr.Accordion("Debug", open=False):input_image_debug = gr.ImageEditor(type="numpy", label="Image Debug", height=320, brush=gr.Brush(colors=["#ffffff"]))prompt_debug = gr.Textbox(label="Prompt Debug", value='')total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)79 unmodified lines)block.launch(share=True, mcp_server=True)28 unmodified lines293031323334357 unmodified lines434445464748495051299 unmodified lines35135235335435535628 unmodified lines38538638738838939033 unmodified lines42442542642742842943043143243343443543643743843920 unmodified lines46046146246346446546679 unmodified lines54654754854928 unmodified linesfree_mem_gb = get_cuda_free_memory_gb(gpu)high_vram = free_mem_gb > 80print(f'Free VRAM {free_mem_gb} GB')print(f'High-VRAM Mode: {high_vram}')7 unmodified linesfeature_extractor = SiglipImageProcessor.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='feature_extractor')image_encoder = SiglipVisionModel.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='image_encoder', torch_dtype=torch.float16).cpu()# quant_config = DiffusersBitsAndBytesConfig(load_in_8bit=True)# transformer = HunyuanVideoTransformer3DModelPacked.from_single_file("https://huggingface.co/sirolim/FramePack_F1_I2V_FP8/resolve/main/FramePack_F1_I2V_HY_fp8_e4m3fn.safetensors", torch_dtype=torch.bfloat16)# transformer = HunyuanVideoTransformer3DModelPacked.from_single_file('sirolim/FramePack_F1_I2V_FP8', "FramePack_F1_I2V_HY_fp8_e4m3fn.safetensors", use_safetensors=True, torch_dtype=torch.bfloat16).cpu()transformer = HunyuanVideoTransformer3DModelPacked.from_pretrained('lllyasviel/FramePack_F1_I2V_HY_20250503', torch_dtype=torch.bfloat16).cpu()vae.eval()299 unmodified linesreturn total_second_length_debug_value * 60return total_second_length * 60@spaces.GPU(duration=get_duration)def process(input_image, prompt,t2v=False,28 unmodified linesdefault_height, default_width = 640, 640input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255print("No input image provided. Using a blank white image.")yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)33 unmodified linescss = make_progress_bar_css()block = gr.Blocks(css=css).queue()with block:gr.Markdown('# FramePack Essentials | Experimentation in Progress')gr.Markdown(f"""### Space is constantly being tinkered with, expect downtime and errors.""")with gr.Row():with gr.Column():input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)prompt = gr.Textbox(label="Prompt", value='')t2v = gr.Checkbox(label="do text-to-video", value=False)example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Quick List', samples_per_page=1000, components=[prompt])example_quick_prompts.click(lambda x: x[0], inputs=[example_quick_prompts], outputs=prompt, show_progress=False, queue=False)with gr.Row():start_button = gr.Button(value="Start Generation")20 unmodified linesmp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")with gr.Accordion("Debug", open=False):input_image_debug = gr.Image(type="numpy", label="Image Debug", height=320)prompt_debug = gr.Textbox(label="Prompt Debug", value='')total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)79 unmodified lines)block.launch(ssr_mode=False)
app.py+11-35