vllm.models.muse_spark.common.processor
¶
Multimodal preprocessing for MuseSpark1x Omni checkpoints.
Classes:
-
MuseSpark1xOmniMultiModalProcessor–Omni processor using native preprocessing instead of an HF processor.
-
MuseSpark1xOmniVideoBackend–Video loader that applies the model's frame sampling at load time.
-
NativeVariableSizeImageTransformError–Raised when resolution fitting fails.
-
PreprocessConfig– -
VideoClipMetadata–Metadata for temporal clips in a preprocessed video.
Functions:
-
compute_video_clip_metadata–Split a video into
patch_temporal-frame clips with first-frame timestamps. -
find_resize_target–Find the target resolution best preserving the image aspect ratio.
-
preprocess_image–Preprocess one image into fp32 [C, H, W] and its output token count.
-
preprocess_video–Preprocess uint8 RGB frames into fp32 [T_aligned, C, H, W].
MuseSpark1xOmniMultiModalProcessor
¶
Bases: BaseMultiModalProcessor[MuseSpark1xOmniProcessingInfo]
Omni processor using native preprocessing instead of an HF processor.
Source code in vllm/models/muse_spark/common/processor.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | |
_apply_hf_processor_main(mm_items, hf_kwargs)
¶
Native mm preprocessing; placeholders expand in _get_prompt_updates.
Source code in vllm/models/muse_spark/common/processor.py
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
MuseSpark1xOmniVideoBackend
¶
Bases: VideoBackend
Video loader that applies the model's frame sampling at load time.
The connector's default num_frames=32 is indistinguishable from an
explicit request, so num_frames is always replaced by the model's cap.
Source code in vllm/models/muse_spark/common/processor.py
NativeVariableSizeImageTransformError
¶
PreprocessConfig
dataclass
¶
Attributes:
-
token_patch_height(int) –Spatial resolution of each token after downsampling.
-
token_patch_width(int) –Spatial resolution of each token after downsampling.
Source code in vllm/models/muse_spark/common/processor.py
VideoClipMetadata
dataclass
¶
_least_distance_fit(i_nph, i_npw, min_num_tokens, max_num_tokens, patch_h, patch_w)
¶
Fallback: closest grid point between the min/max token hyperbolas.
Source code in vllm/models/muse_spark/common/processor.py
_least_distortion_fit(i_nph, i_npw, img_h, img_w, patch_h, patch_w, min_num_tokens, max_num_tokens)
¶
Find the patch grid (nph, npw) minimizing aspect-ratio distortion.
Source code in vllm/models/muse_spark/common/processor.py
_normalize_pixels(pixels, config)
¶
Scale uint8 pixels to [0, 1] and apply mean/std normalization.
Uses an explicit .float(): uint8 / Python float promotes to
torch.get_default_dtype(), which workers may have set to the model dtype.
Source code in vllm/models/muse_spark/common/processor.py
_preprocess_single_video(video_item, config)
¶
Preprocess a single video item for the NaViT encoder.
The FPS target uses metadata["total_num_frames"]: frames may be pre-sampled.
Source code in vllm/models/muse_spark/common/processor.py
_resize(image, target_h, target_w)
¶
PIL LANCZOS resize to a uint8 [C, H, W] tensor (training parity).
Source code in vllm/models/muse_spark/common/processor.py
_resize_frames(frames, target_h, target_w)
¶
Resize a uint8 [T, C, H, W] tensor frame by frame with PIL LANCZOS.
Source code in vllm/models/muse_spark/common/processor.py
_to_rgb(image)
¶
Convert to RGB, compositing alpha over RGBA_BACKGROUND_COLOR.
Source code in vllm/models/muse_spark/common/processor.py
_video_patch_count(video_tensor, config)
¶
Number of output patch tokens for a preprocessed [T, C, H, W] video.
Source code in vllm/models/muse_spark/common/processor.py
compute_video_clip_metadata(video_tensor, factored_timestamps, config)
¶
Split a video into patch_temporal-frame clips with first-frame timestamps.
Source code in vllm/models/muse_spark/common/processor.py
find_resize_target(img_h, img_w, patch_h, patch_w, min_num_tokens, max_num_tokens, resize_to_max_canvas=False)
¶
Find the target resolution best preserving the image aspect ratio.
Source code in vllm/models/muse_spark/common/processor.py
preprocess_image(image, config, resize_to_max_canvas=False)
¶
Preprocess one image into fp32 [C, H, W] and its output token count.
Source code in vllm/models/muse_spark/common/processor.py
preprocess_video(frames, timestamps, config, resize_to_max_canvas=False)
¶
Preprocess uint8 RGB frames into fp32 [T_aligned, C, H, W].