File size: 619 Bytes
53b77d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import torch
import pickle

class TimeSeriesAnomalyDetectionHandler:
    def __init__(self):
        # Load the model from the .pt file
        with open("lstm_ed.pt", "rb") as f:
            self.model = torch.load(f)



    def __call__(self, event, context):
        # Parse the input data from the event
        data = event["data"]
        inputs = data

        # Run the model inference
        with torch.no_grad():
            outputs = self.model.predict(**inputs)

        # Process the model outputs
        predictions = outputs

        # Return the predictions
        return {"predictions": predictions}