Skip to content

Commit b2652b7

Browse files
committed
fixed a bug in the MatchImageRatioToPreset node.
1 parent efb9913 commit b2652b7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nodes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,14 +882,14 @@ def INPUT_TYPES(s):
882882

883883
def forward(self, image):
884884
h, w = image.shape[1:-1]
885-
aspect_ratio = h / w
885+
aspect_ratio = w / h
886886

887887
# 计算每个预设的宽高比,并与输入图像的宽高比进行比较
888-
distances = [abs(aspect_ratio - h/w) for h, w in self.presets]
888+
distances = [abs(aspect_ratio - w/h) for w,h in self.presets]
889889
closest_index = np.argmin(distances)
890890

891891
# 选择最接近的预设尺寸
892-
target_h, target_w = self.presets[closest_index]
892+
target_w, target_h = self.presets[closest_index]
893893

894894
max_v, min_v = max(target_h, target_w), min(target_h, target_w)
895895
logger.debug((target_w, target_h, min_v, max_v))

0 commit comments

Comments
 (0)