Buckets:
| # | |
| # Được cấp phép theo Giấy phép Apache, Phiên bản 2.0 (gọi là "Giấy phép"); | |
| # bạn có thể không sử dụng tệp này ngoại trừ tuân thủ theo Giấy phép. | |
| # Bạn có thể nhận được một bản sao của Giấy phép tại | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Trừ khi được yêu cầu bởi luật pháp có hiệu lực hoặc được thỏa thuận bằng văn bản, phần mềm | |
| # được phân phối theo Giấy phép được phân phối trên cơ sở | |
| # KHÔNG CÓ BẢO HÀNH HOẶC ĐIỀU KIỆN DƯỚI BẤT KỲ HÌNH THỨC NÀO, dù được nêu rõ hay ngụ ý. | |
| # Xem Giấy phép để biết ngôn ngữ cụ thể điều chỉnh các quyền và | |
| # giới hạn theo Giấy phép. --> | |
| # Helios | |
| [Helios: Mô hình tạo video dài thời gian thực](https://huggingface.co/papers/2603.04379) từ Đại học Bắc Kinh & ByteDance & v.v., bởi Shenghai Yuan, Yuanyang Yin, Zongjian Li, Xinwei Huang, Xiao Yang, Li Yuan. | |
| * Chúng tôi giới thiệu Helios, mô hình tạo video 14B đầu tiên chạy ở tốc độ 17 FPS trên một GPU NVIDIA H100 duy nhất và hỗ trợ tạo video ở quy mô phút trong khi vẫn đạt chất lượng tương đương với một baseline mạnh. Chúng tôi đạt được những bước đột phá trên ba khía cạnh chính: (1) khả năng chống chịu với hiện tượng trôi (drifting) trong video dài mà không cần sử dụng các heuristic chống trôi phổ biến như self-forcing, error banks hay keyframe sampling; (2) tạo video thời gian thực mà không cần các kỹ thuật tăng tốc tiêu chuẩn như KV-cache, causal masking hay sparse attention; và (3) huấn luyện mà không cần các framework song song hoặc sharding, cho phép kích thước batch ở quy mô image-diffusion trong khi vẫn chứa được tới bốn mô hình 14B trong 80 GB bộ nhớ GPU. Cụ thể, Helios là một mô hình diffusion tự hồi quy (autoregressive) 14B với biểu diễn đầu vào thống nhất, hỗ trợ bản địa (natively) các tác vụ T2V, I2V và V2V. Để giảm thiểu hiện tượng trôi trong tạo video dài, chúng tôi đặc trưng hóa các chế độ lỗi điển hình của nó và đề xuất các chiến lược huấn luyện đơn giản nhưng hiệu quả, trong đó mô phỏng rõ ràng hiện tượng trôi trong quá trình huấn luyện, đồng thời loại bỏ chuyển động lặp đi lặp lại ngay từ nguồn gốc. Về hiệu quả, chúng tôi nén mạnh ngữ cảnh lịch sử và nhiễu, đồng thời giảm số bước lấy mẫu, dẫn đến chi phí tính toán tương đương hoặc thấp hơn so với các mô hình tạo video 1.3B. Hơn nữa, chúng tôi giới thiệu các tối ưu hóa ở cấp hạ tầng, giúp tăng tốc cả suy luận (inference) lẫn huấn luyện trong khi giảm mức tiêu thụ bộ nhớ. Các thí nghiệm rộng rãi cho thấy Helios luôn vượt trội hơn các phương pháp trước đó trong cả tạo video ngắn lẫn video dài. Toàn bộ mã nguồn và mô hình có sẵn tại [this https URL](https://pku-yuangroup.github.io/Helios-Page). | |
| Các mô hình Helios sau đây được hỗ trợ trong Diffusers: | |
| - [Helios-Base](https://huggingface.co/BestWishYsh/Helios-Base): Chất lượng tốt nhất, với v-prediction, CFG chuẩn và HeliosScheduler tùy chỉnh. | |
| - [Helios-Mid](https://huggingface.co/BestWishYsh/Helios-Mid): Trọng lượng trung bình, với v-prediction, CFG-Zero* và HeliosScheduler tùy chỉnh. | |
| - [Helios-Distilled](https://huggingface.co/BestWishYsh/Helios-Distilled): Hiệu suất tốt nhất, với x0-prediction và HeliosDMDScheduler tùy chỉnh. | |
| > [!TIP] | |
| > Nhấp vào các mô hình Helios ở thanh bên phải để xem thêm các ví dụ về tạo video. | |
| ### Tối ưu hóa bộ nhớ và tốc độ suy luận | |
| Ví dụ dưới đây minh họa cách tạo video từ văn bản được tối ưu hóa cho bộ nhớ hoặc tốc độ suy luận. | |
| Tham khảo hướng dẫn [Giảm mức sử dụng bộ nhớ](../../optimization/memory) để biết thêm chi tiết về các kỹ thuật tiết kiệm bộ nhớ khác nhau. | |
| Mô hình Helios bên dưới yêu cầu ~6GB VRAM. | |
| ```py | |
| import torch | |
| from diffusers import AutoModel, HeliosPipeline | |
| from diffusers.hooks.group_offloading import apply_group_offloading | |
| from diffusers.utils import export_to_video | |
| vae = AutoModel.from_pretrained("BestWishYsh/Helios-Base", subfolder="vae", dtype=torch.float32) | |
| # group-offloading | |
| pipeline = HeliosPipeline.from_pretrained( | |
| "BestWishYsh/Helios-Base", | |
| vae=vae, | |
| dtype=torch.bfloat16 | |
| ) | |
| pipeline.enable_group_offload( | |
| onload_device=torch.device("cuda"), | |
| offload_device=torch.device("cpu"), | |
| offload_type="leaf_level", | |
| use_stream=True, | |
| record_stream=True, | |
| ) | |
| prompt = """ | |
| A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue | |
| and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with | |
| a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, | |
| allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades | |
| of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and | |
| the vivid colors of its surroundings. A close-up shot with dynamic movement. | |
| """ | |
| negative_prompt = """ | |
| Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, | |
| low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, | |
| misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards | |
| """ | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| num_frames=99, | |
| num_inference_steps=50, | |
| guidance_scale=5.0, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_base_t2v_output.mp4", fps=24) | |
| ``` | |
| [Compilation](../../optimization/fp16#torchcompile) sẽ chậm ở lần đầu tiên nhưng các lần gọi pipeline sau đó sẽ nhanh hơn. [Attention Backends](../../optimization/attention_backends) như FlashAttention và SageAttention có thể tăng tốc độ đáng kể bằng cách tối ưu hóa việc tính toán cơ chế attention. [Context Parallelism](../../optimization/context_parallelism) chia nhỏ chuỗi đầu vào trên nhiều thiết bị để cho phép xử lý các ngữ cảnh dài song song, giảm áp lực bộ nhớ và độ trễ. [Caching](../../optimization/cache) cũng có thể tăng tốc suy luận bằng cách lưu trữ và tái sử dụng các kết quả trung gian. | |
| ```py | |
| import torch | |
| from diffusers import AutoModel, HeliosPipeline | |
| from diffusers.utils import export_to_video | |
| vae = AutoModel.from_pretrained("BestWishYsh/Helios-Base", subfolder="vae", dtype=torch.float32) | |
| pipeline = HeliosPipeline.from_pretrained( | |
| "BestWishYsh/Helios-Base", | |
| vae=vae, | |
| dtype=torch.bfloat16 | |
| ) | |
| pipeline.to("cuda") # or "mps", "xpu", "cpu" | |
| # attention backend | |
| # pipeline.transformer.set_attention_backend("flash") | |
| pipeline.transformer.set_attention_backend("_flash_3_hub") # For Hopper GPUs | |
| # torch.compile | |
| torch.backends.cudnn.benchmark = True | |
| pipeline.text_encoder.compile(mode="max-autotune-no-cudagraphs", dynamic=False) | |
| pipeline.vae.compile(mode="max-autotune-no-cudagraphs", dynamic=False) | |
| pipeline.transformer.compile(mode="max-autotune-no-cudagraphs", dynamic=False) | |
| prompt = """ | |
| A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue | |
| and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with | |
| a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, | |
| allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades | |
| of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and | |
| the vivid colors of its surroundings. A close-up shot with dynamic movement. | |
| """ | |
| negative_prompt = """ | |
| Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, | |
| low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, | |
| misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards | |
| """ | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| num_frames=99, | |
| num_inference_steps=50, | |
| guidance_scale=5.0, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_base_t2v_output.mp4", fps=24) | |
| ``` | |
| ### Tạo nội dung với Helios-Base | |
| Ví dụ dưới đây minh họa cách sử dụng Helios-Base để tạo video dựa trên văn bản, hình ảnh hoặc video. | |
| ```python | |
| import torch | |
| from diffusers import AutoModel, HeliosPipeline | |
| from diffusers.utils import export_to_video, load_video, load_image | |
| vae = AutoModel.from_pretrained("BestWishYsh/Helios-Base", subfolder="vae", dtype=torch.float32) | |
| pipeline = HeliosPipeline.from_pretrained( | |
| "BestWishYsh/Helios-Base", | |
| vae=vae, | |
| dtype=torch.bfloat16 | |
| ) | |
| pipeline.to("cuda") # or "mps", "xpu", "cpu" | |
| negative_prompt = """ | |
| Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, | |
| low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, | |
| misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards | |
| """ | |
| # For Text-to-Video | |
| prompt = """ | |
| A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue | |
| and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with | |
| a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, | |
| allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades | |
| of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and | |
| the vivid colors of its surroundings. A close-up shot with dynamic movement. | |
| """ | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| num_frames=99, | |
| num_inference_steps=50, | |
| guidance_scale=5.0, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_base_t2v_output.mp4", fps=24) | |
| # For Image-to-Video | |
| prompt = """ | |
| A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, | |
| illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, | |
| casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes | |
| apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and | |
| relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and | |
| respect for nature’s might. | |
| """ | |
| image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| image=load_image(image_path).resize((640, 384)), | |
| num_frames=99, | |
| num_inference_steps=50, | |
| guidance_scale=5.0, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_base_i2v_output.mp4", fps=24) | |
| # For Video-to-Video | |
| prompt = """ | |
| A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees | |
| under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, | |
| emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to | |
| the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. | |
| A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery. | |
| """ | |
| video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| video=load_video(video_path), | |
| num_frames=99, | |
| num_inference_steps=50, | |
| guidance_scale=5.0, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_base_v2v_output.mp4", fps=24) | |
| ``` | |
| ### Tạo nội dung với Helios-Mid | |
| Ví dụ dưới đây minh họa cách sử dụng Helios-Mid để tạo video dựa trên văn bản, hình ảnh hoặc video. | |
| ```python | |
| import torch | |
| from diffusers import AutoModel, HeliosPyramidPipeline | |
| from diffusers.utils import export_to_video, load_video, load_image | |
| vae = AutoModel.from_pretrained("BestWishYsh/Helios-Mid", subfolder="vae", dtype=torch.float32) | |
| pipeline = HeliosPyramidPipeline.from_pretrained( | |
| "BestWishYsh/Helios-Mid", | |
| vae=vae, | |
| dtype=torch.bfloat16 | |
| ) | |
| pipeline.to("cuda") # or "mps", "xpu", "cpu" | |
| negative_prompt = """ | |
| Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, | |
| low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, | |
| misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards | |
| """ | |
| # For Text-to-Video | |
| prompt = """ | |
| A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue | |
| and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with | |
| a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, | |
| allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades | |
| of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and | |
| the vivid colors of its surroundings. A close-up shot with dynamic movement. | |
| """ | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| num_frames=99, | |
| pyramid_num_inference_steps_list=[20, 20, 20], | |
| guidance_scale=5.0, | |
| use_zero_init=True, | |
| zero_steps=1, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_pyramid_t2v_output.mp4", fps=24) | |
| # For Image-to-Video | |
| prompt = """ | |
| A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, | |
| illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, | |
| casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes | |
| apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and | |
| relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and | |
| respect for nature’s might. | |
| """ | |
| image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| image=load_image(image_path).resize((640, 384)), | |
| num_frames=99, | |
| pyramid_num_inference_steps_list=[20, 20, 20], | |
| guidance_scale=5.0, | |
| use_zero_init=True, | |
| zero_steps=1, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_pyramid_i2v_output.mp4", fps=24) | |
| # For Video-to-Video | |
| prompt = """ | |
| A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees | |
| under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, | |
| emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to | |
| the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. | |
| A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery. | |
| """ | |
| video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| video=load_video(video_path), | |
| num_frames=99, | |
| pyramid_num_inference_steps_list=[20, 20, 20], | |
| guidance_scale=5.0, | |
| use_zero_init=True, | |
| zero_steps=1, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_pyramid_v2v_output.mp4", fps=24) | |
| ``` | |
| ### Tạo nội dung với Helios-Distilled | |
| Ví dụ dưới đây minh họa cách sử dụng Helios-Distilled để tạo video dựa trên văn bản, hình ảnh hoặc video. | |
| ```python | |
| import torch | |
| from diffusers import AutoModel, HeliosPyramidPipeline | |
| from diffusers.utils import export_to_video, load_video, load_image | |
| vae = AutoModel.from_pretrained("BestWishYsh/Helios-Distilled", subfolder="vae", dtype=torch.float32) | |
| pipeline = HeliosPyramidPipeline.from_pretrained( | |
| "BestWishYsh/Helios-Distilled", | |
| vae=vae, | |
| dtype=torch.bfloat16 | |
| ) | |
| pipeline.to("cuda") # or "mps", "xpu", "cpu" | |
| negative_prompt = """ | |
| Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, | |
| low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, | |
| misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards | |
| """ | |
| # For Text-to-Video | |
| prompt = """ | |
| A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue | |
| and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with | |
| a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, | |
| allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades | |
| of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and | |
| the vivid colors of its surroundings. A close-up shot with dynamic movement. | |
| """ | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| num_frames=240, | |
| pyramid_num_inference_steps_list=[2, 2, 2], | |
| guidance_scale=1.0, | |
| is_amplify_first_chunk=True, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_distilled_t2v_output.mp4", fps=24) | |
| # For Image-to-Video | |
| prompt = """ | |
| A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, | |
| illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, | |
| casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes | |
| apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and | |
| relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and | |
| respect for nature’s might. | |
| """ | |
| image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| image=load_image(image_path).resize((640, 384)), | |
| num_frames=240, | |
| pyramid_num_inference_steps_list=[2, 2, 2], | |
| guidance_scale=1.0, | |
| is_amplify_first_chunk=True, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_distilled_i2v_output.mp4", fps=24) | |
| # For Video-to-Video | |
| prompt = """ | |
| A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees | |
| under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, | |
| emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to | |
| the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. | |
| A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery. | |
| """ | |
| video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4" | |
| output = pipeline( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| video=load_video(video_path), | |
| num_frames=240, | |
| pyramid_num_inference_steps_list=[2, 2, 2], | |
| guidance_scale=1.0, | |
| is_amplify_first_chunk=True, | |
| generator=torch.Generator("cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(output, "helios_distilled_v2v_output.mp4", fps=24) | |
| ``` | |
| ## Các ví dụ về Text-to-Video | |
| Video được tạo từ Prompt | |
| Một chiến binh Viking lái xe buýt thành phố hiện đại chở đầy hành khách. Người Viking có mái tóc vàng dài buộc gọn, râu quai nón, đội mũ và mặc giáp có lót lông. Anh mặc áo choàng và quần truyền thống, nhưng cũng thắt dây an toàn khi tập trung điều khiển xe trên những con phố đông đúc. Nội thất bên trong xe buýt điển hình, với các hàng ghế được lấp đầy bởi những hành khách đa dạng đang thực hiện các hoạt động thường nhật. Các góc quay bên ngoài cho thấy môi trường đô thị nhộn nhịp, bao gồm các tòa nhà cao tầng và giao thông. Cảnh trung bình tập trung vào người Viking ở vô lăng, thỉnh thoảng có các cảnh cận mặt thể hiện vẻ quyết tâm của anh. | |
| Bức ảnh chụp thiên nhiên theo phong cách tài liệu, được ghi lại từ một chiếc xe tải camera đang di chuyển về phía bên trái, bắt trọn khoảnh khắc một con cua vội vã chui vào hang. Con cua có lớp vỏ cứng màu nâu xanh và đôi càng dài, di chuyển với tốc độ quyết đoán trên mặt đất cát. Thân nó hơi cong khi đào vào cát, để lại một vệt nhỏ phía sau. Nền ảnh cho thấy một bãi biển nông với những tảng đá và vỏ sò rải rác, đường chân trời hiện lên với đường cong nhẹ nhàng của bờ biển. Bức ảnh có kết cấu tự nhiên và chân thực, nhấn mạnh chuyển động tự nhiên của con cua và kết cấu của cát. Góc chụp cận cảnh từ một vị trí hơi cao hơn. | |
| ## Các ví dụ minh họa từ ảnh sang video | |
| Video được tạo từ Prompt hình ảnh | |
| Một chiếc xe Kia màu đỏ bóng bẩy phóng nhanh trên con đường nông thôn dưới bầu trời nhiều mây, thiết kế hiện đại và chuyển động đầy năng động của xe được nhấn mạnh bởi hiệu ứng mờ do chuyển động của những cánh đồng và hàng cây xung quanh trải dài đến tận chân trời. Lớp sơn bóng của xe phản chiếu bầu trời u ám, làm nổi bật hình dáng khí động học và tư thế thể thao. Biển số xe ghi "KIA 626", và đèn pha của xe đang bật, góp phần tạo thêm cảm giác chuyển động và năng lượng. Con đường uốn lượn nhẹ nhàng, với chiếc xe được đặt hơi lệch khỏi tâm, tạo cảm giác về động lực tiến về phía trước. Góc nhìn ba phần tư phía trước đầy động lực ghi lại sự hiện diện mạnh mẽ của chiếc xe trên nền cảnh quan yên bình với những ngọn đồi nhấp nhô và những hàng cây rải rác. | |
| Một bức ảnh cận cảnh bắt trọn chú mèo cam lông xù với đôi mắt xanh lá cây sắc nét và những sợi râu trắng, đang nhìn chằm chằm về phía máy ảnh. Bộ lông của chú mềm mại và được chăm chút kỹ lưỡng, pha trộn giữa các tông màu cam ấm áp và kem. Đôi mắt to, biểu cảm của chú có màu xanh lá cây rực rỡ, phản ánh sự tò mò và cảnh giác. Mũi chú nhỏ và hồng, miệng hơi hé mở, hé lộ một chút lưỡi hồng. Nền ảnh được làm mờ nhẹ, gợi lên một không gian trong nhà ấm cúng với các tông màu trung tính. Bức ảnh có độ sâu trường ảnh nông, tập trung sắc nét vào khuôn mặt chú mèo trong khi nền vẫn bị mờ. Một góc chụp cận cảnh từ một góc nhìn hơi cao hơn. | |
| ## Trưng bày Video Tương tác | |
| Video được tạo từ Prompt | |
| Prompt có thể được tìm thấy tại đây | |
| Prompt có thể được tìm thấy tại đây | |
| ## Tài nguyên | |
| Tìm hiểu thêm về Helios với các tài nguyên sau. | |
| - Xem [video1](https://www.youtube.com/watch?v=vd_AgHtOUFQ) và [video2](https://www.youtube.com/watch?v=1GeIU2Dn7UY) để xem cách sử dụng các tính năng chính của Helios. | |
| - Xem thêm chi tiết trong bài nghiên cứu [Helios: Real Real-Time Long Video Generation Model](https://huggingface.co/papers/2603.04379). | |
| ## HeliosPipeline[[diffusers.HeliosPipeline]] | |
| #### diffusers.HeliosPipeline[[diffusers.HeliosPipeline]] | |
| ```python | |
| diffusers.HeliosPipeline(tokenizer: AutoTokenizer, text_encoder: UMT5EncoderModel, vae: AutoencoderKLWan, scheduler: HeliosScheduler, transformer: HeliosTransformer3DModel) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios.py#L108) | |
| **Tham số:** | |
| tokenizer (`T5Tokenizer`) : Tokenizer từ [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer), cụ thể là biến thể [google/umt5-xxl](https://huggingface.co/google/umt5-xxl). | |
| text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), cụ thể là biến thể [google/umt5-xxl](https://huggingface.co/google/umt5-xxl). | |
| transformer ([HeliosTransformer3DModel](/docs/diffusers/main/vi/api/models/helios_transformer3d#diffusers.HeliosTransformer3DModel)) : Transformer có điều kiện để khử nhiễu các latents đầu vào. | |
| scheduler ([HeliosScheduler](/docs/diffusers/main/vi/api/schedulers/helios#diffusers.HeliosScheduler)) : Một trình lập lịch được sử dụng kết hợp với `transformer` để khử nhiễu các latents của ảnh đã mã hóa. | |
| vae ([AutoencoderKLWan](/docs/diffusers/main/vi/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã video sang và từ các biểu diễn ẩn. | |
| Pipeline để tạo video từ văn bản / từ hình ảnh / từ video sử dụng Helios. | |
| Mô hình này kế thừa từ [DiffusionPipeline](/docs/diffusers/main/vi/api/pipelines/overview#diffusers.DiffusionPipeline). Xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các pipeline (tải xuống, lưu, chạy trên một thiết bị cụ thể, v.v.). | |
| #### __call__[[diffusers.HeliosPipeline.__call__]] | |
| ```python | |
| __call__(prompt: str | list[str] = None, negative_prompt: str | list[str] = None, height: int = 384, width: int = 640, num_frames: int = 132, num_inference_steps: int = 50, sigmas: list[float] = None, guidance_scale: float = 5.0, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'np', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, image_latents: typing.Optional[torch.Tensor] = None, fake_image_latents: typing.Optional[torch.Tensor] = None, add_noise_to_image_latents: bool = True, image_noise_sigma_min: float = 0.111, image_noise_sigma_max: float = 0.135, video: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, video_latents: typing.Optional[torch.Tensor] = None, add_noise_to_video_latents: bool = True, video_noise_sigma_min: float = 0.111, video_noise_sigma_max: float = 0.135, history_sizes: list = [16, 2, 1], num_latent_frames_per_chunk: int = 9, keep_first_frame: bool = True, is_skip_first_chunk: bool = False) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios.py#L445) | |
| **Tham số:** | |
| prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt để hướng dẫn việc tạo ảnh. Nếu không được định nghĩa, hãy truyền `prompt_embeds` thay thế. | |
| negative_prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt cần tránh trong quá trình tạo ảnh. Nếu không được định nghĩa, hãy truyền `negative_prompt_embeds` thay thế. Bỏ qua khi không sử dụng guidance (`guidance_scale` < `1`). | |
| height (`int`, mặc định là `384`) : Chiều cao của hình ảnh được tạo ra, tính bằng pixel. | |
| width (`int`, mặc định là `640`) : Độ rộng của hình ảnh được tạo ra, tính bằng pixel. | |
| num_frames (`int`, mặc định là `132`) : Số khung hình trong video được tạo ra. | |
| num_inference_steps (`int`, mặc định là `50`) : Số bước khử nhiễu. Số bước khử nhiễu nhiều hơn thường dẫn đến hình ảnh có chất lượng cao hơn, đổi lại là suy luận chậm hơn. | |
| sigmas (`list[float]`, *optional*) : Các sigma tùy chỉnh để sử dụng cho quá trình khử nhiễu. Nếu không được định nghĩa, lịch mặc định của trình lập lịch sẽ được sử dụng. | |
| guidance_scale (`float`, mặc định là `5.0`) : Thang độ dẫn hướng như được định nghĩa trong [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` được định nghĩa là `w` của phương trình 2. trong [Imagen Paper](https://huggingface.co/papers/2205.11487). Thang độ dẫn hướng được kích hoạt bằng cách đặt `guidance_scale > 1`. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ với `prompt` văn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn. | |
| num_videos_per_prompt (`int`, *tuỳ chọn*, mặc định là 1) : Số lượng hình ảnh cần tạo cho mỗi prompt. | |
| generator (`torch.Generator` hoặc `list[torch.Generator]`, *tùy chọn*) : Một [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) để đảm bảo quá trình sinh là tất định. | |
| latents (`torch.Tensor`, *tùy chọn*) : Các latents nhiễu được tạo trước, lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh. Có thể dùng để tinh chỉnh cùng một quá trình tạo với các prompt khác nhau. Nếu không được cung cấp, một tensor latents sẽ được tạo bằng cách lấy mẫu sử dụng `generator` ngẫu nhiên được cung cấp. | |
| prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản (trọng số prompt). Nếu không được cung cấp, các vector nhúng văn bản sẽ được tạo từ đối số đầu vào `prompt`. | |
| negative_prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản âm đã được tạo trước. Nếu không được cung cấp, chúng sẽ được tạo từ `negative_prompt`. | |
| output_type (`str`, *tùy chọn*, mặc định là `"np"`) : Định dạng đầu ra của hình ảnh được tạo ra. Chọn giữa `PIL.Image` hoặc `np.array`. | |
| return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `HeliosPipelineOutput` thay vì một tuple thông thường hay không. | |
| attention_kwargs (`dict`, *tùy chọn*) : Một từ điển kwargs mà nếu được chỉ định sẽ được truyền đến `AttentionProcessor` như đã định nghĩa dưới `self.processor` trong [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). | |
| callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *optional*) : Một hàm hoặc một lớp con của `PipelineCallback` hoặc `MultiPipelineCallbacks` được gọi vào cuối mỗi bước khử nhiễu trong quá trình suy luận, với các đối số sau: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` sẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởi `callback_on_step_end_tensor_inputs`. | |
| callback_on_step_end_tensor_inputs (`list`, *optional*) : Danh sách các đầu vào tensor cho hàm `callback_on_step_end`. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham số `callback_kwargs`. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính `._callback_tensor_inputs` của lớp pipeline của bạn. | |
| max_sequence_length (`int`, mặc định là `512`) : Độ dài tối đa của chuỗi cho text encoder. Nếu prompt dài hơn giá trị này, nó sẽ bị cắt bớt. Nếu prompt ngắn hơn, nó sẽ được đệm (padding) đến độ dài này. | |
| image (`PipelineImageInput`, *tùy chọn*) : Ảnh đầu vào được sử dụng cho điều kiện từ ảnh sang video. | |
| image_latents (`torch.Tensor`, *tùy chọn*) : Các latents của ảnh đã được mã hóa trước để sử dụng thay cho `image`. | |
| fake_image_latents (`torch.Tensor`, *tùy chọn*) : Các latents ảnh giả tùy chọn được sử dụng trong quá trình điều kiện hóa. | |
| add_noise_to_image_latents (`bool`, *tùy chọn*, mặc định là `True`) : Có thêm nhiễu vào các latent của hình ảnh trước khi khử nhiễu hay không. | |
| image_noise_sigma_min (`float`, *tuỳ chọn*, mặc định là `0.111`) : Giá trị sigma tối thiểu cho nhiễu được thêm vào các latents của hình ảnh. | |
| image_noise_sigma_max (`float`, *tuỳ chọn*, mặc định là `0.135`) : Giá trị sigma tối đa cho nhiễu được thêm vào các latents của hình ảnh. | |
| video (`PipelineImageInput`, *tùy chọn*) : Video đầu vào được sử dụng cho điều kiện video-đến-video. | |
| video_latents (`torch.Tensor`, *tùy chọn*) : Các video latents đã mã hóa trước để sử dụng thay cho `video`. | |
| add_noise_to_video_latents (`bool`, *tùy chọn*, mặc định là `True`) : Có thêm nhiễu vào các latents của video trước khi khử nhiễu hay không. | |
| video_noise_sigma_min (`float`, *tuỳ chọn*, mặc định là `0.111`) : Giá trị sigma tối thiểu cho nhiễu được thêm vào các latents của video. | |
| video_noise_sigma_max (`float`, *tuỳ chọn*, mặc định là `0.135`) : Giá trị sigma tối đa cho nhiễu được thêm vào các latents của video. | |
| history_sizes (`list`, *tùy chọn*, mặc định là `[16, 2, 1]`) : Kích thước cửa sổ lịch sử được sử dụng cho việc tạo chunk tự hồi quy. | |
| num_latent_frames_per_chunk (`int`, *tuỳ chọn*, mặc định là `9`) : Số lượng khung tiềm ẩn được tạo ra cho mỗi khối trong quá trình tạo tự hồi quy. | |
| keep_first_frame (`bool`, *tùy chọn*, mặc định là `True`) : Có giữ lại khung hình đầu tiên giữa các khối hay không. | |
| is_skip_first_chunk (`bool`, *tùy chọn*, mặc định là `False`) : Có bỏ qua việc tạo chunk đầu tiên hay không. | |
| **Trả về:** `~HeliosPipelineOutput` hoặc `tuple` | |
| Nếu `return_dict` là `True`, `HeliosPipelineOutput` sẽ được trả về, ngược lại một `tuple` sẽ được trả về trong đó phần tử đầu tiên là một danh sách chứa các hình ảnh được tạo ra và phần tử thứ hai là một danh sách các `bool` cho biết hình ảnh được tạo ra tương ứng có chứa nội dung "không an toàn cho công việc" (nsfw) hay không. | |
| Hàm gọi call của pipeline để tạo nội dung. | |
| Ví dụ: | |
| ```python | |
| >>> import torch | |
| >>> from diffusers.utils import export_to_video | |
| >>> from diffusers import AutoencoderKLWan, HeliosPipeline | |
| >>> # Available models: BestWishYsh/Helios-Base, BestWishYsh/Helios-Mid, BestWishYsh/Helios-Distilled | |
| >>> model_id = "BestWishYsh/Helios-Base" | |
| >>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) | |
| >>> pipe = HeliosPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) | |
| >>> pipe.to("cuda") | |
| >>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window." | |
| >>> negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" | |
| >>> output = pipe( | |
| ... prompt=prompt, | |
| ... negative_prompt=negative_prompt, | |
| ... height=384, | |
| ... width=640, | |
| ... num_frames=132, | |
| ... guidance_scale=5.0, | |
| ... ).frames[0] | |
| >>> export_to_video(output, "output.mp4", fps=24) | |
| ``` | |
| #### encode_prompt[[diffusers.HeliosPipeline.encode_prompt]] | |
| ```python | |
| encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios.py#L196) | |
| **Tham số:** | |
| prompt (`str` hoặc `list[str]`, *tùy chọn*) : prompt cần được mã hóa | |
| negative_prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt không được dùng để hướng dẫn việc tạo ảnh. Nếu không được định nghĩa, bạn phải truyền `negative_prompt_embeds` thay thế. Bỏ qua khi không sử dụng guidance (tức là bị bỏ qua nếu `guidance_scale` nhỏ hơn `1`). | |
| do_classifier_free_guidance (`bool`, *tùy chọn*, mặc định là `True`) : Có sử dụng classifier free guidance hay không. | |
| num_videos_per_prompt (`int`, *optional*, mặc định là 1) : Số lượng video cần được tạo cho mỗi prompt. Thiết bị torch để đặt các embeddings kết quả lên | |
| prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản, *vd.* trọng số prompt. Nếu không được cung cấp, các vector nhúng văn bản sẽ được tạo từ đối số đầu vào `prompt`. | |
| negative_prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản âm đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản, *vd.* trọng số prompt. Nếu không được cung cấp, negative_prompt_embeds sẽ được tạo từ đối số đầu vào `negative_prompt`. | |
| device : (`torch.device`, *tùy chọn*): thiết bị torch | |
| dtype : (`torch.dtype`, *tùy chọn*): torch dtype | |
| Mã hóa prompt thành các trạng thái ẩn của text encoder. | |
| ## HeliosPyramidPipeline[[diffusers.HeliosPyramidPipeline]] | |
| #### diffusers.HeliosPyramidPipeline[[diffusers.HeliosPyramidPipeline]] | |
| ```python | |
| diffusers.HeliosPyramidPipeline(tokenizer: AutoTokenizer, text_encoder: UMT5EncoderModel, vae: AutoencoderKLWan, scheduler: diffusers.schedulers.scheduling_helios.HeliosScheduler | diffusers.schedulers.scheduling_helios_dmd.HeliosDMDScheduler, transformer: HeliosTransformer3DModel, is_cfg_zero_star: bool = False, is_distilled: bool = False) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios_pyramid.py#L121) | |
| **Tham số:** | |
| tokenizer (`T5Tokenizer`) : Tokenizer từ [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer), cụ thể là biến thể [google/umt5-xxl](https://huggingface.co/google/umt5-xxl). | |
| text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), cụ thể là biến thể [google/umt5-xxl](https://huggingface.co/google/umt5-xxl). | |
| transformer ([HeliosTransformer3DModel](/docs/diffusers/main/vi/api/models/helios_transformer3d#diffusers.HeliosTransformer3DModel)) : Transformer có điều kiện để khử nhiễu các latents đầu vào. | |
| scheduler ([`HeliosScheduler`, `HeliosDMDScheduler`]) : Một scheduler được sử dụng kết hợp với `transformer` để khử nhiễu các latents của ảnh đã mã hóa. | |
| vae ([AutoencoderKLWan](/docs/diffusers/main/vi/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã video sang và từ các biểu diễn ẩn. | |
| Pipeline để tạo video từ văn bản / từ hình ảnh / từ video sử dụng Helios. | |
| Mô hình này kế thừa từ [DiffusionPipeline](/docs/diffusers/main/vi/api/pipelines/overview#diffusers.DiffusionPipeline). Xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các pipeline (tải xuống, lưu, chạy trên một thiết bị cụ thể, v.v.). | |
| #### __call__[[diffusers.HeliosPyramidPipeline.__call__]] | |
| ```python | |
| __call__(prompt: str | list[str] = None, negative_prompt: str | list[str] = None, height: int = 384, width: int = 640, num_frames: int = 132, sigmas: list[float] = None, guidance_scale: float = 5.0, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'np', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, image_latents: typing.Optional[torch.Tensor] = None, fake_image_latents: typing.Optional[torch.Tensor] = None, add_noise_to_image_latents: bool = True, image_noise_sigma_min: float = 0.111, image_noise_sigma_max: float = 0.135, video: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, video_latents: typing.Optional[torch.Tensor] = None, add_noise_to_video_latents: bool = True, video_noise_sigma_min: float = 0.111, video_noise_sigma_max: float = 0.135, history_sizes: list = [16, 2, 1], num_latent_frames_per_chunk: int = 9, keep_first_frame: bool = True, is_skip_first_chunk: bool = False, pyramid_num_inference_steps_list: list = [10, 10, 10], use_zero_init: bool | None = True, zero_steps: int | None = 1, is_amplify_first_chunk: bool = False) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios_pyramid.py#L508) | |
| **Tham số:** | |
| prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt để hướng dẫn việc tạo ảnh. Nếu không được định nghĩa, hãy truyền `prompt_embeds` thay thế. | |
| negative_prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt cần tránh trong quá trình tạo ảnh. Nếu không được định nghĩa, hãy truyền `negative_prompt_embeds` thay thế. Bỏ qua khi không sử dụng guidance (`guidance_scale` < `1`). | |
| height (`int`, mặc định là `384`) : Chiều cao của hình ảnh được tạo ra, tính bằng pixel. | |
| width (`int`, mặc định là `640`) : Độ rộng của hình ảnh được tạo ra, tính bằng pixel. | |
| num_frames (`int`, mặc định là `132`) : Số khung hình trong video được tạo ra. | |
| sigmas (`list[float]`, *optional*) : Các sigma tùy chỉnh để sử dụng cho quá trình khử nhiễu. Nếu không được định nghĩa, lịch mặc định của trình lập lịch sẽ được sử dụng. | |
| guidance_scale (`float`, mặc định là `5.0`) : Thang độ dẫn hướng như được định nghĩa trong [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` được định nghĩa là `w` của phương trình 2. trong [Imagen Paper](https://huggingface.co/papers/2205.11487). Thang độ dẫn hướng được kích hoạt bằng cách đặt `guidance_scale > 1`. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ với `prompt` văn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn. | |
| num_videos_per_prompt (`int`, *tuỳ chọn*, mặc định là 1) : Số lượng hình ảnh cần tạo cho mỗi prompt. | |
| generator (`torch.Generator` hoặc `list[torch.Generator]`, *tùy chọn*) : Một [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) để đảm bảo quá trình sinh là tất định. | |
| latents (`torch.Tensor`, *tùy chọn*) : Các latents nhiễu được tạo trước, lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh. Có thể dùng để tinh chỉnh cùng một quá trình tạo với các prompt khác nhau. Nếu không được cung cấp, một tensor latents sẽ được tạo bằng cách lấy mẫu sử dụng `generator` ngẫu nhiên được cung cấp. | |
| prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản (trọng số prompt). Nếu không được cung cấp, các vector nhúng văn bản sẽ được tạo từ đối số đầu vào `prompt`. | |
| negative_prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản âm đã được tạo trước. Nếu không được cung cấp, chúng sẽ được tạo từ `negative_prompt`. | |
| output_type (`str`, *tùy chọn*, mặc định là `"np"`) : Định dạng đầu ra của hình ảnh được tạo ra. Chọn giữa `PIL.Image` hoặc `np.array`. | |
| return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `HeliosPipelineOutput` thay vì một tuple thông thường hay không. | |
| attention_kwargs (`dict`, *tùy chọn*) : Một từ điển kwargs mà nếu được chỉ định sẽ được truyền đến `AttentionProcessor` như đã định nghĩa dưới `self.processor` trong [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). | |
| callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *optional*) : Một hàm hoặc một lớp con của `PipelineCallback` hoặc `MultiPipelineCallbacks` được gọi vào cuối mỗi bước khử nhiễu trong quá trình suy luận, với các đối số sau: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` sẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởi `callback_on_step_end_tensor_inputs`. | |
| callback_on_step_end_tensor_inputs (`list`, *optional*) : Danh sách các đầu vào tensor cho hàm `callback_on_step_end`. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham số `callback_kwargs`. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính `._callback_tensor_inputs` của lớp pipeline của bạn. | |
| max_sequence_length (`int`, mặc định là `512`) : Độ dài tối đa của chuỗi cho text encoder. Nếu prompt dài hơn giá trị này, nó sẽ bị cắt bớt. Nếu prompt ngắn hơn, nó sẽ được đệm (padding) đến độ dài này. | |
| image (`PipelineImageInput`, *tùy chọn*) : Ảnh đầu vào được sử dụng cho điều kiện từ ảnh sang video. | |
| image_latents (`torch.Tensor`, *tùy chọn*) : Các latents của ảnh đã được mã hóa trước để sử dụng thay cho `image`. | |
| fake_image_latents (`torch.Tensor`, *tùy chọn*) : Các latents ảnh giả tùy chọn được sử dụng trong quá trình điều kiện hóa. | |
| add_noise_to_image_latents (`bool`, *tùy chọn*, mặc định là `True`) : Có thêm nhiễu vào các latent của hình ảnh trước khi khử nhiễu hay không. | |
| image_noise_sigma_min (`float`, *tuỳ chọn*, mặc định là `0.111`) : Giá trị sigma tối thiểu cho nhiễu được thêm vào các latents của hình ảnh. | |
| image_noise_sigma_max (`float`, *tuỳ chọn*, mặc định là `0.135`) : Giá trị sigma tối đa cho nhiễu được thêm vào các latents của hình ảnh. | |
| video (`PipelineImageInput`, *tùy chọn*) : Video đầu vào được sử dụng cho điều kiện video-đến-video. | |
| video_latents (`torch.Tensor`, *tùy chọn*) : Các video latents đã mã hóa trước để sử dụng thay cho `video`. | |
| add_noise_to_video_latents (`bool`, *tùy chọn*, mặc định là `True`) : Có thêm nhiễu vào các latents của video trước khi khử nhiễu hay không. | |
| video_noise_sigma_min (`float`, *tuỳ chọn*, mặc định là `0.111`) : Giá trị sigma tối thiểu cho nhiễu được thêm vào các latents của video. | |
| video_noise_sigma_max (`float`, *tuỳ chọn*, mặc định là `0.135`) : Giá trị sigma tối đa cho nhiễu được thêm vào các latents của video. | |
| history_sizes (`list`, *tùy chọn*, mặc định là `[16, 2, 1]`) : Kích thước cửa sổ lịch sử được sử dụng cho việc tạo chunk tự hồi quy. | |
| num_latent_frames_per_chunk (`int`, *tuỳ chọn*, mặc định là `9`) : Số lượng khung tiềm ẩn được tạo ra cho mỗi khối trong quá trình tạo tự hồi quy. | |
| keep_first_frame (`bool`, *tùy chọn*, mặc định là `True`) : Có giữ lại khung hình đầu tiên giữa các khối hay không. | |
| is_skip_first_chunk (`bool`, *tùy chọn*, mặc định là `False`) : Có bỏ qua việc tạo chunk đầu tiên hay không. | |
| pyramid_num_inference_steps_list (`list`, *tùy chọn*, mặc định là `[10, 10, 10]`) : Số bước suy luận cho mỗi giai đoạn của kim tự tháp trong quá trình tạo ở Giai đoạn 2. | |
| use_zero_init (`bool`, *tùy chọn*, mặc định là `True`) : Có áp dụng CFG zero-init ở đầu quá trình khử nhiễu hay không. | |
| zero_steps (`int`, *tuỳ chọn*, mặc định là `1`) : Số bước khởi tạo ban đầu sử dụng CFG zero-init. | |
| is_amplify_first_chunk (`bool`, *tùy chọn*, mặc định là `False`) : Có khuếch đại hướng dẫn trên khối đầu tiên hay không (liên quan đến DMD). | |
| **Trả về:** `~HeliosPipelineOutput` hoặc `tuple` | |
| Nếu `return_dict` là `True`, `HeliosPipelineOutput` sẽ được trả về, ngược lại một `tuple` sẽ được trả về trong đó phần tử đầu tiên là một danh sách chứa các hình ảnh được tạo ra và phần tử thứ hai là một danh sách các `bool` cho biết hình ảnh được tạo ra tương ứng có chứa nội dung "không an toàn cho công việc" (nsfw) hay không. | |
| Hàm gọi call của pipeline để tạo nội dung. | |
| Ví dụ: | |
| ```python | |
| >>> import torch | |
| >>> from diffusers.utils import export_to_video | |
| >>> from diffusers import AutoencoderKLWan, HeliosPyramidPipeline | |
| >>> # Available models: BestWishYsh/Helios-Base, BestWishYsh/Helios-Mid, BestWishYsh/Helios-Distilled | |
| >>> model_id = "BestWishYsh/Helios-Base" | |
| >>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) | |
| >>> pipe = HeliosPyramidPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) | |
| >>> pipe.to("cuda") | |
| >>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window." | |
| >>> negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" | |
| >>> output = pipe( | |
| ... prompt=prompt, | |
| ... negative_prompt=negative_prompt, | |
| ... height=384, | |
| ... width=640, | |
| ... num_frames=132, | |
| ... guidance_scale=5.0, | |
| ... ).frames[0] | |
| >>> export_to_video(output, "output.mp4", fps=24) | |
| ``` | |
| #### encode_prompt[[diffusers.HeliosPyramidPipeline.encode_prompt]] | |
| ```python | |
| encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_helios_pyramid.py#L214) | |
| **Tham số:** | |
| prompt (`str` hoặc `list[str]`, *tùy chọn*) : prompt cần được mã hóa | |
| negative_prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt không được dùng để hướng dẫn việc tạo ảnh. Nếu không được định nghĩa, bạn phải truyền `negative_prompt_embeds` thay thế. Bỏ qua khi không sử dụng guidance (tức là bị bỏ qua nếu `guidance_scale` nhỏ hơn `1`). | |
| do_classifier_free_guidance (`bool`, *tùy chọn*, mặc định là `True`) : Có sử dụng classifier free guidance hay không. | |
| num_videos_per_prompt (`int`, *optional*, mặc định là 1) : Số lượng video cần được tạo cho mỗi prompt. Thiết bị torch để đặt các embeddings kết quả lên | |
| prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản, *vd.* trọng số prompt. Nếu không được cung cấp, các vector nhúng văn bản sẽ được tạo từ đối số đầu vào `prompt`. | |
| negative_prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản âm đã được tạo trước. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản, *vd.* trọng số prompt. Nếu không được cung cấp, negative_prompt_embeds sẽ được tạo từ đối số đầu vào `negative_prompt`. | |
| device : (`torch.device`, *tùy chọn*): thiết bị torch | |
| dtype : (`torch.dtype`, *tùy chọn*): torch dtype | |
| Mã hóa prompt thành các trạng thái ẩn của text encoder. | |
| ## HeliosPipelineOutput[[diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput]] | |
| #### diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput[[diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput]] | |
| ```python | |
| diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput(frames: Tensor) | |
| ``` | |
| [Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/helios/pipeline_output.py#L9) | |
| **Tham số:** | |
| frames (`torch.Tensor`, `np.ndarray`, hoặc List[List[PIL.Image.Image]]) : Danh sách các đầu ra video - Có thể là một danh sách lồng nhau có độ dài `batch_size,` trong đó mỗi danh sách con chứa các chuỗi hình ảnh PIL đã khử nhiễu có độ dài `num_frames.` Nó cũng có thể là một mảng NumPy hoặc tensor Torch có hình dạng `(batch_size, num_frames, channels, height, width)`. | |
| Lớp đầu ra cho các pipeline Helios. | |
Xet Storage Details
- Size:
- 59.7 kB
- Xet hash:
- cb28220c7bdb797c3d7cafbc9caba04f177e7e6d7bf7c1240041b5290d47c4eb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.