mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-03-05 04:59:49 +00:00
Update sd_forge_controlnet_example.py
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
# Use --show-controlnet-example to see this extension.
|
||||
|
||||
|
||||
import os
|
||||
import gradio as gr
|
||||
|
||||
from modules import scripts
|
||||
from modules.shared_cmd_options import cmd_opts
|
||||
from modules.paths import models_path
|
||||
from modules.modelloader import load_file_from_url
|
||||
from ldm_patched.modules.controlnet import load_controlnet
|
||||
|
||||
|
||||
class ControlNetExampleForge(scripts.Script):
|
||||
@@ -20,14 +23,13 @@ class ControlNetExampleForge(scripts.Script):
|
||||
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.')
|
||||
funny_slider = gr.Slider(label='This slider does nothing. It just shows you how to transfer parameters.',
|
||||
minimum=0.0, maximum=1.0, value=0.5)
|
||||
|
||||
return input_image, funny_slider
|
||||
|
||||
def process_batch(self, p, *script_args, **kwargs):
|
||||
# This function will be called every batch.
|
||||
# If you develop controlnet, you will need some caches.
|
||||
# We do not implement any cache, so you just use your own way that makes you comfortable.
|
||||
# This function will be called every batch. Use your own way to cache.
|
||||
|
||||
input_image, funny_slider = script_args
|
||||
|
||||
@@ -39,6 +41,17 @@ class ControlNetExampleForge(scripts.Script):
|
||||
|
||||
print('Input image is read.')
|
||||
|
||||
model_dir = os.path.join(models_path, 'ControlNet')
|
||||
os.makedirs(model_dir, exist_ok=True)
|
||||
controlnet_canny_path = load_file_from_url(
|
||||
url='https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/control_v11p_sd15_canny_fp16.safetensors',
|
||||
model_dir=model_dir,
|
||||
file_name='control_v11p_sd15_canny_fp16.safetensors'
|
||||
)
|
||||
print('The model [control_v11p_sd15_canny_fp16.safetensors] download finished.')
|
||||
|
||||
controlnet = load_controlnet(controlnet_canny_path)
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user