Skip to content

Commit

Permalink
fix api (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
lllyasviel authored Jun 5, 2023
1 parent f364938 commit 7ad8cc8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
27 changes: 27 additions & 0 deletions scripts/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,33 @@ def process(self, p, *args):
# safe numpy
input_image = np.ascontiguousarray(input_image.copy()).copy()

if unit.processor_res < 0:
try:
cfg = preprocessor_sliders_config[global_state.get_module_basename(unit.module)]
unit.processor_res = int(cfg[0]['value'])
logger.info(f'API used default config: unit.processor_res = {unit.processor_res}')
except:
unit.processor_res = 512
logger.info(f'API used default value: unit.processor_res = {unit.processor_res}')

if unit.threshold_a < 0:
try:
cfg = preprocessor_sliders_config[global_state.get_module_basename(unit.module)]
unit.threshold_a = float(cfg[1]['value'])
logger.info(f'API used default config: unit.threshold_a = {unit.threshold_a}')
except:
unit.threshold_a = 0
logger.info(f'API used default value: unit.threshold_a = {unit.threshold_a}')

if unit.threshold_b < 0:
try:
cfg = preprocessor_sliders_config[global_state.get_module_basename(unit.module)]
unit.threshold_b = float(cfg[2]['value'])
logger.info(f'API used default config: unit.threshold_b = {unit.threshold_b}')
except:
unit.threshold_b = 0
logger.info(f'API used default value: unit.threshold_b = {unit.threshold_b}')

logger.info(f"Loading preprocessor: {unit.module}")
preprocessor = self.preprocessor[unit.module]
h, w, bsz = p.height, p.width, p.batch_size
Expand Down
2 changes: 1 addition & 1 deletion scripts/controlnet_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version_flag = 'v1.1.217'
version_flag = 'v1.1.218'

from scripts.logging import logger

Expand Down
6 changes: 3 additions & 3 deletions scripts/external_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ def __init__(
image: Optional[InputImage]=None,
resize_mode: Union[ResizeMode, int, str] = ResizeMode.INNER_FIT,
low_vram: bool=False,
processor_res: int=512,
threshold_a: float=64,
threshold_b: float=64,
processor_res: int=-1,
threshold_a: float=-1,
threshold_b: float=-1,
guidance_start: float=0.0,
guidance_end: float=1.0,
pixel_perfect: bool=False,
Expand Down

0 comments on commit 7ad8cc8

Please sign in to comment.