self.device = torch.device(
        "cuda:" + str(properties.get("gpu_id"))
        if torch.cuda.is_available() and properties.get("gpu_id") is not None
        else "cpu"
        )
        self.model = torch.jit.load(model_pt_path, map_location=self.device)
    self.model = self.model.half()

def preprocess(self, data):

    inputs = []
    for request in batch:

        request_body = request.get("body")

        input_ = io.BytesIO(request_body)
        image = cv2.imdecode(np.fromstring(input_.read(), np.uint8), 1)
        input = torch.Tensor(image).permute(2, 0, 1)
        input = input.to(self.device)
        input = input.half()
        inputs.append({"image": input})

    return inputs

def inference(self,inputs):
    predictions = self.model(**inputs)
    return predictions

def postprocess(self, output):
    responses = []
    for inference_output in inference_outputs:
        responses_json = {
