mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 08:37:06 +08:00
fix MultimodalRegistry (#3699)
This commit is contained in:
@@ -137,11 +137,7 @@ class ResourceManagerV1(ResourceManager):
|
|||||||
return num_new_tokens
|
return num_new_tokens
|
||||||
|
|
||||||
inputs = request.multimodal_inputs
|
inputs = request.multimodal_inputs
|
||||||
if (
|
if inputs["patch_idx"] is not None and inputs["patch_map"] is not None:
|
||||||
inputs["image_feature_urls"] is not None
|
|
||||||
or inputs["video_feature_urls"] is not None
|
|
||||||
or inputs["audio_feature_urls"] is not None
|
|
||||||
):
|
|
||||||
pre_end_idx = request.num_computed_tokens
|
pre_end_idx = request.num_computed_tokens
|
||||||
new_end_idx = pre_end_idx + num_new_tokens
|
new_end_idx = pre_end_idx + num_new_tokens
|
||||||
# start
|
# start
|
||||||
|
@@ -14,32 +14,13 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Callable
|
|
||||||
|
|
||||||
|
|
||||||
class MultimodalRegistry:
|
class MultimodalRegistry:
|
||||||
"""
|
"""
|
||||||
A registry for multimodal models
|
A registry for multimodal models
|
||||||
"""
|
"""
|
||||||
|
|
||||||
mm_models: set[str] = {"Ernie4_5_VLMoeForConditionalGeneration"}
|
mm_models: set[str] = {"Ernie4_5_VLMoeForConditionalGeneration", "Ernie5MoeForCausalLM"}
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def register_model(cls, name: str = "") -> Callable:
|
|
||||||
"""
|
|
||||||
Register model with the given name, class name is used if name is not provided.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _register(model):
|
|
||||||
nonlocal name
|
|
||||||
if len(name) == 0:
|
|
||||||
name = model.__name__
|
|
||||||
if name in cls.mm_models:
|
|
||||||
raise ValueError(f"multimodal model {name} is already registered")
|
|
||||||
cls.mm_models.add(name)
|
|
||||||
return model
|
|
||||||
|
|
||||||
return _register
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def contains_model(cls, name: str) -> bool:
|
def contains_model(cls, name: str) -> bool:
|
||||||
|
Reference in New Issue
Block a user