INNER CODE UNIT · Python

load_img

Shilin-LU/TF-ICON · scripts/app.py:32

def load_img(image, SCALE, pad=False, seg_map=False, target_size=None):
    if seg_map:
        # Load the input image and segmentation map
        # image = Image.open(path).convert("RGB")
        # seg_map = Image.open(seg).convert("1")

        seg_map = seg_map.convert("1")
        # Get the width and height of the original image
        w, h = image.size

        # Calculate the aspect ratio of the original image
        aspect_ratio = h / w

        # Determine the new dimensions for resizing the image while maintaining aspect ratio
        if aspect_ratio > 1:
            new_w = int(SCALE * 256 / aspect_ratio)
            new_h = int(SCALE * 256)
        else:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…