-
Notifications
You must be signed in to change notification settings - Fork 0
/
infotext_example_selectable_scripts.py
37 lines (27 loc) · 1.36 KB
/
infotext_example_selectable_scripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
this is the selectable script example, you should read the basic version first
"""
from modules import scripts
import gradio as gr
class Script(scripts.Script):
def title(self):
return 'infotext example - selectable script'
def ui(self, is_img2img):
# this is essentially the same as the basic version without the enable checkbox and comments removed
slider = gr.Slider(label='slider', value=5)
text = gr.Textbox(label='text', value='some text')
number = gr.Number(label='number', value=5)
self.infotext_fields = [
(slider, 'infotext slider'),
(text, lambda d: d.get('infotext text', 'you can set default value')),
(number, lambda d: d.get('infotext number', None)),
]
return slider, text, number
def run(self, p, *args, **kwargs):
slider, text, number = args
# set p.extra_generation_params['Script'] to the title of your script will allow webui to automatically switch the current script when reading infotext
p.extra_generation_params['Script'] = self.title()
p.extra_generation_params['infotext slider'] = slider
p.extra_generation_params['infotext text'] = text
p.extra_generation_params['infotext number'] = number
# normally you would have your processing here, but this is just an infotext example.