Fix classpath model extraction and accept ONNX models

This commit is contained in:
黄仁欢 2026-03-19 15:43:10 +08:00
parent fb838867d8
commit 8430b1ab0b
3 changed files with 19 additions and 6 deletions

View File

@ -62,7 +62,7 @@ def _find_model_dir(base: Path, *parts: str, contains: str, requires_inference:
it = root.rglob("*") if recursive else root.iterdir()
for p in it:
if p.is_dir() and contains_lower in p.name.lower():
if requires_inference and not (p / "inference.yml").exists():
if requires_inference and not ((p / "inference.yml").exists() or (p / "inference.onnx").exists()):
continue
return p
except Exception:

View File

@ -346,16 +346,29 @@ public class ResourceExtractor {
for (Resource resource : resources) {
if (resource.isReadable() && !resource.getURL().toString().endsWith("/")) {
try {
String path = resource.getURL().getPath();
String relativePath = path.substring(path.indexOf(resourcePath));
Path targetPath = targetDir.resolve(relativePath.substring(resourcePath.length()));
String url = resource.getURL().toString();
String rel = null;
int idx = url.indexOf(resourcePath + "/");
if (idx >= 0) {
rel = url.substring(idx + resourcePath.length());
} else {
String path = resource.getURL().getPath();
int pidx = path.indexOf(resourcePath + "/");
if (pidx >= 0) {
rel = path.substring(pidx + resourcePath.length());
}
}
if (rel == null || rel.isEmpty()) {
rel = "/" + resource.getFilename();
}
Path targetPath = targetDir.resolve(rel.startsWith("/") ? rel.substring(1) : rel);
Files.createDirectories(targetPath.getParent());
Files.copy(resource.getInputStream(), targetPath,
StandardCopyOption.REPLACE_EXISTING);
fileCount++;
} catch (Exception e) {
log.debug("跳过文件: {}", resource.getFilename());
log.debug("??????: {}", resource.getFilename());
}
}
}

View File

@ -61,7 +61,7 @@ def _find_model_dir(base: Path, *parts: str, contains: str, requires_inference:
it = root.rglob("*") if recursive else root.iterdir()
for p in it:
if p.is_dir() and contains_lower in p.name.lower():
if requires_inference and not (p / "inference.yml").exists():
if requires_inference and not ((p / "inference.yml").exists() or (p / "inference.onnx").exists()):
continue
return p
except Exception: