-
Notifications
You must be signed in to change notification settings - Fork 20
support wan2.5 i2i #66
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -138,8 +138,15 @@ def _get_input(cls, | |||||||||||||||||||||||||||||||||||||||
| has_upload = False | ||||||||||||||||||||||||||||||||||||||||
| if negative_prompt is not None: | ||||||||||||||||||||||||||||||||||||||||
| inputs[NEGATIVE_PROMPT] = negative_prompt | ||||||||||||||||||||||||||||||||||||||||
| if images is not None: | ||||||||||||||||||||||||||||||||||||||||
| inputs[IMAGES] = images | ||||||||||||||||||||||||||||||||||||||||
| if images is not None and images and len(images) > 0: | ||||||||||||||||||||||||||||||||||||||||
| new_images = [] | ||||||||||||||||||||||||||||||||||||||||
| for image in images: | ||||||||||||||||||||||||||||||||||||||||
| is_upload, new_image = check_and_upload_local( | ||||||||||||||||||||||||||||||||||||||||
| model, image, api_key) | ||||||||||||||||||||||||||||||||||||||||
| if is_upload: | ||||||||||||||||||||||||||||||||||||||||
| has_upload = True | ||||||||||||||||||||||||||||||||||||||||
| new_images.append(new_image) | ||||||||||||||||||||||||||||||||||||||||
| inputs[IMAGES] = new_images | ||||||||||||||||||||||||||||||||||||||||
| if sketch_image_url is not None and sketch_image_url: | ||||||||||||||||||||||||||||||||||||||||
| is_upload, sketch_image_url = check_and_upload_local( | ||||||||||||||||||||||||||||||||||||||||
| model, sketch_image_url, api_key) | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -178,10 +185,20 @@ def _get_input(cls, | |||||||||||||||||||||||||||||||||||||||
| headers['X-DashScope-OssResourceResolve'] = 'enable' | ||||||||||||||||||||||||||||||||||||||||
| kwargs['headers'] = headers | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if task is None: | ||||||||||||||||||||||||||||||||||||||||
| task = ImageSynthesis.task | ||||||||||||||||||||||||||||||||||||||||
| if model is not None and model and 'imageedit' in model: | ||||||||||||||||||||||||||||||||||||||||
| task = 'image2image' | ||||||||||||||||||||||||||||||||||||||||
| def __get_i2i_task(task, model) -> str: | ||||||||||||||||||||||||||||||||||||||||
| # 处理task参数:优先使用有效的task值 | ||||||||||||||||||||||||||||||||||||||||
| if task is not None and task != "": | ||||||||||||||||||||||||||||||||||||||||
| return task | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # 根据model确定任务类型 | ||||||||||||||||||||||||||||||||||||||||
| if model is not None and model != "": | ||||||||||||||||||||||||||||||||||||||||
| if 'imageedit' in model or "wan2.5-i2i" in model: | ||||||||||||||||||||||||||||||||||||||||
| return 'image2image' | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # 默认返回文本到图像任务 | ||||||||||||||||||||||||||||||||||||||||
| return ImageSynthesis.task | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| task = __get_i2i_task(task, model) | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+188
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This nested function A few other points:
I suggest replacing the function definition and call with the equivalent inlined logic.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| return inputs, kwargs, task | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition to check if
imagesis a non-empty list is redundant. In Python, you can simply useif images:, which evaluates toTruefor non-empty lists andFalseforNoneor empty lists. This is more idiomatic and readable.