xinference 1.5.1__py3-none-any.whl → 1.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xinference might be problematic. Click here for more details.

Files changed (96) hide show
  1. xinference/_version.py +3 -3
  2. xinference/api/restful_api.py +97 -8
  3. xinference/client/restful/restful_client.py +51 -11
  4. xinference/core/media_interface.py +758 -0
  5. xinference/core/model.py +49 -9
  6. xinference/core/worker.py +31 -37
  7. xinference/deploy/utils.py +0 -3
  8. xinference/model/audio/__init__.py +16 -27
  9. xinference/model/audio/core.py +1 -0
  10. xinference/model/audio/cosyvoice.py +4 -2
  11. xinference/model/audio/model_spec.json +20 -3
  12. xinference/model/audio/model_spec_modelscope.json +18 -1
  13. xinference/model/embedding/__init__.py +16 -24
  14. xinference/model/image/__init__.py +15 -25
  15. xinference/model/llm/__init__.py +37 -110
  16. xinference/model/llm/core.py +15 -6
  17. xinference/model/llm/llama_cpp/core.py +25 -353
  18. xinference/model/llm/llm_family.json +613 -89
  19. xinference/model/llm/llm_family.py +9 -1
  20. xinference/model/llm/llm_family_modelscope.json +540 -90
  21. xinference/model/llm/mlx/core.py +6 -3
  22. xinference/model/llm/reasoning_parser.py +281 -5
  23. xinference/model/llm/sglang/core.py +16 -3
  24. xinference/model/llm/transformers/chatglm.py +2 -2
  25. xinference/model/llm/transformers/cogagent.py +1 -1
  26. xinference/model/llm/transformers/cogvlm2.py +1 -1
  27. xinference/model/llm/transformers/core.py +9 -3
  28. xinference/model/llm/transformers/glm4v.py +1 -1
  29. xinference/model/llm/transformers/minicpmv26.py +1 -1
  30. xinference/model/llm/transformers/qwen-omni.py +6 -0
  31. xinference/model/llm/transformers/qwen_vl.py +1 -1
  32. xinference/model/llm/utils.py +68 -45
  33. xinference/model/llm/vllm/core.py +38 -18
  34. xinference/model/llm/vllm/xavier/test/test_xavier.py +1 -10
  35. xinference/model/rerank/__init__.py +13 -24
  36. xinference/model/video/__init__.py +15 -25
  37. xinference/model/video/core.py +3 -3
  38. xinference/model/video/diffusers.py +133 -16
  39. xinference/model/video/model_spec.json +54 -0
  40. xinference/model/video/model_spec_modelscope.json +56 -0
  41. xinference/thirdparty/cosyvoice/bin/average_model.py +5 -4
  42. xinference/thirdparty/cosyvoice/bin/export_jit.py +50 -20
  43. xinference/thirdparty/cosyvoice/bin/export_onnx.py +136 -51
  44. xinference/thirdparty/cosyvoice/bin/inference.py +15 -5
  45. xinference/thirdparty/cosyvoice/bin/train.py +7 -2
  46. xinference/thirdparty/cosyvoice/cli/cosyvoice.py +72 -52
  47. xinference/thirdparty/cosyvoice/cli/frontend.py +58 -58
  48. xinference/thirdparty/cosyvoice/cli/model.py +140 -155
  49. xinference/thirdparty/cosyvoice/dataset/processor.py +9 -5
  50. xinference/thirdparty/cosyvoice/flow/decoder.py +656 -54
  51. xinference/thirdparty/cosyvoice/flow/flow.py +69 -11
  52. xinference/thirdparty/cosyvoice/flow/flow_matching.py +167 -63
  53. xinference/thirdparty/cosyvoice/flow/length_regulator.py +1 -0
  54. xinference/thirdparty/cosyvoice/hifigan/discriminator.py +91 -1
  55. xinference/thirdparty/cosyvoice/hifigan/f0_predictor.py +4 -1
  56. xinference/thirdparty/cosyvoice/hifigan/generator.py +4 -1
  57. xinference/thirdparty/cosyvoice/hifigan/hifigan.py +2 -2
  58. xinference/thirdparty/cosyvoice/llm/llm.py +198 -18
  59. xinference/thirdparty/cosyvoice/transformer/embedding.py +12 -4
  60. xinference/thirdparty/cosyvoice/transformer/upsample_encoder.py +124 -21
  61. xinference/thirdparty/cosyvoice/utils/class_utils.py +13 -0
  62. xinference/thirdparty/cosyvoice/utils/common.py +1 -1
  63. xinference/thirdparty/cosyvoice/utils/file_utils.py +40 -2
  64. xinference/thirdparty/cosyvoice/utils/frontend_utils.py +7 -0
  65. xinference/thirdparty/cosyvoice/utils/mask.py +4 -0
  66. xinference/thirdparty/cosyvoice/utils/train_utils.py +5 -1
  67. xinference/thirdparty/matcha/hifigan/xutils.py +3 -3
  68. xinference/types.py +0 -71
  69. xinference/web/ui/build/asset-manifest.json +3 -3
  70. xinference/web/ui/build/index.html +1 -1
  71. xinference/web/ui/build/static/js/main.ae579a97.js +3 -0
  72. xinference/web/ui/build/static/js/main.ae579a97.js.map +1 -0
  73. xinference/web/ui/node_modules/.cache/babel-loader/0196a4b09e3264614e54360d5f832c46b31d964ec58296765ebff191ace6adbf.json +1 -0
  74. xinference/web/ui/node_modules/.cache/babel-loader/12e02ee790dbf57ead09a241a93bb5f893393aa36628ca741d44390e836a103f.json +1 -0
  75. xinference/web/ui/node_modules/.cache/babel-loader/18fa271456b31cded36c05c4c71c6b2b1cf4e4128c1e32f0e45d8b9f21764397.json +1 -0
  76. xinference/web/ui/node_modules/.cache/babel-loader/2fdc61dcb6a9d1fbcb44be592d0e87d8c3f21297a7327559ef5345665f8343f7.json +1 -0
  77. xinference/web/ui/node_modules/.cache/babel-loader/3d596a3e8dd6430d7ce81d164e32c31f8d47cfa5f725c328a298754d78563e14.json +1 -0
  78. xinference/web/ui/node_modules/.cache/babel-loader/8472e58a31720892d534f3febda31f746b25ec4aa60787eef34217b074e67965.json +1 -0
  79. xinference/web/ui/src/locales/en.json +6 -4
  80. xinference/web/ui/src/locales/zh.json +6 -4
  81. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/METADATA +56 -36
  82. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/RECORD +87 -87
  83. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/WHEEL +1 -1
  84. xinference/core/image_interface.py +0 -377
  85. xinference/thirdparty/cosyvoice/bin/export_trt.sh +0 -9
  86. xinference/web/ui/build/static/js/main.91e77b5c.js +0 -3
  87. xinference/web/ui/build/static/js/main.91e77b5c.js.map +0 -1
  88. xinference/web/ui/node_modules/.cache/babel-loader/0f0adb2283a8f469d097a7a0ebb754624fa52414c83b83696c41f2e6a737ceda.json +0 -1
  89. xinference/web/ui/node_modules/.cache/babel-loader/5e6edb0fb87e3798f142e9abf8dd2dc46bab33a60d31dff525797c0c99887097.json +0 -1
  90. xinference/web/ui/node_modules/.cache/babel-loader/6087820be1bd5c02c42dff797e7df365448ef35ab26dd5d6bd33e967e05cbfd4.json +0 -1
  91. xinference/web/ui/node_modules/.cache/babel-loader/8157db83995c671eb57abc316c337f867d1dc63fb83520bb4ff351fee57dcce2.json +0 -1
  92. xinference/web/ui/node_modules/.cache/babel-loader/f04f666b77b44d7be3e16034d6b0074de2ba9c254f1fae15222b3148608fa8b3.json +0 -1
  93. /xinference/web/ui/build/static/js/{main.91e77b5c.js.LICENSE.txt → main.ae579a97.js.LICENSE.txt} +0 -0
  94. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/entry_points.txt +0 -0
  95. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/licenses/LICENSE +0 -0
  96. {xinference-1.5.1.dist-info → xinference-1.6.0.dist-info}/top_level.txt +0 -0
