donghuna commited on
Commit
49cd757
ยท
verified ยท
1 Parent(s): 3ba40ec

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +9 -4
handler.py CHANGED
@@ -5,7 +5,8 @@ from preprocessing import read_video
5
  import logging
6
  import json
7
  import traceback
8
- import base64
 
9
 
10
  # ๋กœ๊น… ์„ค์ •
11
  logging.basicConfig(level=logging.INFO)
@@ -20,11 +21,15 @@ class EndpointHandler:
20
  self.model.classifier = torch.nn.Linear(self.model.classifier.in_features, 48) # 48 output classes
21
  self.model.eval()
22
 
23
- def __call__(self, data):
24
  try:
25
- video_base64 = data.get("video_base64")
 
 
 
 
26
 
27
- processed_frames = read_video(video_base64)
28
 
29
  return {"processed_frames": processed_frames}
30
 
 
5
  import logging
6
  import json
7
  import traceback
8
+ import os
9
+ from fastapi import FastAPI, File, UploadFile
10
 
11
  # ๋กœ๊น… ์„ค์ •
12
  logging.basicConfig(level=logging.INFO)
 
21
  self.model.classifier = torch.nn.Linear(self.model.classifier.in_features, 48) # 48 output classes
22
  self.model.eval()
23
 
24
+ def __call__(self, file: UploadFile):
25
  try:
26
+ file_path = os.path.join(self.model_dir, file.filename)
27
+
28
+ # ํŒŒ์ผ์„ ๋””์Šคํฌ์— ์ €์žฅ
29
+ with open(file_path, "wb") as buffer:
30
+ buffer.write(await file.read())
31
 
32
+ processed_frames = read_video(file_path)
33
 
34
  return {"processed_frames": processed_frames}
35