import numpy as np

import torch

import time


torch.manual_seed(42)

np.random.seed(42)

torch.set_num_threads(1)


# @torch.inference_mode()

def inference():

    X = np.random.randn(1, 3, 800, 6000)

    min_vals = X.min(axis=(2, 3), keepdims=True)  # Min across height and width (axis 2 and 3)

    max_vals = X.max(axis=(2, 3), keepdims=True)  # Max across height and width (axis 2 and 3)

    scale = max_vals - min_vals

    scale[scale == 0] =  1

    X = (X - min_vals) / (scale)


    model = torch.jit.load("ts-model-2.3/unet-l23-cosmic500-e50.ts")

    device = "cpu"

    model = model.to(device).float()

    model = model.eval()


    X = torch.tensor(X).to(device).float()

    with torch.no_grad():
        pred = (model(X) > 0.5)




if __name__ == "__main__":

    t1 = time.time()

    inference()

    print(time.time()-t1)
