-
Notifications
You must be signed in to change notification settings - Fork 172
Added img2img and Image Variations tabs to the Qt GUI #285
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
Conversation
This commit adds img2img support to the Qt GUI version as a first step in attempting to add all the generation modes already supported in both the CLI and WebUI versions.
Add Image Variations tab to the Qt GUI version
Use actual slider strength in img2img Qt GUI tabs
Applied code formatting for Qt GUI files
|
Oh, right, I forgot to mention it works by dragging and dropping the image you want as input for img2img modes, that's why I didn't add a file dialog. Maybe it needs some extra work. Thanks. |
Providing only drag and drop is not user-friendly, we need to give a manual file selection dialog and drag and drop. It will be a better user experience. User will look for image picker. |
|
Thanks, will try to add a file selection dialog. I'm learning Qt just as I code these changes so be patient. |
Add file selection dialog for Qt img2img tabs
|
Added a simple file selection dialog feature to the img2img tabs for the Qt version. Hopefully it works fine this time. Please note that once you select the first file, clicking again anywhere on the image area will cause the file dialog to appear again. |
|
I didn't want to bloat the GUI with extra widgets but OK, will try to add those. |
This commit adds file selection widgets to the img2img tabs in the Qt GUI. Also, the code for the Qt GUI img2img tabs was reorganized.
|
I added the Qt widgets for opening the file selection dialog. The other ways to choose an image were already coded so I left them there, too. Also, I reorganized the code for the Qt GUI img2img tabs to reduce the places where a class had to reference fields from another or to remove code where widgets were enabled or disabled at seemingly random places. Hopefully, the code works as expected while also being easier to read and maintain. |
src/frontend/gui/base_widget.py
Outdated
| self.next_btn = QToolButton() | ||
| self.next_btn.setText(">") | ||
| self.next_btn.clicked.connect(self.on_show_next_image) | ||
| # self.vspacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) |
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.
Please remove commented code
src/frontend/gui/base_widget.py
Outdated
| path = unquote(urlparse(event.mimeData().text()).path) | ||
| self.show_image(path) | ||
|
|
||
| def show_image(self, filename: str, pixmap: QPixmap = None): |
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.
show_image should receive only pixmap
src/frontend/gui/base_widget.py
Outdated
| if filename != None: | ||
| self.current_pixmap = QPixmap(filename) | ||
| if self.current_pixmap.isNull(): | ||
| return | ||
| self.current_filename = filename | ||
| self.changed.emit() | ||
| else: | ||
| if pixmap == None or pixmap.isNull(): | ||
| return | ||
| self.current_pixmap = pixmap | ||
| self.current_filename = "" | ||
| self.changed.emit() |
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.
This function is doing more than one thing, please follow the Single Responsibility Principle (SOLID) . This function's main purpose is to show images. Move this pixmap generation logic to separate function
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 logic I used was that show_image() could be used to also show an image that is being loaded from a file via the file selection button, doing it this way also simplifies the code for emitting the widget changed signal to display the correct filename in the GUI. Doing this in separate functions would complicate the code, in my opinion, but will try to do it and see how it goes.
src/frontend/gui/img2img_widget.py
Outdated
| self.img_path.setText("<<Generated image>>") | ||
| else: |
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.
We can remove this and show the initial image path
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 way the code works now, once an image has been generated, clicking the Generate button again will use the currently displayed image as init image, not the file that was selected via the file selection dialog, thus the <<Generated image>> text, since displaying the selected file path would be misleading. The alternative would be to use the user selected image as init image even though the displayed image is no longer the one the user selected and that would be confusing, in my opinion.
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.
That is not correct we need to use same init image for each button press similar to web ui
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.
Well, yeah, but the webui has two different GUI elements, one for displaying the init image and a different one for the generated image, so there's no confusion about which is your init image. Of course the same can be done with the Qt GUI by adding a different GUI element for the generated image but I wanted to maintain as much as possible the original compact design of the Qt GUI.
However, if you really think that's how it should work then I will do the corresponding changes.
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.
@monstruosoft In the image-to-image workflow no need to show the input image in Qt GUI, the user can select the path, that path will be shown in the text box, and there is no output image to input image feedback.
Qt GUI img2img changes
|
Sorry for the delay, it was a simple change but I wasn't able to push the changes until now. Hopefully it works now as expected. |
Thank you, I will check it |
|
@monstruosoft Thanks for the PR! |



I've had these changes ready to commit for a while now but didn't have the opportunity to push the changes. I've added Image to Image and Image Variations tabs to the Qt GUI. The idea is to eventually add all the modes already supported in the CLI and webui versions.
Right now, some code is duplicated from app_window.py into base_widget.py, it should be easy to remove the duplicated code once I can confirm that the current changes work.