Fix classpath model extraction and accept ONNX models
This commit is contained in:
parent
fb838867d8
commit
8430b1ab0b
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -346,16 +346,29 @@ public class ResourceExtractor {
|
|||
for (Resource resource : resources) {
|
||||
if (resource.isReadable() && !resource.getURL().toString().endsWith("/")) {
|
||||
try {
|
||||
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();
|
||||
String relativePath = path.substring(path.indexOf(resourcePath));
|
||||
Path targetPath = targetDir.resolve(relativePath.substring(resourcePath.length()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue