Skip to content

Commit

Permalink
fix adetailer with controlnet
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Nov 8, 2023
1 parent a03d7ce commit 8bcb14d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
30 changes: 30 additions & 0 deletions modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import warnings
from contextlib import nullcontext
from typing import Any, Dict, List
from dataclasses import dataclass, field
import torch
import numpy as np
import cv2
Expand Down Expand Up @@ -115,6 +116,7 @@ def txt2img_image_conditioning(sd_model, x, width, height):
return x.new_zeros(x.shape[0], 5, 1, 1, dtype=x.dtype, device=x.device)


@dataclass(repr=False)
class StableDiffusionProcessing:
"""
The first set of paramaters: sd_models -> do_not_reload_embeddings represent the minimum required to create a StableDiffusionProcessing
Expand Down Expand Up @@ -203,11 +205,39 @@ def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prom
self.all_hr_negative_prompts = []
self.comments = {}
self.is_api = False
self.scripts_value: modules.scripts.ScriptRunner = field(default=None, init=False)
self.script_args_value: list = field(default=None, init=False)
self.scripts_setup_complete: bool = field(default=False, init=False)


@property
def sd_model(self):
return shared.sd_model

@property
def scripts(self):
return self.scripts_value

@scripts.setter
def scripts(self, value):
self.scripts_value = value
if self.scripts_value and self.script_args_value and not self.scripts_setup_complete:
self.setup_scripts()

@property
def script_args(self):
return self.script_args_value

@script_args.setter
def script_args(self, value):
self.script_args_value = value
if self.scripts_value and self.script_args_value and not self.scripts_setup_complete:
self.setup_scripts()

def setup_scripts(self):
self.scripts_setup_complete = True
self.scripts.setup_scrips(self, is_ui=not self.is_api)

def comment(self, text):
self.comments[text] = 1

Expand Down
3 changes: 2 additions & 1 deletion modules/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import csv
import json
from installer import log
from modules import paths


class Style():
Expand Down Expand Up @@ -66,6 +65,8 @@ def apply_styles_to_extra(p, style: Style):

class StyleDatabase:
def __init__(self, opts):
from modules import paths

self.no_style = Style("None")
self.styles = {}
self.path = opts.styles_dir
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ requests==2.31.0
tqdm==4.66.1
accelerate==0.20.3
opencv-python-headless==4.7.0.72
diffusers==0.22.0
diffusers==0.22.3
einops==0.4.1
gradio==3.43.2
huggingface_hub==0.18.0
Expand Down

0 comments on commit 8bcb14d

Please sign in to comment.