-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[None][feat] Add Qwen-Image-Layered baseline support #15096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # 1-GPU Qwen-Image-Layered baseline. | ||
| # Load with VisualGenArgs.from_yaml() or example scripts that accept --visual_gen_args. | ||
| attention_config: | ||
| backend: VANILLA | ||
| parallel_config: | ||
| cfg_size: 1 | ||
| ulysses_size: 1 | ||
| cuda_graph_config: | ||
| enable: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
|
yibinl-nvidia marked this conversation as resolved.
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Qwen-Image-Layered image decomposition. | ||
|
|
||
| Usage: | ||
| python qwen_image_layered.py --image input.png | ||
| python qwen_image_layered.py --visual_gen_args ../configs/qwen-image-layered-1gpu.yaml \ | ||
| --image input.png | ||
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| from tensorrt_llm import VisualGen, VisualGenArgs | ||
|
|
||
|
|
||
| def parse_args() -> argparse.Namespace: | ||
|
yibinl-nvidia marked this conversation as resolved.
|
||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "--model", | ||
| default="Qwen/Qwen-Image-Layered", | ||
| help="Hugging Face model id or local checkpoint path.", | ||
| ) | ||
| parser.add_argument( | ||
| "--visual_gen_args", | ||
| "--extra_visual_gen_options", | ||
| dest="visual_gen_args", | ||
| help="Optional VisualGenArgs YAML file.", | ||
| ) | ||
| parser.add_argument( | ||
| "--image", | ||
| required=True, | ||
| help="Input image path.", | ||
| ) | ||
| parser.add_argument( | ||
| "--prompt", | ||
| default="", | ||
| help="Optional text prompt. Empty prompt enables image captioning.", | ||
| ) | ||
| parser.add_argument( | ||
| "--output_path", | ||
| default="qwen_image_layered_output.png", | ||
| help="Path to save the layer grid image.", | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def main() -> None: | ||
| args = parse_args() | ||
| extra_args = VisualGenArgs.from_yaml(args.visual_gen_args) if args.visual_gen_args else None | ||
| visual_gen = VisualGen(model=args.model, args=extra_args) | ||
|
|
||
| params = visual_gen.default_params | ||
| params.image = args.image | ||
|
|
||
| output = visual_gen.generate(inputs=args.prompt, params=params) | ||
| saved = output.save(args.output_path) | ||
| print(f"Saved image to {saved}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tensorrt_llm/_torch/visual_gen/models/qwen_image_layered/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Qwen-Image-Layered pipeline exports.""" | ||
|
|
||
| from .pipeline_qwen_image_layered import QwenImageLayeredPipeline | ||
| from .transformer_qwen_image_layered import QwenEmbedLayer3DRope, QwenImageLayeredTransformer2DModel | ||
|
|
||
| __all__ = [ | ||
| "QwenEmbedLayer3DRope", | ||
| "QwenImageLayeredPipeline", | ||
| "QwenImageLayeredTransformer2DModel", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.