[Diffusion] fix serving image_edit get input image bug#18109
Conversation
Summary of ChangesHello @BBuf, 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 addresses a critical bug within the diffusion server's image editing functionality. The change ensures that the system correctly interprets the input image path, even when it is unexpectedly provided as a list. This fix prevents errors during image processing, allowing image editing requests to execute successfully and produce the intended visual results. 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. 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 pull request fixes a bug in the image editing functionality where the input image path was not handled correctly when passed as a list. The change correctly extracts the path from the list. However, the implementation has a potential issue with certain edge cases (e.g., a list containing None) which could lead to a runtime error. I've suggested a more robust implementation to handle this. Additionally, the current approach modifies the input batch object in-place, which could be avoided by using a local variable for better code safety.
| if isinstance(batch.image_path, list): | ||
| batch.image_path = batch.image_path[0] | ||
|
|
There was a problem hiding this comment.
This change correctly handles a list of image paths, but it's vulnerable to an AttributeError if the list contains a None value (e.g., [None]). In that scenario, batch.image_path becomes None, and the subsequent call to .startswith() on line 339 will crash.
To make this more robust, we should add a check for a falsy value after potentially unwrapping the list.
As a minor style point, modifying the batch object in-place can sometimes have unintended side effects. Using a local variable for the path would be a safer pattern, though it would require a slightly larger refactoring of this function.
| if isinstance(batch.image_path, list): | |
| batch.image_path = batch.image_path[0] | |
| if isinstance(batch.image_path, list): | |
| batch.image_path = batch.image_path[0] | |
| if not batch.image_path: return None |
I'll do it in future pr when I have bandwidth. |
|
/tag-and-rerun-ci |
Motivation
Server:
Client:
The input image is:
After send requests, I got this error :
And the result is bad:
After pr fix, I can got the correct result:
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci