donghuna commited on
Commit
fca2c62
ยท
verified ยท
1 Parent(s): a5cd004

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +13 -0
handler.py CHANGED
@@ -12,13 +12,26 @@ class EndpointHandler:
12
  self.model.eval()
13
 
14
  def __call__(self, data):
 
 
 
15
  frames = np.array(data['frames'])
16
  frames = torch.tensor(frames).float() # Ensure the data is in the correct format
 
 
 
17
 
18
  # Perform inference
19
  with torch.no_grad():
20
  outputs = self.model(frames.unsqueeze(0)) # Add batch dimension
21
  predictions = torch.softmax(outputs.logits, dim=-1)
 
 
 
 
22
  predicted_class = torch.argmax(predictions, dim=-1).item()
 
 
 
23
 
24
  return {"predicted_class": predicted_class, "predictions": predictions.tolist()}
 
12
  self.model.eval()
13
 
14
  def __call__(self, data):
15
+ # ๋””๋ฒ„๊น…: ์ž…๋ ฅ ๋ฐ์ดํ„ฐ ํ™•์ธ
16
+ print("Received data:", data)
17
+
18
  frames = np.array(data['frames'])
19
  frames = torch.tensor(frames).float() # Ensure the data is in the correct format
20
+
21
+ # ๋””๋ฒ„๊น…: ํ”„๋ ˆ์ž„ ๋ฐ์ดํ„ฐ ํ™•์ธ
22
+ print("Frames shape:", frames.shape)
23
 
24
  # Perform inference
25
  with torch.no_grad():
26
  outputs = self.model(frames.unsqueeze(0)) # Add batch dimension
27
  predictions = torch.softmax(outputs.logits, dim=-1)
28
+
29
+ # ๋””๋ฒ„๊น…: ์˜ˆ์ธก ๊ฒฐ๊ณผ ํ™•์ธ
30
+ print("Predictions:", predictions)
31
+
32
  predicted_class = torch.argmax(predictions, dim=-1).item()
33
+
34
+ # ๋””๋ฒ„๊น…: ์˜ˆ์ธก ํด๋ž˜์Šค ํ™•์ธ
35
+ print("Predicted class:", predicted_class)
36
 
37
  return {"predicted_class": predicted_class, "predictions": predictions.tolist()}