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

Function handler

exp/fork-functions/recognition/function.py:25–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

benchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected