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()
|
it = root.rglob("*") if recursive else root.iterdir()
|
||||||
for p in it:
|
for p in it:
|
||||||
if p.is_dir() and contains_lower in p.name.lower():
|
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
|
continue
|
||||||
return p
|
return p
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -346,16 +346,29 @@ public class ResourceExtractor {
|
||||||
for (Resource resource : resources) {
|
for (Resource resource : resources) {
|
||||||
if (resource.isReadable() && !resource.getURL().toString().endsWith("/")) {
|
if (resource.isReadable() && !resource.getURL().toString().endsWith("/")) {
|
||||||
try {
|
try {
|
||||||
String path = resource.getURL().getPath();
|
String url = resource.getURL().toString();
|
||||||
String relativePath = path.substring(path.indexOf(resourcePath));
|
String rel = null;
|
||||||
Path targetPath = targetDir.resolve(relativePath.substring(resourcePath.length()));
|
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.createDirectories(targetPath.getParent());
|
||||||
Files.copy(resource.getInputStream(), targetPath,
|
Files.copy(resource.getInputStream(), targetPath,
|
||||||
StandardCopyOption.REPLACE_EXISTING);
|
StandardCopyOption.REPLACE_EXISTING);
|
||||||
fileCount++;
|
fileCount++;
|
||||||
} catch (Exception e) {
|
} 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()
|
it = root.rglob("*") if recursive else root.iterdir()
|
||||||
for p in it:
|
for p in it:
|
||||||
if p.is_dir() and contains_lower in p.name.lower():
|
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
|
continue
|
||||||
return p
|
return p
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue