Skip to content

Commit 1b9faaa

Browse files
Merge pull request #4196 from cobryan05/extras_no_rehash
extras - skip unnecessary second hash of image
2 parents faa79b0 + 313e14d commit 1b9faaa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/extras.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ class UpscaleParams:
136136

137137
def run_upscalers_blend(params: List[UpscaleParams], image: Image.Image, info: str) -> Tuple[Image.Image, str]:
138138
blended_result: Image.Image = None
139+
image_hash: str = hash(np.array(image.getdata()).tobytes())
139140
for upscaler in params:
140141
upscale_args = (upscaler.upscaler_idx, upscaling_resize, resize_mode,
141142
upscaling_resize_w, upscaling_resize_h, upscaling_crop)
142-
cache_key = LruCache.Key(image_hash=hash(np.array(image.getdata()).tobytes()),
143+
cache_key = LruCache.Key(image_hash=image_hash,
143144
info_hash=hash(info),
144-
args_hash=hash((upscale_args, upscale_first)))
145+
args_hash=hash(upscale_args))
145146
cached_entry = cached_images.get(cache_key)
146147
if cached_entry is None:
147148
res = upscale(image, *upscale_args)

0 commit comments

Comments
 (0)