mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-03-10 23:49:48 +00:00
Add back ControlNet model version filter (#131)
* Add back ControlNet model version filter * Update choice after sd model changes
This commit is contained in:
@@ -129,6 +129,9 @@ callback_map = dict(
|
||||
callbacks_list_optimizers=[],
|
||||
callbacks_list_unets=[],
|
||||
)
|
||||
event_subscriber_map = dict(
|
||||
callbacks_setting_updated=[],
|
||||
)
|
||||
|
||||
|
||||
def clear_callbacks():
|
||||
@@ -309,6 +312,23 @@ def list_unets_callback():
|
||||
return res
|
||||
|
||||
|
||||
def setting_updated_event_subscriber_chain(handler, component, setting_name: str):
|
||||
"""
|
||||
Arguments:
|
||||
- handler: The returned handler from calling an event subscriber.
|
||||
- component: The component that is updated. The component should provide
|
||||
the value of setting after update.
|
||||
- setting_name: The name of the setting.
|
||||
"""
|
||||
for param in event_subscriber_map['callbacks_setting_updated']:
|
||||
handler = handler.then(
|
||||
fn=lambda *args: param["fn"](*args, setting_name),
|
||||
inputs=param["inputs"] + [component],
|
||||
outputs=param["outputs"],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
|
||||
def add_callback(callbacks, fun):
|
||||
stack = [x for x in inspect.stack() if x.filename != __file__]
|
||||
filename = stack[0].filename if stack else 'unknown file'
|
||||
@@ -483,3 +503,13 @@ def on_list_unets(callback):
|
||||
The function will be called with one argument, a list, and shall add objects of type modules.sd_unet.SdUnetOption to it."""
|
||||
|
||||
add_callback(callback_map['callbacks_list_unets'], callback)
|
||||
|
||||
|
||||
def on_setting_updated_subscriber(subscriber_params):
|
||||
"""register a function to be called after settings update. `subscriber_params`
|
||||
should contain necessary fields to register an gradio event handler. Necessary
|
||||
fields are ["fn", "outputs", "inputs"].
|
||||
Setting name and setting value after update will be append to inputs. So be
|
||||
sure to handle these extra params when defining the callback function.
|
||||
"""
|
||||
event_subscriber_map['callbacks_setting_updated'].append(subscriber_params)
|
||||
|
||||
Reference in New Issue
Block a user