Skip to content

Commit

Permalink
fix colorfix for the input size was different
Browse files Browse the repository at this point in the history
  • Loading branch information
gameltb committed Mar 1, 2024
1 parent 187502e commit fb60104
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 2 additions & 0 deletions modules/colorfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def adain_color_fix(target: Image, source: Image):
return result_image

def wavelet_color_fix(target: Image, source: Image):
source = source.resize(target.size, resample=Image.Resampling.LANCZOS)

# Convert images to tensors
to_tensor = ToTensor()
target_tensor = to_tensor(target).unsqueeze(0)
Expand Down
18 changes: 6 additions & 12 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,12 @@ def INPUT_TYPES(s):
CATEGORY = "image"

def fix_color(self, image, color_map_image, color_fix):
print(f"[StableSR] fix_color")
try:
color_fix_func = (
wavelet_color_fix if color_fix == "Wavelet" else adain_color_fix
)
result_image = color_fix_func(
tensor2pil(image), tensor2pil(color_map_image)
)
refined_image = pil2tensor(result_image)
return (refined_image,)
except Exception as e:
print(f"[StableSR] Error fix_color: {e}")
color_fix_func = (
wavelet_color_fix if color_fix == "Wavelet" else adain_color_fix
)
result_image = color_fix_func(tensor2pil(image), tensor2pil(color_map_image))
refined_image = pil2tensor(result_image)
return (refined_image,)


original_sample = comfy.sample.sample
Expand Down

0 comments on commit fb60104

Please sign in to comment.