xinference/core/model.py CHANGED
@@ -632,6 +632,8 @@ class ModelActor(xo.StatelessActor, CancelMixin):
632
632
  return await _gen.__anext__() # noqa: F821
633
633
  except StopAsyncIteration:
634
634
  return stop
635
+ except Exception as e:
636
+ return e
635
637
 
636
638
  def _wrapper(_gen):
637
639
  # Avoid issue: https://github.com/python/cpython/issues/112182
@@ -639,6 +641,8 @@ class ModelActor(xo.StatelessActor, CancelMixin):
639
641
  return next(_gen)
640
642
  except StopIteration:
641
643
  return stop
644
+ except Exception as e:
645
+ return e
642
646
 
643
647
  while True:
644
648
  try:
@@ -699,6 +703,8 @@ class ModelActor(xo.StatelessActor, CancelMixin):
699
703
  o = stream_out.get()
700
704
  if o is stop:
701
705
  break
706
+ elif isinstance(o, Exception):
707
+ raise o
702
708
  else:
703
709
  yield o
704
710
 
@@ -715,6 +721,8 @@ class ModelActor(xo.StatelessActor, CancelMixin):
715
721
  o = await stream_out.get()
716
722
  if o is stop:
717
723
  break
724
+ elif isinstance(o, Exception):
725
+ raise o
718
726
  else:
719
727
  yield o
720
728
 
@@ -1229,19 +1237,51 @@ class ModelActor(xo.StatelessActor, CancelMixin):
1229
1237
  *args,
1230
1238
  **kwargs,
1231
1239
  ):
1232
- kwargs.pop("request_id", None)
1233
- if hasattr(self._model, "text_to_video"):
1234
- return await self._call_wrapper_json(
1235
- self._model.text_to_video,
1236
- prompt,
1237
- n,
1238
- *args,
1239
- **kwargs,
1240
- )
1240
+ progressor = kwargs["progressor"] = await self._get_progressor(
1241
+ kwargs.pop("request_id", None)
1242
+ )
1243
+ with progressor:
1244
+ if hasattr(self._model, "text_to_video"):
1245
+ return await self._call_wrapper_json(
1246
+ self._model.text_to_video,
1247
+ prompt,
1248
+ n,
1249
+ *args,
1250
+ **kwargs,
1251
+ )
1241
1252
  raise AttributeError(
1242
1253
  f"Model {self._model.model_spec} is not for creating video."
1243
1254
  )
1244
1255
 
1256
+ @request_limit
1257
+ @log_async(logger=logger)
1258
+ async def image_to_video(
1259
+ self,
1260
+ image: "PIL.Image",
1261
+ prompt: str,
1262
+ negative_prompt: Optional[str] = None,
1263
+ n: int = 1,
1264
+ *args,
1265
+ **kwargs,
1266
+ ):
1267
+ kwargs["negative_prompt"] = negative_prompt
1268
+ progressor = kwargs["progressor"] = await self._get_progressor(
1269
+ kwargs.pop("request_id", None)
1270
+ )
1271
+ with progressor:
1272
+ if hasattr(self._model, "image_to_video"):
1273
+ return await self._call_wrapper_json(
1274
+ self._model.image_to_video,
1275
+ image,
1276
+ prompt,
1277
+ n,
1278
+ *args,
1279
+ **kwargs,
1280
+ )
1281
+ raise AttributeError(
1282
+ f"Model {self._model.model_spec} is not for creating video from image."
1283
+ )
1284
+
1245
1285
  async def record_metrics(self, name, op, kwargs):
1246
1286
  worker_ref = await self._get_worker_ref()
1247
1287
  await worker_ref.record_metrics(name, op, kwargs)
xinference/core/worker.py CHANGED
@@ -148,7 +148,7 @@ class WorkerActor(xo.StatelessActor):
148
148
  elif metrics_exporter_host is not None or metrics_exporter_port is not None:
149
149
  # metrics export server.
150
150
  logger.info(
151
- f"Starting metrics export server at {metrics_exporter_host}:{metrics_exporter_port}"
151
+ f"Starting metrics export server at {metrics_exporter_host}:{metrics_exporter_port}" # noqa: E231
152
152
  )
153
153
  q: queue.Queue = queue.Queue()
154
154
  self._metrics_thread = threading.Thread(
@@ -162,7 +162,9 @@ class WorkerActor(xo.StatelessActor):
162
162
  while self._metrics_thread.is_alive():
163
163
  try:
164
164
  host, port = q.get(block=False)[:2]
165
- logger.info(f"Metrics server is started at: http://{host}:{port}")
165
+ logger.info(
166
+ f"Metrics server is started at: http://{host}:{port}" # noqa: E231
167
+ )
166
168
  break
167
169
  except queue.Empty:
168
170
  pass
@@ -584,6 +586,7 @@ class WorkerActor(xo.StatelessActor):
584
586
  n_gpu: Optional[Union[int, str]] = "auto",
585
587
  gpu_idx: Optional[List[int]] = None,
586
588
  env: Optional[Dict[str, str]] = None,
589
+ start_python: Optional[str] = None,
587
590
  ) -> Tuple[str, List[str]]:
588
591
  env = {} if env is None else env
589
592
  devices = []
@@ -609,14 +612,8 @@ class WorkerActor(xo.StatelessActor):
609
612
  )
610
613
  env[env_name] = ",".join([str(dev) for dev in devices])
611
614
 
612
- if os.name != "nt" and platform.system() != "Darwin":
613
- # Linux
614
- start_method = "forkserver"
615
- else:
616
- # Windows and macOS
617
- start_method = "spawn"
618
615
  subpool_address = await self._main_pool.append_sub_pool(
619
- env=env, start_method=start_method
616
+ env=env, start_python=start_python
620
617
  )
621
618
  return subpool_address, [str(dev) for dev in devices]
622
619
 
@@ -833,6 +830,8 @@ class WorkerActor(xo.StatelessActor):
833
830
  virtual_env_manager: VirtualEnvManager = get_virtual_env_manager(
834
831
  virtual_env_name or "uv", env_path
835
832
  )
833
+ # create env
834
+ virtual_env_manager.create_env()
836
835
  return virtual_env_manager
837
836
 
838
837
  @classmethod
@@ -845,9 +844,6 @@ class WorkerActor(xo.StatelessActor):
845
844
  # no settings or no packages
846
845
  return
847
846
 
848
- # create env
849
- virtual_env_manager.create_env()
850
-
851
847
  if settings.inherit_pip_config:
852
848
  # inherit pip config
853
849
  pip_config = get_pip_config_args()
@@ -1001,22 +997,26 @@ class WorkerActor(xo.StatelessActor):
1001
997
  # virtualenv
1002
998
  enable_virtual_env = kwargs.pop("enable_virtual_env", None)
1003
999
  virtual_env_name = kwargs.pop("virtual_env_name", None)
1004
- virtual_env_path = os.path.join(XINFERENCE_VIRTUAL_ENV_DIR, model_name)
1000
+ virtual_env_path = os.path.join(
1001
+ XINFERENCE_VIRTUAL_ENV_DIR, "v2", model_name
1002
+ )
1005
1003
  virtual_env_manager = await asyncio.to_thread(
1006
1004
  self._create_virtual_env_manager,
1007
1005
  enable_virtual_env,
1008
1006
  virtual_env_name,
1009
1007
  virtual_env_path,
1010
1008
  )
1011
- # setting os.environ if virtualenv created
1012
- env = (
1013
- {"PYTHONPATH": virtual_env_manager.get_lib_path()}
1014
- if virtual_env_manager
1015
- else None
1009
+ subpool_python_path = (
1010
+ None
1011
+ if virtual_env_manager is None
1012
+ else virtual_env_manager.get_python_path()
1016
1013
  )
1017
-
1018
1014
  subpool_address, devices = await self._create_subpool(
1019
- model_uid, model_type, n_gpu=n_gpu, gpu_idx=gpu_idx, env=env
1015
+ model_uid,
1016
+ model_type,
1017
+ n_gpu=n_gpu,
1018
+ gpu_idx=gpu_idx,
1019
+ start_python=subpool_python_path,
1020
1020
  )
1021
1021
  all_subpool_addresses = [subpool_address]
1022
1022
  try:
@@ -1116,7 +1116,7 @@ class WorkerActor(xo.StatelessActor):
1116
1116
  coros.append(
1117
1117
  self._main_pool.append_sub_pool(
1118
1118
  env={env_name: env_value},
1119
- start_method=self._get_start_method(),
1119
+ start_python=subpool_python_path,
1120
1120
  )
1121
1121
  )
1122
1122
  pool_addresses = await asyncio.gather(*coros)
@@ -1255,7 +1255,14 @@ class WorkerActor(xo.StatelessActor):
1255
1255
  try:
1256
1256
  logger.debug("Start to destroy model actor: %s", model_ref)
1257
1257
  coro = xo.destroy_actor(model_ref)
1258
- await asyncio.wait_for(coro, timeout=5)
1258
+ # see https://github.com/xorbitsai/xoscar/pull/140
1259
+ # asyncio.wait_for cannot work for Xoscar actor call,
1260
+ # because when time out, the coroutine will be cancelled via raise CancelledEror,
1261
+ # inside actor call, the error will be caught and
1262
+ # a CancelMessage will be sent to dest actor pool,
1263
+ # however the actor pool may be stuck already,
1264
+ # thus the timeout will never be raised
1265
+ await xo.wait_for(coro, timeout=5)
1259
1266
  except Exception as e:
1260
1267
  logger.debug(
1261
1268
  "Destroy model actor failed, model uid: %s, error: %s", model_uid, e
@@ -1434,7 +1441,7 @@ class WorkerActor(xo.StatelessActor):
1434
1441
  else:
1435
1442
  logger.debug(f"{path} is not a valid path.")
1436
1443
  except Exception as e:
1437
- logger.error(f"Fail to delete {path} with error:{e}.")
1444
+ logger.error(f"Fail to delete {path} with error:{e}.") # noqa: E231
1438
1445
  return False
1439
1446
  await self._cache_tracker_ref.confirm_and_remove_model(
1440
1447
  model_version, self.address
@@ -1467,26 +1474,13 @@ class WorkerActor(xo.StatelessActor):
1467
1474
  model_ref = self._model_uid_to_model[rep_model_uid]
1468
1475
  await model_ref.start_transfer_for_vllm(rank_addresses)
1469
1476
 
1470
- @staticmethod
1471
- def _get_start_method():
1472
- if os.name != "nt" and platform.system() != "Darwin":
1473
- # Linux
1474
- start_method = "forkserver"
1475
- else:
1476
- # Windows and macOS
1477
- start_method = "spawn"
1478
- return start_method
1479
-
1480
1477
  @log_async(logger=logger, level=logging.INFO)
1481
1478
  async def launch_rank0_model(
1482
1479
  self, rep_model_uid: str, xavier_config: Dict[str, Any]
1483
1480
  ) -> Tuple[str, int]:
1484
1481
  from ..model.llm.vllm.xavier.collective_manager import Rank0ModelActor
1485
1482
 
1486
- start_method = self._get_start_method()
1487
- subpool_address = await self._main_pool.append_sub_pool(
1488
- start_method=start_method
1489
- )
1483
+ subpool_address = await self._main_pool.append_sub_pool()
1490
1484
 
1491
1485
  store_address = subpool_address.split(":")[0]
1492
1486
  # Note that `store_port` needs to be generated on the worker,
@@ -141,13 +141,10 @@ def get_config_dict(
141
141
  async def create_worker_actor_pool(
142
142
  address: str, logging_conf: Optional[dict] = None
143
143
  ) -> "MainActorPoolType":
144
- subprocess_start_method = "forkserver" if os.name != "nt" else "spawn"
145
-
146
144
  return await xo.create_actor_pool(
147
145
  address=address,
148
146
  n_process=0,
149
147
  auto_recover="process",
150
- subprocess_start_method=subprocess_start_method,
151
148
  logging_conf={"dict": logging_conf},
152
149
  )
153
150
 
@@ -66,31 +66,8 @@ def _need_filter(spec: dict):
66
66
 
67
67
 
68
68
  def _install():
69
- _model_spec_json = os.path.join(os.path.dirname(__file__), "model_spec.json")
70
- _model_spec_modelscope_json = os.path.join(
71
- os.path.dirname(__file__), "model_spec_modelscope.json"
72
- )
73
- BUILTIN_AUDIO_MODELS.update(
74
- dict(
75
- (spec["model_name"], AudioModelFamilyV1(**spec))
76
- for spec in json.load(codecs.open(_model_spec_json, "r", encoding="utf-8"))
77
- if not _need_filter(spec)
78
- )
79
- )
80
- for model_name, model_spec in BUILTIN_AUDIO_MODELS.items():
81
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
82
-
83
- MODELSCOPE_AUDIO_MODELS.update(
84
- dict(
85
- (spec["model_name"], AudioModelFamilyV1(**spec))
86
- for spec in json.load(
87
- codecs.open(_model_spec_modelscope_json, "r", encoding="utf-8")
88
- )
89
- if not _need_filter(spec)
90
- )
91
- )
92
- for model_name, model_spec in MODELSCOPE_AUDIO_MODELS.items():
93
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
69
+ load_model_family_from_json("model_spec.json", BUILTIN_AUDIO_MODELS)
70
+ load_model_family_from_json("model_spec_modelscope.json", MODELSCOPE_AUDIO_MODELS)
94
71
 
95
72
  # register model description after recording model revision
96
73
  for model_spec_info in [BUILTIN_AUDIO_MODELS, MODELSCOPE_AUDIO_MODELS]:
@@ -104,5 +81,17 @@ def _install():
104
81
  for ud_audio in get_user_defined_audios():
105
82
  AUDIO_MODEL_DESCRIPTIONS.update(generate_audio_description(ud_audio))
106
83
 
107
- del _model_spec_json
108
- del _model_spec_modelscope_json
84
+
85
+ def load_model_family_from_json(json_filename, target_families):
86
+ json_path = os.path.join(os.path.dirname(__file__), json_filename)
87
+ target_families.update(
88
+ dict(
89
+ (spec["model_name"], AudioModelFamilyV1(**spec))
90
+ for spec in json.load(codecs.open(json_path, "r", encoding="utf-8"))
91
+ if not _need_filter(spec)
92
+ )
93
+ )
94
+ for model_name, model_spec in target_families.items():
95
+ MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
96
+
97
+ del json_path
@@ -82,6 +82,7 @@ class AudioModelDescription(ModelDescription):
82
82
  "model_name": self._model_spec.model_name,
83
83
  "model_family": self._model_spec.model_family,
84
84
  "model_revision": self._model_spec.model_revision,
85
+ "model_ability": self._model_spec.model_ability,
85
86
  }
86
87
 
87
88
  def to_version_info(self):
@@ -55,10 +55,12 @@ class CosyVoiceModel:
55
55
  thirdparty_dir = os.path.join(os.path.dirname(__file__), "../../thirdparty")
56
56
  sys.path.insert(0, thirdparty_dir)
57
57
 
58
+ kwargs = {}
58
59
  if "CosyVoice2" in self._model_spec.model_name:
59
60
  from cosyvoice.cli.cosyvoice import CosyVoice2 as CosyVoice
60
61
 
61
62
  self._is_cosyvoice2 = True
63
+ kwargs = {"use_flow_cache": self._kwargs.get("use_flow_cache", False)}
62
64
  else:
63
65
  from cosyvoice.cli.cosyvoice import CosyVoice
64
66
 
@@ -69,7 +71,7 @@ class CosyVoiceModel:
69
71
  "compile", False
70
72
  )
71
73
  logger.info("Loading CosyVoice model, compile=%s...", load_jit)
72
- self._model = CosyVoice(self._model_path, load_jit=load_jit)
74
+ self._model = CosyVoice(self._model_path, load_jit=load_jit, **kwargs)
73
75
  if self._is_cosyvoice2:
74
76
  spk2info_file = os.path.join(thirdparty_dir, "cosyvoice/bin/spk2info.pt")
75
77
  self._model.frontend.spk2info = torch.load(
@@ -112,7 +114,7 @@ class CosyVoiceModel:
112
114
  input, prompt_speech_16k, stream=stream
113
115
  )
114
116
  else:
115
- available_speakers = self._model.list_avaliable_spks()
117
+ available_speakers = self._model.list_available_spks()
116
118
  if not voice:
117
119
  voice = available_speakers[0]
118
120
  logger.info("Auto select speaker: %s", voice)
@@ -253,10 +253,27 @@
253
253
  {
254
254
  "model_name": "CosyVoice2-0.5B",
255
255
  "model_family": "CosyVoice",
256
- "model_id": "mrfakename/CosyVoice2-0.5B",
257
- "model_revision": "5676baabc8a76dc93ef60a88bbd2420deaa2f644",
256
+ "model_id": "JunHowie/CosyVoice2-0.5B",
257
+ "model_revision": "7ac9e9a026aec35efe48cde1196eaad6a00ad5f2",
258
258
  "model_ability": ["text2audio"],
259
- "multilingual": true
259
+ "multilingual": true,
260
+ "virtualenv": {
261
+ "packages": [
262
+ "tiktoken",
263
+ "lightning>=2.0.0",
264
+ "hydra-core>=1.3.2",
265
+ "inflect",
266
+ "conformer",
267
+ "diffusers==0.29.0",
268
+ "gdown",
269
+ "pyarrow",
270
+ "HyperPyYAML",
271
+ "onnxruntime>=1.16.0",
272
+ "pyworld>=0.3.4",
273
+ "numpy==1.26.4",
274
+ "#system_torch#"
275
+ ]
276
+ }
260
277
  },
261
278
  {
262
279
  "model_name": "FishSpeech-1.5",
@@ -106,7 +106,24 @@
106
106
  "model_id": "iic/CosyVoice2-0.5B",
107
107
  "model_revision": "master",
108
108
  "model_ability": ["text2audio"],
109
- "multilingual": true
109
+ "multilingual": true,
110
+ "virtualenv": {
111
+ "packages": [
112
+ "tiktoken",
113
+ "lightning>=2.0.0",
114
+ "hydra-core>=1.3.2",
115
+ "inflect",
116
+ "conformer",
117
+ "diffusers==0.29.0",
118
+ "gdown",
119
+ "pyarrow",
120
+ "HyperPyYAML",
121
+ "onnxruntime>=1.16.0",
122
+ "pyworld>=0.3.4",
123
+ "numpy==1.26.4",
124
+ "#system_torch#"
125
+ ]
126
+ }
110
127
  },
111
128
  {
112
129
  "model_name": "F5-TTS",
@@ -56,29 +56,10 @@ def register_custom_model():
56
56
 
57
57
 
58
58
  def _install():
59
- _model_spec_json = os.path.join(os.path.dirname(__file__), "model_spec.json")
60
- _model_spec_modelscope_json = os.path.join(
61
- os.path.dirname(__file__), "model_spec_modelscope.json"
59
+ load_model_family_from_json("model_spec.json", BUILTIN_EMBEDDING_MODELS)
60
+ load_model_family_from_json(
61
+ "model_spec_modelscope.json", MODELSCOPE_EMBEDDING_MODELS
62
62
  )
63
- BUILTIN_EMBEDDING_MODELS.update(
64
- dict(
65
- (spec["model_name"], EmbeddingModelSpec(**spec))
66
- for spec in json.load(codecs.open(_model_spec_json, "r", encoding="utf-8"))
67
- )
68
- )
69
- for model_name, model_spec in BUILTIN_EMBEDDING_MODELS.items():
70
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
71
-
72
- MODELSCOPE_EMBEDDING_MODELS.update(
73
- dict(
74
- (spec["model_name"], EmbeddingModelSpec(**spec))
75
- for spec in json.load(
76
- codecs.open(_model_spec_modelscope_json, "r", encoding="utf-8")
77
- )
78
- )
79
- )
80
- for model_name, model_spec in MODELSCOPE_EMBEDDING_MODELS.items():
81
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
82
63
 
83
64
  # register model description after recording model revision
84
65
  for model_spec_info in [BUILTIN_EMBEDDING_MODELS, MODELSCOPE_EMBEDDING_MODELS]:
@@ -96,5 +77,16 @@ def _install():
96
77
  generate_embedding_description(ud_embedding)
97
78
  )
98
79
 
99
- del _model_spec_json
100
- del _model_spec_modelscope_json
80
+
81
+ def load_model_family_from_json(json_filename, target_families):
82
+ json_path = os.path.join(os.path.dirname(__file__), json_filename)
83
+ target_families.update(
84
+ dict(
85
+ (spec["model_name"], EmbeddingModelSpec(**spec))
86
+ for spec in json.load(codecs.open(json_path, "r", encoding="utf-8"))
87
+ )
88
+ )
89
+ for model_name, model_spec in target_families.items():
90
+ MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
91
+
92
+ del json_path
@@ -55,29 +55,8 @@ def register_custom_model():
55
55
 
56
56
 
57
57
  def _install():
58
- _model_spec_json = os.path.join(os.path.dirname(__file__), "model_spec.json")
59
- _model_spec_modelscope_json = os.path.join(
60
- os.path.dirname(__file__), "model_spec_modelscope.json"
61
- )
62
- BUILTIN_IMAGE_MODELS.update(
63
- dict(
64
- (spec["model_name"], ImageModelFamilyV1(**spec))
65
- for spec in json.load(codecs.open(_model_spec_json, "r", encoding="utf-8"))
66
- )
67
- )
68
- for model_name, model_spec in BUILTIN_IMAGE_MODELS.items():
69
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
70
-
71
- MODELSCOPE_IMAGE_MODELS.update(
72
- dict(
73
- (spec["model_name"], ImageModelFamilyV1(**spec))
74
- for spec in json.load(
75
- codecs.open(_model_spec_modelscope_json, "r", encoding="utf-8")
76
- )
77
- )
78
- )
79
- for model_name, model_spec in MODELSCOPE_IMAGE_MODELS.items():
80
- MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
58
+ load_model_family_from_json("model_spec.json", BUILTIN_IMAGE_MODELS)
59
+ load_model_family_from_json("model_spec_modelscope.json", MODELSCOPE_IMAGE_MODELS)
81
60
 
82
61
  # register model description
83
62
  for model_name, model_spec in chain(
@@ -90,5 +69,16 @@ def _install():
90
69
  for ud_image in get_user_defined_images():
91
70
  IMAGE_MODEL_DESCRIPTIONS.update(generate_image_description(ud_image))
92
71
 
93
- del _model_spec_json
94
- del _model_spec_modelscope_json
72
+
73
+ def load_model_family_from_json(json_filename, target_families):
74
+ json_path = os.path.join(os.path.dirname(__file__), json_filename)
75
+ target_families.update(
76
+ dict(
77
+ (spec["model_name"], ImageModelFamilyV1(**spec))
78
+ for spec in json.load(codecs.open(json_path, "r", encoding="utf-8"))
79
+ )
80
+ )
81
+ for model_name, model_spec in target_families.items():
82
+ MODEL_NAME_TO_REVISION[model_name].append(model_spec.model_revision)
83
+
84
+ del json_path