INNER CODE UNIT · Python

resize_factor

davidefiocco/streamlit-fastapi-model-serving · fastapi/segmentation.py:24

    resize_factor = min(max_size / width, max_size / height)
    resized_image = input_image.resize(
        (
            int(input_image.width * resize_factor),
            int(input_image.height * resize_factor),
        )
    )

    preprocess = transforms.Compose(
        [
            transforms.ToTensor(),
            transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
        ]
    )

    input_tensor = preprocess(resized_image)
    input_batch = input_tensor.unsqueeze(
        0

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…