Update handler.py
Browse files- 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
|
|
|
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,
|
24 |
try:
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
processed_frames = read_video(
|
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 |
|