mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
cleanup logging and update requirements
Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
+4
-2
@@ -495,12 +495,14 @@ def check_transformers():
|
||||
return
|
||||
pkg_transformers = package_spec('transformers')
|
||||
pkg_tokenizers = package_spec('tokenizers')
|
||||
target_commit = '753d61104116eefc8ffc977327b441ee0c8d599f' # transformers commit hash == 4.57.6
|
||||
# target_commit = '753d61104116eefc8ffc977327b441ee0c8d599f' # transformers commit hash == 4.57.6
|
||||
target_commit = 'a28c974c7ac74c83dbf379e93ceecc2661730f63' # transformers commit hash == 4.57.6
|
||||
if args.use_directml:
|
||||
target_transformers = '4.52.4'
|
||||
target_tokenizers = '0.21.4'
|
||||
else:
|
||||
target_transformers = '4.57.6'
|
||||
# target_transformers = '4.57.6'
|
||||
target_transformers = None
|
||||
target_tokenizers = '0.22.2'
|
||||
if target_transformers is not None:
|
||||
# Pinned release version (e.g. DirectML)
|
||||
|
||||
@@ -179,7 +179,7 @@ class APIControl:
|
||||
u = req.control[i]
|
||||
ut = u.unit_type if u.unit_type is not None else default_type
|
||||
if ut not in unit_types:
|
||||
shared.log.error(f'Control unknown unit type: type={ut} available={unit_types}')
|
||||
log.error(f'Control unknown unit type: type={ut} available={unit_types}')
|
||||
continue
|
||||
if (len(self.units) > i) and (self.units[i].process_id == u.process) and (self.units[i].model_id == u.model) and (self.units[i].type == ut):
|
||||
unit = self.units[i]
|
||||
|
||||
@@ -510,7 +510,7 @@ def update_pipeline(sd_model, p: processing.StableDiffusionProcessing):
|
||||
if sd_model is None:
|
||||
sd_model = shared.sd_model
|
||||
if sd_model is None:
|
||||
shared.log.warning('Processing: op=update model not loaded')
|
||||
log.warning('Processing: op=update model not loaded')
|
||||
return None
|
||||
updated_model = sd_model
|
||||
if sd_models.get_diffusers_task(sd_model) == sd_models.DiffusersTaskType.INPAINTING and getattr(p, 'image_mask', None) is None and p.task_args.get('image_mask', None) is None and getattr(p, 'mask', None) is None:
|
||||
|
||||
@@ -7,7 +7,7 @@ import torch
|
||||
import accelerate.hooks
|
||||
import accelerate.utils.modeling
|
||||
from modules.logger import log
|
||||
from modules import shared, devices, errors, model_quant, sd_models, sd_models_aux
|
||||
from modules import shared, devices, errors, model_quant, sd_models, sd_offload_aux
|
||||
from modules.timer import process as process_timer
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ class OffloadHook(accelerate.hooks.ModelHook):
|
||||
if shared.opts.diffusers_offload_pre:
|
||||
t0 = time.time()
|
||||
debug_move(f'Offload: type=balanced op=pre module={module.__class__.__name__}')
|
||||
sd_models_aux.evict_aux(reason=f'pre:{module.__class__.__name__}')
|
||||
sd_offload_aux.evict_aux(reason=f'pre:{module.__class__.__name__}')
|
||||
for pipe in get_pipe_variants():
|
||||
for module_name in get_module_names(pipe):
|
||||
module_instance = getattr(pipe, module_name, None)
|
||||
|
||||
@@ -3,7 +3,6 @@ import dataclasses
|
||||
import torch
|
||||
from modules.logger import log
|
||||
from modules import shared, devices
|
||||
from modules.timer import process as process_timer
|
||||
|
||||
|
||||
move_stream = None
|
||||
|
||||
@@ -486,7 +486,7 @@ class DiffusionSampler:
|
||||
try:
|
||||
cls_source = inspect.getsource(constructor)
|
||||
if '"flow_prediction"' not in cls_source and "'flow_prediction'" not in cls_source:
|
||||
shared.log.warning(f'Sampler: "{name}" does not support flow_prediction')
|
||||
log.warning(f'Sampler: "{name}" does not support flow_prediction')
|
||||
self.sampler = None
|
||||
return
|
||||
except (TypeError, OSError):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from modules.logger import log
|
||||
from modules import shared
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ def apply_token_merging(sd_model, p=None):
|
||||
if current_tome == tome:
|
||||
return
|
||||
if hypertile and not shared.cmd_opts.experimental:
|
||||
shared.log.warning('Token merging not supported with HyperTile for UNet')
|
||||
log.warning('Token merging not supported with HyperTile for UNet')
|
||||
return
|
||||
try:
|
||||
import installer
|
||||
@@ -34,10 +35,10 @@ def apply_token_merging(sd_model, p=None):
|
||||
merge_crossattn=False,
|
||||
merge_mlp=False
|
||||
)
|
||||
shared.log.info(f'Applying ToMe: ratio={tome}')
|
||||
log.info(f'Applying ToMe: ratio={tome}')
|
||||
sd_model.applied_tome = tome
|
||||
except Exception:
|
||||
shared.log.warning(f'Token merging not supported: pipeline={sd_model.__class__.__name__}')
|
||||
log.warning(f'Token merging not supported: pipeline={sd_model.__class__.__name__}')
|
||||
else:
|
||||
sd_model.applied_tome = 0
|
||||
|
||||
@@ -45,7 +46,7 @@ def apply_token_merging(sd_model, p=None):
|
||||
if current_todo == todo:
|
||||
return
|
||||
if hypertile and not shared.cmd_opts.experimental:
|
||||
shared.log.warning('Token merging not supported with HyperTile for UNet')
|
||||
log.warning('Token merging not supported with HyperTile for UNet')
|
||||
return
|
||||
try:
|
||||
from modules.todo.todo_utils import patch_attention_proc
|
||||
@@ -61,10 +62,10 @@ def apply_token_merging(sd_model, p=None):
|
||||
"ratio_level_2": 0.0,
|
||||
}
|
||||
patch_attention_proc(sd_model.unet, token_merge_args=token_merge_args)
|
||||
shared.log.info(f'Applying ToDo: ratio={todo}')
|
||||
log.info(f'Applying ToDo: ratio={todo}')
|
||||
sd_model.applied_todo = todo
|
||||
except Exception:
|
||||
shared.log.warning(f'Token merging not supported: pipeline={sd_model.__class__.__name__}')
|
||||
log.warning(f'Token merging not supported: pipeline={sd_model.__class__.__name__}')
|
||||
else:
|
||||
sd_model.applied_todo = 0
|
||||
|
||||
|
||||
@@ -197,11 +197,7 @@ def create_ui(_blocks: gr.Blocks=None):
|
||||
|
||||
guidance_name, guidance_scale, guidance_rescale, guidance_start, guidance_stop, cfg_scale, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end = ui_guidance.create_guidance_inputs('control')
|
||||
vae_type, tiling, hidiffusion, clip_skip = ui_sections.create_advanced_inputs('control')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, \
|
||||
grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, \
|
||||
grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, \
|
||||
grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, \
|
||||
grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('control')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('control')
|
||||
|
||||
with gr.Accordion(open=False, label="Video", elem_id="control_video", elem_classes=["small-accordion"]):
|
||||
with gr.Row():
|
||||
|
||||
@@ -135,11 +135,7 @@ def create_ui():
|
||||
|
||||
guidance_name, guidance_scale, guidance_rescale, guidance_start, guidance_stop, cfg_scale, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end = ui_guidance.create_guidance_inputs('img2img')
|
||||
vae_type, tiling, hidiffusion, clip_skip = ui_sections.create_advanced_inputs('img2img')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, \
|
||||
grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, \
|
||||
grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, \
|
||||
grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, \
|
||||
grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('img2img')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('img2img')
|
||||
enable_hr, hr_sampler_index, hr_denoising_strength, hr_resize_mode, hr_resize_context, hr_upscaler, hr_force, hr_second_pass_steps, hr_scale, hr_resize_x, hr_resize_y, refiner_steps, hr_refiner_start, refiner_prompt, refiner_negative = ui_sections.create_hires_inputs('img2img')
|
||||
detailer_enabled, detailer_prompt, detailer_negative, detailer_steps, detailer_strength, detailer_resolution = shared.yolo.ui('img2img')
|
||||
|
||||
|
||||
@@ -35,11 +35,7 @@ def create_ui():
|
||||
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w = ui_sections.create_seed_inputs('txt2img')
|
||||
guidance_name, guidance_scale, guidance_rescale, guidance_start, guidance_stop, cfg_scale, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end = ui_guidance.create_guidance_inputs('txt2img')
|
||||
vae_type, tiling, hidiffusion, clip_skip = ui_sections.create_advanced_inputs('txt2img')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, \
|
||||
grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, \
|
||||
grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, \
|
||||
grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, \
|
||||
grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('txt2img')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundary, hdr_color_picker, hdr_tint_ratio, hdr_apply_hires, grading_brightness, grading_contrast, grading_saturation, grading_hue, grading_gamma, grading_sharpness, grading_color_temp, grading_shadows, grading_midtones, grading_highlights, grading_clahe_clip, grading_clahe_grid, grading_shadows_tint, grading_highlights_tint, grading_split_tone_balance, grading_vignette, grading_grain, grading_lut_file, grading_lut_strength = ui_sections.create_color_inputs('txt2img')
|
||||
enable_hr, hr_sampler_index, hr_denoising_strength, hr_resize_mode, hr_resize_context, hr_upscaler, hr_force, hr_second_pass_steps, hr_scale, hr_resize_x, hr_resize_y, refiner_steps, refiner_start, refiner_prompt, refiner_negative = ui_sections.create_hires_inputs('txt2img')
|
||||
detailer_enabled, detailer_prompt, detailer_negative, detailer_steps, detailer_strength, detailer_resolution = shared.yolo.ui('txt2img')
|
||||
override_settings = ui_common.create_override_inputs('txt2img')
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ requests==2.32.3
|
||||
tqdm==4.67.3
|
||||
accelerate==1.12.0
|
||||
einops==0.8.1
|
||||
huggingface_hub==0.36.2
|
||||
huggingface_hub==1.5.0
|
||||
numpy==2.1.2
|
||||
pandas==2.3.1
|
||||
protobuf==6.33.5
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
"""
|
||||
downloads: https://luts.iwltbap.com/
|
||||
lib: https://github.com/homm/pillow-lut-tools
|
||||
"""
|
||||
import os
|
||||
import gradio as gr
|
||||
from installer import install
|
||||
from modules import scripts_manager, processing
|
||||
from modules.logger import log
|
||||
|
||||
|
||||
class Script(scripts_manager.Script):
|
||||
def title(self):
|
||||
return 'LUT Color grading'
|
||||
|
||||
def show(self, is_img2img): # pylint: disable=unused-argument
|
||||
return True
|
||||
|
||||
def ui(self, _is_img2img):
|
||||
with gr.Row():
|
||||
gr.HTML("<span>  LUT Color grading</span><br>")
|
||||
with gr.Row():
|
||||
original = gr.Checkbox(label='Include original image', value=True)
|
||||
with gr.Row():
|
||||
cube_file = gr.File(label='LUT .cube file', help='Download LUTs from https://luts.iwltbap.com/')
|
||||
# cube_file = gr.File(label='LUT .cube file')
|
||||
with gr.Row():
|
||||
gr.HTML("<br>Enhance LUT")
|
||||
with gr.Row():
|
||||
cube_scale = gr.Slider(label='Amplify LUT', minimum=0.0, maximum=5.0, step=0.05, value=1.0)
|
||||
brightness = gr.Slider(label='Brightness', minimum=-1, maximum=1, step=0.05, value=0)
|
||||
exposure = gr.Slider(label='Exposure', minimum=-5, maximum=5, step=0.05, value=0)
|
||||
contrast = gr.Slider(label='Contrast', minimum=-1, maximum=1, step=0.05, value=0)
|
||||
warmth = gr.Slider(label='Warmth', minimum=-1, maximum=1, step=0.05, value=0)
|
||||
saturation = gr.Slider(label='Saturation', minimum=-1, maximum=5, step=0.05, value=0)
|
||||
vibrance = gr.Slider(label='Vibrance', minimum=-1, maximum=5, step=0.05, value=0)
|
||||
hue = gr.Slider(label='Hue', minimum=0, maximum=1, step=0.05, value=0)
|
||||
gamma = gr.Slider(label='Gamma', minimum=0, maximum=10.0, step=0.1, value=1.0)
|
||||
return [original, cube_file, cube_scale, brightness, exposure, contrast, warmth, saturation, vibrance, hue, gamma]
|
||||
|
||||
# auto-executed by the script-callback
|
||||
def after(self, p: processing.StableDiffusionProcessing, processed: processing.Processed, original, cube_file, cube_scale, brightness, exposure, contrast, warmth, saturation, vibrance, hue, gamma): # pylint: disable=arguments-differ, unused-argument
|
||||
install('pillow_lut', quiet=True)
|
||||
import pillow_lut
|
||||
|
||||
cube = None
|
||||
name = os.path.splitext(os.path.basename(cube_file.name))[0] if cube_file is not None else None
|
||||
log.info(f'Color grading: cube="{name}" scale={cube_scale} brightness={brightness} exposure={exposure} contrast={contrast} warmth={warmth} saturation={saturation} vibrance={vibrance} hue={hue} gamma={gamma}')
|
||||
if cube_file is not None:
|
||||
try:
|
||||
cube = pillow_lut.load_cube_file(cube_file.name)
|
||||
cube = pillow_lut.amplify_lut(cube, cube_scale)
|
||||
cube = pillow_lut.rgb_color_enhance(source=cube, brightness=brightness, exposure=exposure, contrast=contrast, warmth=warmth, saturation=saturation, vibrance=vibrance, hue=hue, gamma=gamma)
|
||||
except Exception as e:
|
||||
log.error(f'Color grading: {e}')
|
||||
|
||||
images = []
|
||||
if processed is not None and len(processed.images) > 0:
|
||||
for image in processed.images:
|
||||
info = image.info.get('parameters', '')
|
||||
if original:
|
||||
images.append(image)
|
||||
if cube is not None:
|
||||
filtered = image.filter(cube)
|
||||
filtered.info['parameters'] = f'{info}, LUT: {name}'
|
||||
images.append(filtered)
|
||||
processed.images = images
|
||||
|
||||
return processed
|
||||
Reference in New Issue
Block a user