Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions xinference/model/image/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ...types import PeftModelConfig
from ..core import CacheableModelSpec, VirtualEnvSettings
from ..utils import ModelInstanceInfoMixin
from .ocr.deepseek_ocr import DeepSeekOCRModel
from .ocr.got_ocr2 import GotOCR2Model
from .stable_diffusion.core import DiffusionModel
from .stable_diffusion.mlx import MLXDiffusionModel
Expand Down Expand Up @@ -159,21 +160,29 @@ def create_ocr_model_instance(
model_spec: ImageModelFamilyV2,
model_path: Optional[str] = None,
**kwargs,
):
) -> Union[DeepSeekOCRModel, GotOCR2Model]:
from .cache_manager import ImageCacheManager

if not model_path:
cache_manager = ImageCacheManager(model_spec)
model_path = cache_manager.cache()

# Use GOT-OCR2 for all OCR models
model = GotOCR2Model(
model_uid,
model_path,
model_spec=model_spec,
**kwargs,
)
return model
# Choose OCR model based on model_name
if model_spec.model_name == "DeepSeek-OCR":
return DeepSeekOCRModel(
model_uid,
model_path,
model_spec=model_spec,
**kwargs,
)
else:
# Default to GOT-OCR2 for other OCR models
return GotOCR2Model(
model_uid,
model_path,
model_spec=model_spec,
**kwargs,
)


def create_image_model_instance(
Expand All @@ -189,7 +198,7 @@ def create_image_model_instance(
lightning_version: Optional[str] = None,
lightning_model_path: Optional[str] = None,
**kwargs,
) -> Union[DiffusionModel, MLXDiffusionModel, GotOCR2Model]:
) -> Union[DiffusionModel, MLXDiffusionModel, GotOCR2Model, DeepSeekOCRModel]:
from .cache_manager import ImageCacheManager

model_spec = match_diffusion(model_name, download_hub)
Expand Down
5 changes: 5 additions & 0 deletions xinference/model/image/ocr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .deepseek_ocr import DeepSeekOCRModel
from .got_ocr2 import GotOCR2Model

__all__ = ["DeepSeekOCRModel", "GotOCR2Model"]
Loading
Loading