MCPcopy Create free account
hub / github.com/ProjectMitosisOS/mitosis-core / handler

Function handler

exp/fork-functions/recognition/function_bench.py:24–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22input_image = Image.open("test.jpg")
23
24def handler():
25 preprocess = transforms.Compose([
26 transforms.Resize(256),
27 transforms.CenterCrop(224),
28 transforms.ToTensor(),
29 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
30 ])
31 input_tensor = preprocess(input_image)
32 input_batch = input_tensor.unsqueeze(0) # create a mini-batch as expected by the model
33 output = model(input_batch)
34 _, index = torch.max(output, 1)
35 # The output has unnormalized scores. To get probabilities, you can run a softmax on it.
36 prob = torch.nn.functional.softmax(output[0], dim=0)
37 _, indices = torch.sort(output, descending=True)
38
39@func_exec_bench
40def bench():

Callers 1

benchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected