wookee3 commited on
Commit
e6a6574
·
verified ·
1 Parent(s): 4133b46

Fix ONNX auto-download repo resolution for tokenize_from_file

Browse files
Files changed (2) hide show
  1. config.json +1 -1
  2. modeling_onnx_parameter_store.py +14 -1
config.json CHANGED
@@ -15,6 +15,6 @@
15
  "param_prefix": "weights",
16
  "parameter_spec_file": "onnx_parameter_map.json",
17
  "source_onnx_file": "speech_tokenizer_v3.onnx",
18
- "source_onnx_repo_id": null,
19
  "win_length": 400
20
  }
 
15
  "param_prefix": "weights",
16
  "parameter_spec_file": "onnx_parameter_map.json",
17
  "source_onnx_file": "speech_tokenizer_v3.onnx",
18
+ "source_onnx_repo_id": "FunAudioLLM/Fun-CosyVoice3-0.5B-2512",
19
  "win_length": 400
20
  }
modeling_onnx_parameter_store.py CHANGED
@@ -161,7 +161,9 @@ class OnnxParameterStoreModel(nn.Module):
161
  if cand.is_file():
162
  return str(cand.resolve())
163
 
164
- repo_id = self.config.source_onnx_repo_id or local_repo
 
 
165
  if repo_id and "/" in repo_id:
166
  try:
167
  from huggingface_hub import hf_hub_download
@@ -362,3 +364,14 @@ def _str_to_dtype(name: str):
362
  "bool": torch.bool,
363
  }
364
  return table.get(name, torch.float32)
 
 
 
 
 
 
 
 
 
 
 
 
161
  if cand.is_file():
162
  return str(cand.resolve())
163
 
164
+ repo_id = self.config.source_onnx_repo_id
165
+ if not repo_id and local_repo and _looks_like_repo_id(local_repo):
166
+ repo_id = local_repo
167
  if repo_id and "/" in repo_id:
168
  try:
169
  from huggingface_hub import hf_hub_download
 
364
  "bool": torch.bool,
365
  }
366
  return table.get(name, torch.float32)
367
+
368
+
369
+ def _looks_like_repo_id(candidate: str) -> bool:
370
+ path_like = Path(candidate)
371
+ if path_like.exists():
372
+ return False
373
+ if candidate.startswith("/") or candidate.startswith("."):
374
+ return False
375
+ if "\\" in candidate or ":" in candidate:
376
+ return False
377
+ return "/" in candidate