This commit is contained in:
lllyasviel
2024-01-27 16:06:07 -08:00
parent af375839f3
commit d430320ace
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
def preload(parser):
parser.add_argument(
"--show-controlnet-example",
action="store_true",
help="Show development example extension for ControlNet.",
)

View File

@@ -0,0 +1,40 @@
import gradio as gr
from modules import scripts
from modules.shared_cmd_options import cmd_opts
class ControlNetExampleForge(scripts.Script):
def title(self):
return "ControlNet Example for Developers"
def show(self, is_img2img):
# make this extension visible in both txt2img and img2img tab.
return scripts.AlwaysVisible
def ui(self, *args, **kwargs):
with gr.Accordion(open=False, label=self.title()):
gr.HTML('This is an example controlnet extension for developers.')
gr.HTML('You see this extension because you used --show-controlnet-example')
input_image = gr.Image(source='upload', type='numpy')
funny_slider = gr.Slider(label='This slider does nothing. It just shows you how to transfer parameters.')
return input_image, funny_slider
def process_batch(self, p, *script_args, **kwargs):
input_image, funny_slider = script_args
# This slider does nothing. It just shows you how to transfer parameters.
del funny_slider
if input_image is None:
return
print('Input image is read')
return
# Use --show-controlnet-example to see this extension.
if not cmd_opts.show_controlnet_example:
del ControlNetExampleForge