Aliayub1995
commited on
Commit
•
3e3aa94
1
Parent(s):
a16ec50
Update handler.py
Browse files- handler.py +23 -23
handler.py
CHANGED
@@ -16,28 +16,28 @@ class EndpointHandler:
|
|
16 |
self.model_path = 'DAMO-NLP-SG/VideoLLaMA2-7B'
|
17 |
self.model, self.processor, self.tokenizer = model_init(self.model_path)
|
18 |
|
19 |
-
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
|
|
|
16 |
self.model_path = 'DAMO-NLP-SG/VideoLLaMA2-7B'
|
17 |
self.model, self.processor, self.tokenizer = model_init(self.model_path)
|
18 |
|
19 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
20 |
+
print(f"Received data: {data}") # Debugging: Print received data
|
21 |
+
|
22 |
+
modal = data.get("modal", "video")
|
23 |
+
modal_path = data.get("modal_path", "")
|
24 |
+
instruct = data.get("instruct", "")
|
25 |
+
|
26 |
+
print(f"Modal: {modal}, Modal Path: {modal_path}, Instruct: {instruct}") # Debugging: Print extracted values
|
27 |
+
|
28 |
+
if not modal_path or not instruct:
|
29 |
+
raise ValueError("Both 'modal_path' and 'instruct' must be provided in the input data.")
|
30 |
+
|
31 |
+
# Perform inference
|
32 |
+
output = mm_infer(
|
33 |
+
self.processor[modal](modal_path),
|
34 |
+
instruct,
|
35 |
+
model=self.model,
|
36 |
+
tokenizer=self.tokenizer,
|
37 |
+
do_sample=False,
|
38 |
+
modal=modal
|
39 |
+
)
|
40 |
+
|
41 |
+
return [{"output": output}]
|
42 |
|
43 |
|