https://github.com/haoming02/sd-webui-yapping
An Extension for Automatic1111 Webui that adds presets for parameters
https://github.com/haoming02/sd-webui-yapping
stable-diffusion-webui stable-diffusion-webui-plugin
Last synced: 6 months ago
JSON representation
An Extension for Automatic1111 Webui that adds presets for parameters
- Host: GitHub
- URL: https://github.com/haoming02/sd-webui-yapping
- Owner: Haoming02
- License: mit
- Created: 2024-07-12T08:16:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-21T13:28:24.000Z (over 1 year ago)
- Last Synced: 2024-10-23T10:33:11.376Z (over 1 year ago)
- Topics: stable-diffusion-webui, stable-diffusion-webui-plugin
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Y**et **A**nother **P**reset-**P**lanning **I**ntegration: **N**ext-**G**en
Behold, the quintessence of computational artistry: the formidable "Preset Planning" integration, an immaculate marvel harnessed by the enchanting Python Gradio package, devoid of the cacophony of JavaScript's ubiquitous clamor. This technological paragon transcends the mundane, weaving a tapestry of seamless interaction and divine user experience.
Gaze, upon the sublime architecture of Gradio's Pythonic embrace, where form follows function with an unwavering fidelity. Embracing the purist ethos of simplicity, this plug-in shuns the ornate excesses of its counterparts, distilling the essence of user experience into a distilled elixir of elegance.
Consider, the "Preset Planning" integration, fortified by Python Gradio's mastery, stands not as a mere tool, but as a testament to the ingenuity of human imagination. It embodies the zenith of interface refinement, transcending the realm of expectation to forge a path toward a future where utility and artistry converge in resplendent harmony.
- ChatGPT
# SD Webui Yapping
This is an Extension for the [Automatic1111 Webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui), which adds fully-customizable preset buttons, that set specified parameters to specified values when clicked.
> Compatible with [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge)

Example Buttons
(used with Tabs Extension)
As mentioned in the *holy **yapping*** above, this Extension finds the fields during the UI setup process via Python, and uses the Gradio button events to change the parameters.
Thus, no more trying to query elements using JavaScript; no more hacky workaround to change element values; no more clashing due to identical field name.
## How to Use
> On a fresh install, the Extension will automatically rename `example.json` to `presets.json`, to avoid overriding users' existing presets
Within the `presets.json` file, there are 3 objects, `txt2img`, `img2img`, and `triggers`:
- The **txt2img** and **img2img** objects are responsible for the **Preset** buttons:
- Start with a key, which will become the name of the button. This is also the name used by the **triggers** below.
> If the `key` contains the phrase "sep", it will become a separator instead, placing buttons above and below it into different rows
- Then, open into an object that contains multiple key-value pairs. Each pair consists of the `elem_id` of the field, and the value to set the parameter to.
- The **triggers** object is responsible for hooking **Preset** to other buttons present in the Webui.
- The key is the `elem_id` of the button
- The value is in the format of `{tab}-{preset}`, where `{tab}` is either `t2i` or `i2i`, referring to the mode the preset was defined in; while `{preset}` is the name of the **Preset** to trigger.
#### Examples
- The following will add a button called `portrait` to the `txt2img` tab that when clicked, sets the `width` and `height` to `896` and `1152` respectively
```json
"txt2img": {
"portrait": {
"txt2img_width": 896,
"txt2img_height": 1152
}
}
```
- The following will trigger the `upscale` preset defined in `img2img` tab, when the `Send to img2img` button in the `txt2img` tab is clicked
```json
"triggers": {
"txt2img_send_to_img2img": "i2i-upscale",
}
```
> Refer to the `presets.json` for more included examples
elem_id
To find the `elem_id` of a parameter, right click on the field and click `Inspect Element`, then look through the parent elements until you can find a descriptive `id`.
Most parameters should work, as long as they are Gradio components defined with unique `elem_id` properly, even ones from other Extensions.
Listed below are some built-in `elem_id` that were tested and confirmed to work:
- `txt2img_sampling`
- `txt2img_width`
- `txt2img_height`
- `txt2img_steps`
- `txt2img_cfg_scale`
- `img2img_sampling`
- `img2img_width`
- `img2img_height`
- `img2img_steps`
- `img2img_cfg_scale`
- `img2img_denoising_strength`
- `txt2img_send_to_img2img`
- `img2img_send_to_inpaint`
- `img2img_tabs_resize`
## Roadmap
- [X] Implement error handling for invalid `elem_id`
- [X] Add a way to trigger a Preset from a built-in Button
- [X] Support Gradio.Tab
- [ ] Add a way to edit the Presets within the Webui