MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / ModelWrapper

Class ModelWrapper

modules/base.py:184–216  ·  view source on GitHub ↗

模型封装基类 为了让"调用模型时应该就是一句话",我们将模型封装成简单的接口。 使用示例: model = SAM3Model() result = model.predict(image, prompts) # 一行调用

Source from the content-addressed store, hash-verified

182
183
184class ModelWrapper:
185 """
186 模型封装基类
187
188 为了让"调用模型时应该就是一句话",我们将模型封装成简单的接口。
189
190 使用示例:
191 model = SAM3Model()
192 result = model.predict(image, prompts) # 一行调用
193 """
194
195 def __init__(self):
196 self._model = None
197 self._is_loaded = False
198
199 @abstractmethod
200 def load(self):
201 """加载模型"""
202 pass
203
204 @abstractmethod
205 def predict(self, *args, **kwargs):
206 """模型推理"""
207 pass
208
209 def unload(self):
210 """卸载模型"""
211 self._model = None
212 self._is_loaded = False
213
214 @property
215 def is_loaded(self) -> bool:
216 return self._is_loaded

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected