Fixes ControlNet and styling issues.

This commit is contained in:
Yanko
2023-09-30 22:16:23 +01:00
parent f3874a0c7b
commit 99ea83f925
3 changed files with 22 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
# Photopea Stable Diffusion WebUI Extension
# 🦜 Photopea Stable Diffusion WebUI Extension
[![Demo video](https://img.youtube.com/vi/f_OXiNAvtII/0.jpg)](https://youtu.be/f_OXiNAvtII)
@@ -8,6 +8,8 @@ In the tab, you will have an embedded Photopea editor and a few buttons to send
Consider supporting Photopea by [going premium](https://www.photopea.com/api/accounts)!
Also consider using the much better integrated (and more actively maintained) [Stable Diffusion PS Pea](https://github.com/huchenlei/stable-diffusion-ps-pea) extension by [huchenlei](https://github.com/huchenlei/)!
## Installation
On your Stable Diffusion WebUI, click the `Extensions` tab, then the `Install from URL` internal tab in that section. Paste the URL for this repo and click `Install`.
@@ -36,12 +38,21 @@ In case you have the ControlNet extension installed, you'll also have:
### WebUI image galleries
In the `txt2txt`, `img2img` and `extras` tab galleries (where your generated images appear), there will also be a **`Send to Photopea`** button. You can press it to send the currently selected image back to the Photopea tab. It will be added as a new rasterized layer to the currently open document.
**Known bug:** when large files are passed in, they might not instantly be rasterized (this happens due to Photopea loading the image asynchronously, but sending the response to the load request *before* the image is fully loaded).
You can also copy and paste the generated results normally into Photopea, and have multiple documents open etc.
**Known bugs:**
* When large files are passed in, they might not instantly be rasterized (this happens due to Photopea loading the image asynchronously, but sending the response to the load request *before* the image is fully loaded).
* In some scenarios, the `Send to Photopea`` buttons do not work. This appears to happen when they are created _before_ the galleries are fully initialized. If you encounter this, try restarting the UI. If you have clear repro steps, please [create an issue](https://github.com/yankooliveira/sd-webui-photopea-embed/issues) or comment to an existing one.
## Changelog
### 2023-09-30
- Fixes a bug that would not properly show ControlNet index dropdown
- Fixes a bug where it would not be possible to send to different ControlNet units
- Changes the `Send to Photopea` button to match the new UI style, officially adopting 🦜 as a mascot
### 2023-06-17
- Fixed ControlNet tab auto-uncollapse when sending images from Photopea.
- Patched `Send to Photopea` on Vladmandic fork (solution suggested by [bananasss00](https://github.com/bananasss00))

View File

@@ -34,9 +34,10 @@ function createSendToPhotopeaButton(queryId, gallery) {
const newButton = existingButton.cloneNode(true);
newButton.style.display = "flex";
newButton.id = `${queryId}_open_in_photopea`;
newButton.textContent = "Send to Photopea";
newButton.title = "Send to Photopea"
newButton.textContent = "\u{1F99C}";
newButton.addEventListener("click", () => openImageInPhotopea(gallery));
gradioApp().querySelector(`#${queryId}`).appendChild(newButton);
existingButton.parentNode.appendChild(newButton);
}
// Switches to the "Photopea" tab by finding and clicking on the DOM button.
@@ -230,7 +231,10 @@ function setImageOnControlNetInput(controlNetDiv, controlNetModelIndex, file) {
tabs[controlNetModelIndex].click();
}
imageInput = controlNetDiv.querySelectorAll("input[type='file']")[controlNetModelIndex];
// HACK: multiplying the index by 2 to match the proper input on the newest ControlNet extension
// was determined empirically and will likely break in the future (as all other DOM-based
// addressing tends to)
imageInput = controlNetDiv.querySelectorAll("input[type='file']")[controlNetModelIndex * 2];
setImageOnInput(imageInput, file);
}
);

View File

@@ -38,7 +38,7 @@ def on_ui_tabs():
)
# Controlnet might have more than one model tab (set by the 'control_net_max_models_num' setting).
try:
num_controlnet_models = opts.control_net_max_models_num
num_controlnet_models = opts.control_net_unit_count
except:
num_controlnet_models = 1