Skip to content

Conversation

@monstruosoft
Copy link
Contributor

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.

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
@rupeshs
Copy link
Owner

rupeshs commented Dec 21, 2024

This is not working as expected image to image workflow user should be able to select image file
image

@monstruosoft
Copy link
Contributor Author

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.

@rupeshs
Copy link
Owner

rupeshs commented Dec 22, 2024

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.

@monstruosoft
Copy link
Contributor Author

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
@monstruosoft
Copy link
Contributor Author

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.

@rupeshs
Copy link
Owner

rupeshs commented Dec 30, 2024

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.

For image input workflows(image to image and image variations) ,we can provide a button(...) to browse for the files, that will be more simpler UI.
image

@monstruosoft
Copy link
Contributor Author

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.
@monstruosoft
Copy link
Contributor Author

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.

@rupeshs
Copy link
Owner

rupeshs commented Jan 3, 2025

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.

Nice work, we can keep the path in text box no need to show <>
image

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code

path = unquote(urlparse(event.mimeData().text()).path)
self.show_image(path)

def show_image(self, filename: str, pixmap: QPixmap = None):
Copy link
Owner

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

Comment on lines 71 to 82
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()
Copy link
Owner

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

Copy link
Contributor Author

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.

Comment on lines 149 to 150
self.img_path.setText("<<Generated image>>")
else:
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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
@monstruosoft
Copy link
Contributor Author

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.

@rupeshs
Copy link
Owner

rupeshs commented Jan 20, 2025

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

@rupeshs
Copy link
Owner

rupeshs commented Jan 24, 2025

@monstruosoft Thanks for the PR!

@rupeshs rupeshs merged commit 7306532 into rupeshs:main Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants