diff options
author | Chris OBryan <13701027+cobryan05@users.noreply.github.com> | 2022-11-03 02:37:43 +0000 |
---|---|---|
committer | Chris OBryan <13701027+cobryan05@users.noreply.github.com> | 2022-11-03 02:37:43 +0000 |
commit | 313e14de04d9955c6ad077341feceb0fc7f2f1d3 (patch) | |
tree | a5835c6d03a89c7464577f1c66b4b530c649b31d | |
parent | d98eacea40c7a40227f36dbea9cf92f90489310b (diff) | |
download | stable-diffusion-webui-gfx803-313e14de04d9955c6ad077341feceb0fc7f2f1d3.tar.gz stable-diffusion-webui-gfx803-313e14de04d9955c6ad077341feceb0fc7f2f1d3.tar.bz2 stable-diffusion-webui-gfx803-313e14de04d9955c6ad077341feceb0fc7f2f1d3.zip |
extras - skip unnecessary second hash of image
There is no need to re-hash the input image each iteration of the loop.
This also reverts PR #4026 as it was determined the cache hits it avoids
were actually valid.
-rw-r--r-- | modules/extras.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/extras.py b/modules/extras.py index 8e2ab35c..71b93a06 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -136,12 +136,13 @@ def run_extras(extras_mode, resize_mode, image, image_folder, input_dir, output_ def run_upscalers_blend(params: List[UpscaleParams], image: Image.Image, info: str) -> Tuple[Image.Image, str]:
blended_result: Image.Image = None
+ image_hash: str = hash(np.array(image.getdata()).tobytes())
for upscaler in params:
upscale_args = (upscaler.upscaler_idx, upscaling_resize, resize_mode,
upscaling_resize_w, upscaling_resize_h, upscaling_crop)
- cache_key = LruCache.Key(image_hash=hash(np.array(image.getdata()).tobytes()),
+ cache_key = LruCache.Key(image_hash=image_hash,
info_hash=hash(info),
- args_hash=hash((upscale_args, upscale_first)))
+ args_hash=hash(upscale_args))
cached_entry = cached_images.get(cache_key)
if cached_entry is None:
res = upscale(image, *upscale_args)
|