Skip to content

Commit 48ecfc8

Browse files
ENH: update model "DeepSeek-OCR" JSON (#4444)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 0205b6e commit 48ecfc8

File tree

2 files changed

+65
-25
lines changed

2 files changed

+65
-25
lines changed

doc/source/gen_docs.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ def _can_use_transformers_legacy(model, model_spec):
241241
abilities = set(model.get("model_ability", []))
242242
return "chat" in abilities or "generate" in abilities
243243

244+
def _extract_primary_model_src(model):
245+
if model.get("model_specs"):
246+
for spec in model["model_specs"]:
247+
if isinstance(spec, dict) and "model_src" in spec:
248+
return spec["model_src"]
249+
return model.get("model_src")
250+
244251
def main():
245252
template_dir = '../templates'
246253
env = Environment(loader=FileSystemLoader(template_dir))
@@ -456,9 +463,10 @@ def main():
456463

457464
for model in sorted_models:
458465
# Process model_src for template compatibility
459-
if 'model_src' in model:
460-
if 'huggingface' in model['model_src']:
461-
hf_src = model['model_src']['huggingface']
466+
model_src = _extract_primary_model_src(model)
467+
if model_src:
468+
if 'huggingface' in model_src:
469+
hf_src = model_src['huggingface']
462470
model['model_id'] = hf_src['model_id']
463471
# Handle GGUF related fields
464472
if 'gguf_model_id' in hf_src:
@@ -470,8 +478,8 @@ def main():
470478
model['lightning_model_id'] = hf_src['lightning_model_id']
471479
if 'lightning_versions' in hf_src:
472480
model['lightning_versions'] = ", ".join(hf_src['lightning_versions'])
473-
elif 'modelscope' in model['model_src']:
474-
model['model_id'] = model['model_src']['modelscope']['model_id']
481+
elif 'modelscope' in model_src:
482+
model['model_id'] = model_src['modelscope']['model_id']
475483

476484
available_controlnet = [cn["model_name"] for cn in model.get("controlnet", [])]
477485
if not available_controlnet:
@@ -502,11 +510,12 @@ def main():
502510

503511
for model in sorted_models:
504512
# Process model_src for template compatibility
505-
if 'model_src' in model:
506-
if 'huggingface' in model['model_src']:
507-
model['model_id'] = model['model_src']['huggingface']['model_id']
508-
elif 'modelscope' in model['model_src']:
509-
model['model_id'] = model['model_src']['modelscope']['model_id']
513+
model_src = _extract_primary_model_src(model)
514+
if model_src:
515+
if 'huggingface' in model_src:
516+
model['model_id'] = model_src['huggingface']['model_id']
517+
elif 'modelscope' in model_src:
518+
model['model_id'] = model_src['modelscope']['model_id']
510519

511520
rendered = env.get_template('audio.rst.jinja').render(model)
512521
output_file_path = os.path.join(output_dir, f"{model['model_name'].lower()}.rst")
@@ -527,11 +536,12 @@ def main():
527536

528537
for model in sorted_models:
529538
# Process model_src for template compatibility
530-
if 'model_src' in model:
531-
if 'huggingface' in model['model_src']:
532-
model['model_id'] = model['model_src']['huggingface']['model_id']
533-
elif 'modelscope' in model['model_src']:
534-
model['model_id'] = model['model_src']['modelscope']['model_id']
539+
model_src = _extract_primary_model_src(model)
540+
if model_src:
541+
if 'huggingface' in model_src:
542+
model['model_id'] = model_src['huggingface']['model_id']
543+
elif 'modelscope' in model_src:
544+
model['model_id'] = model_src['modelscope']['model_id']
535545

536546
model["model_ability"] = ', '.join(model.get("model_ability"))
537547
rendered = env.get_template('video.rst.jinja').render(model)

xinference/model/image/model_spec.json

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -998,18 +998,48 @@
998998
"#system_numpy#"
999999
]
10001000
},
1001-
"model_src": {
1002-
"huggingface": {
1003-
"model_id": "deepseek-ai/DeepSeek-OCR",
1004-
"model_revision": "main"
1001+
"model_specs": [
1002+
{
1003+
"model_format": "pytorch",
1004+
"model_src": {
1005+
"huggingface": {
1006+
"model_id": "deepseek-ai/DeepSeek-OCR",
1007+
"model_revision": "main"
1008+
},
1009+
"modelscope": {
1010+
"model_id": "deepseek-ai/DeepSeek-OCR",
1011+
"model_revision": "master"
1012+
}
1013+
}
10051014
},
1006-
"modelscope": {
1007-
"model_id": "deepseek-ai/DeepSeek-OCR",
1008-
"model_revision": "master"
1015+
{
1016+
"model_format": "mlx",
1017+
"model_src": {
1018+
"huggingface": {
1019+
"model_id": "mlx-community/DeepSeek-OCR-{quantization}",
1020+
"model_revision": "main",
1021+
"quantizations": [
1022+
"8bit",
1023+
"6bit",
1024+
"5bit",
1025+
"4bit"
1026+
]
1027+
},
1028+
"modelscope": {
1029+
"model_id": "mlx-community/DeepSeek-OCR-{quantization}",
1030+
"model_revision": "master",
1031+
"quantizations": [
1032+
"8bit",
1033+
"6bit",
1034+
"5bit",
1035+
"4bit"
1036+
]
1037+
}
1038+
}
10091039
}
1010-
},
1011-
"updated_at": 1766387624,
1012-
"featured": false
1040+
],
1041+
"featured": false,
1042+
"updated_at": 1767691154
10131043
},
10141044
{
10151045
"version": 2,

0 commit comments

Comments
 (0)