support llava video (#426)
This commit is contained in:
@@ -28,8 +28,9 @@ from sglang.lang.ir import (
|
||||
SglVariable,
|
||||
SglVarScopeBegin,
|
||||
SglVarScopeEnd,
|
||||
SglVideo,
|
||||
)
|
||||
from sglang.utils import encode_image_base64, get_exception_traceback
|
||||
from sglang.utils import encode_image_base64, encode_video_base64, get_exception_traceback
|
||||
|
||||
|
||||
def run_internal(state, program, func_args, func_kwargs, sync):
|
||||
@@ -361,6 +362,8 @@ class StreamExecutor:
|
||||
self._execute_role_end(other)
|
||||
elif isinstance(other, SglImage):
|
||||
self._execute_image(other)
|
||||
elif isinstance(other, SglVideo):
|
||||
self._execute_video(other)
|
||||
elif isinstance(other, SglVariable):
|
||||
self._execute_variable(other)
|
||||
elif isinstance(other, SglVarScopeBegin):
|
||||
@@ -397,6 +400,16 @@ class StreamExecutor:
|
||||
self.cur_images.append((path, base64_data))
|
||||
self.text_ += self.chat_template.image_token
|
||||
|
||||
def _execute_video(self, expr: SglVideo):
|
||||
path = expr.path
|
||||
num_frames = expr.num_frames
|
||||
|
||||
base64_data = encode_video_base64(path, num_frames)
|
||||
|
||||
self.images_.append((path, base64_data))
|
||||
self.cur_images.append((path, base64_data))
|
||||
self.text_ += self.chat_template.image_token
|
||||
|
||||
# if global_config.eager_fill_image:
|
||||
# self.backend.fill_image(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user