[Feat] Add Ovis-Image-7B text-to-image pipeline#1117
[Feat] Add Ovis-Image-7B text-to-image pipeline#1117HenryDzy wants to merge 4 commits intohao-ai-lab:mainfrom
Conversation
Summary of ChangesHello @HenryDzy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the FastVideo framework by integrating the Ovis-Image-7B text-to-image model. It introduces new model architectures for the diffusion transformer and text encoder, along with their respective configurations and pipeline implementations. The changes enable users to perform high-quality text-to-image generation and fine-tune the Ovis-Image model within the FastVideo ecosystem. Additionally, the PR includes important refactorings to the model and pipeline registration systems, improving modularity and maintainability, and adds comprehensive test coverage to ensure the stability and correctness of the new features. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is a great pull request that adds comprehensive support for the Ovis-Image-7B text-to-image model. The changes include native model implementations, configurations, a new pipeline, and a full suite of tests, which is excellent. The refactoring in the model and pipeline registries also helps to simplify the codebase. I've identified a few critical issues related to type correctness in configurations and hardcoded paths in tests and examples that need to be addressed. Once these are resolved, this will be a very solid contribution.
| def import_pipeline_classes( | ||
| pipeline_types: list[PipelineType] | PipelineType | None = None | ||
| ) -> dict[str, dict[str, type[ComposedPipelineBase] | None]]: | ||
| pipeline_types_key: tuple[PipelineType, ...] | PipelineType | None | ||
| if isinstance(pipeline_types, list): | ||
| pipeline_types_key = tuple(pipeline_types) | ||
| else: | ||
| pipeline_types_key = pipeline_types | ||
| return _import_pipeline_classes_cached(pipeline_types_key) | ||
|
|
||
|
|
||
| @lru_cache | ||
| def _import_pipeline_classes_cached( | ||
| pipeline_types: tuple[PipelineType, ...] | PipelineType | None = None | ||
| ) -> dict[str, dict[str, type[ComposedPipelineBase] | None]]: | ||
| ) -> dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]: |
There was a problem hiding this comment.
The @lru_cache decorator requires all arguments to be hashable. The pipeline_types argument is typed as a list, which is not hashable and will raise a TypeError at runtime if a list is passed. To fix this, the function signature should be changed to accept a tuple instead of a list.
| def import_pipeline_classes( | |
| pipeline_types: list[PipelineType] | PipelineType | None = None | |
| ) -> dict[str, dict[str, type[ComposedPipelineBase] | None]]: | |
| pipeline_types_key: tuple[PipelineType, ...] | PipelineType | None | |
| if isinstance(pipeline_types, list): | |
| pipeline_types_key = tuple(pipeline_types) | |
| else: | |
| pipeline_types_key = pipeline_types | |
| return _import_pipeline_classes_cached(pipeline_types_key) | |
| @lru_cache | |
| def _import_pipeline_classes_cached( | |
| pipeline_types: tuple[PipelineType, ...] | PipelineType | None = None | |
| ) -> dict[str, dict[str, type[ComposedPipelineBase] | None]]: | |
| ) -> dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]: | |
| def import_pipeline_classes( | |
| pipeline_types: tuple[PipelineType, ...] | PipelineType | None = None | |
| ) -> dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]: |
| if isinstance(pipeline_types, list): | ||
| pipeline_types_to_scan = [ | ||
| pipeline_type.value for pipeline_type in pipeline_types | ||
| ] |
There was a problem hiding this comment.
Following the change to the function signature to accept a tuple for caching purposes, this check should be updated to look for a tuple instead of a list.
| if isinstance(pipeline_types, list): | |
| pipeline_types_to_scan = [ | |
| pipeline_type.value for pipeline_type in pipeline_types | |
| ] | |
| if isinstance(pipeline_types, tuple): | |
| pipeline_types_to_scan = [ | |
| pipeline_type.value for pipeline_type in pipeline_types | |
| ] |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Adds native FastVideo support for Ovis-Image-7B
New files
Models & configs
fastvideo/models/dits/ovisimage.py— NativeOvisImageTransformer2DModel:6 double blocks + 27 single blocks, SwiGLU activations, RoPE,
DistributedAttentionfastvideo/models/encoders/qwen3.py—Qwen3Modeltext encoder(wraps
Ovis2.5-2Bfor conditioning)fastvideo/configs/pipelines/ovis_image.py—OvisImageT2IConfig(flow_shift=3.0, embedded_cfg_scale=5.0, Qwen3 pre/postprocess hooks)
fastvideo/pipelines/basic/ovis_image/—OvisImagePipelinePipeline
fastvideo/pipelines/basic/ovis_image/__init__.pyfastvideo/pipelines/basic/ovis_image/ovis_image_pipeline.pyfastvideo/training/ovis_image_training_pipeline.pyTests
fastvideo/tests/transformers/test_ovisimage.py— transformer forward passfastvideo/tests/encoders/test_qwen3_encoder.py— HF vs FastVideo Qwen3 parityfastvideo/tests/ssim/test_ovis_image_similarity.py— MS-SSIM regression testtests/local_tests/pipelines/test_ovis_image_pipeline_smoke.py— end-to-endVideoGeneratorsmoke testExample
examples/inference/basic/basic_ovis_image.py— runnable exampleFiles modified
fastvideo/registry.py— registeredAIDC-AI/Ovis-Image-7Bfastvideo/configs/models/dits/__init__.py— exportedOvisImageTransformer2DModelConfigfastvideo/configs/models/encoders/__init__.py— exportedQwen3Configfastvideo/configs/models/vaes/base.py— addedload_encoder/load_decoderfieldsfastvideo/models/registry.py— registeredOvisImageTransformer2DModel,Qwen3Modelfastvideo/pipelines/pipeline_registry.py— registeredOvisImagePipelinefastvideo/pipelines/stages/denoising.py—except (ImportError, RuntimeError)for Triton guardsfastvideo/pipelines/stages/causal_denoising.py— same fixfastvideo/pipelines/stages/matrixgame_denoising.py— same fixfastvideo/training/__init__.py— exportedOvisImageTrainingPipelinedocs/inference/support_matrix.md— added Ovis-Image-7B row