fix samplers

This commit is contained in:
Vladimir Mandic
2023-10-19 10:19:46 -04:00
parent 505f36df87
commit e0c92b1085
3 changed files with 15 additions and 4 deletions
+1
View File
@@ -12,6 +12,7 @@ Service release addressing all zero-day issues reported so far...
- fix handling of relative path for models
- fix simple live preview device mismatch
- fix batch img2img
- fix diffusers dpm++ 2m and 1s samplers
- force second requirements check on startup
- remove lyco, multiple_tqdm
- enhance extension compatibility for exensions directly importing codeformers
+5 -3
View File
@@ -29,8 +29,8 @@ config = {
'DDIM': { 'clip_sample': True, 'set_alpha_to_one': True, 'steps_offset': 0, 'clip_sample_range': 1.0, 'sample_max_value': 1.0, 'timestep_spacing': 'linspace', 'rescale_betas_zero_snr': False },
'DDPM': { 'variance_type': "fixed_small", 'clip_sample': True, 'thresholding': False, 'clip_sample_range': 1.0, 'sample_max_value': 1.0, 'timestep_spacing': 'linspace'},
'DEIS': { 'solver_order': 2, 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': "deis", 'solver_type': "logrho", 'lower_order_final': True },
'DPM 1S++': { 'solver_order': 2, 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': "dpmsolver++", 'solver_type': "midpoint", 'lower_order_final': True, 'use_karras_sigmas': False },
'DPM 2M++': { 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': "dpmsolver++", 'solver_type': "midpoint", 'lower_order_final': True, 'use_karras_sigmas': False },
'DPM++ 1S': { 'solver_order': 2, 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': "dpmsolver++", 'solver_type': "midpoint", 'lower_order_final': True, 'use_karras_sigmas': False },
'DPM++ 2M': { 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': "dpmsolver++", 'solver_type': "midpoint", 'lower_order_final': True, 'use_karras_sigmas': False },
'DPM SDE': { 'use_karras_sigmas': False },
'Euler a': { },
'Euler': { 'interpolation_type': "linear", 'use_karras_sigmas': False },
@@ -66,9 +66,10 @@ class DiffusionSampler:
return
self.name = name
self.config = {}
self.config = config['All'].copy() # apply global defaults
if not hasattr(model, 'scheduler'):
return
for key, value in config.get('All', {}).items(): # apply global defaults
self.config[key] = value
for key, value in config.get(name, {}).items(): # apply diffusers per-scheduler defaults
self.config[key] = value
if hasattr(model.scheduler, 'scheduler_config'): # find model defaults
@@ -102,5 +103,6 @@ class DiffusionSampler:
self.config['beta_start'] = shared.opts.schedulers_beta_start
if 'beta_end' in self.config and shared.opts.schedulers_beta_end > 0:
self.config['beta_end'] = shared.opts.schedulers_beta_end
print('HERE9', self.config)
self.sampler = constructor(**self.config)
self.sampler.name = name
+9 -1
View File
@@ -23,9 +23,11 @@ allowed_dirs = []
dir_cache = {} # key=path, value=(mtime, listdir(path))
refresh_time = 0
extra_pages = shared.extra_networks
debug = shared.log.info if os.environ.get('SD_EN_DEBUG', None) is not None else lambda *args, **kwargs: None
def listdir(path):
debug(f'EN list-dir: {path}')
if not os.path.exists(path):
return []
if path in dir_cache and os.path.getmtime(path) == dir_cache[path][0]:
@@ -37,6 +39,7 @@ def listdir(path):
def register_page(page):
# registers extra networks page for the UI; recommend doing it in on_before_ui() callback for extensions
debug(f'EN register-page: {page}')
shared.extra_networks.append(page)
allowed_dirs.clear()
for pg in shared.extra_networks:
@@ -165,6 +168,7 @@ class ExtraNetworksPage:
return True
def create_thumb(self):
debug(f'EN create-thumb: {self.name}')
created = 0
for f in self.missing_thumbs:
if not os.path.exists(f):
@@ -197,6 +201,7 @@ class ExtraNetworksPage:
self.missing_thumbs.clear()
def create_items(self, tabname):
debug(f'EN create-items: {self.name}')
if self.refresh_time is not None and self.refresh_time > refresh_time: # cached results
return
t0 = time.time()
@@ -213,6 +218,7 @@ class ExtraNetworksPage:
def create_page(self, tabname, skip = False):
debug(f'EN create-page: {self.name}')
if self.page_time > refresh_time: # cached page
return self.html
self_name_id = self.name.replace(" ", "_")
@@ -249,7 +255,8 @@ class ExtraNetworksPage:
else:
return ''
shared.log.debug(f"Extra networks: page='{self.name}' items={len(self.items)} subdirs={len(subdirs)} tab={tabname} dirs={self.allowed_directories_for_previews()} time={self.list_time}s")
threading.Thread(target=self.create_thumb).start()
if len(self.missing_thumbs) > 0:
threading.Thread(target=self.create_thumb).start()
return self.html
def list_items(self):
@@ -394,6 +401,7 @@ class ExtraNetworksUi:
def create_ui(container, button_parent, tabname, skip_indexing = False):
debug(f'EN create-ui: {tabname}')
ui = ExtraNetworksUi()
ui.tabname = tabname
ui.pages = []