diff --git a/python_api/ocr_api_server.py b/python_api/ocr_api_server.py index 4ad9d02..884d582 100644 --- a/python_api/ocr_api_server.py +++ b/python_api/ocr_api_server.py @@ -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: diff --git a/src/main/java/com/chinaweal/youfool/reportdetect/common/utils/ResourceExtractor.java b/src/main/java/com/chinaweal/youfool/reportdetect/common/utils/ResourceExtractor.java index c94c9b8..47299d9 100644 --- a/src/main/java/com/chinaweal/youfool/reportdetect/common/utils/ResourceExtractor.java +++ b/src/main/java/com/chinaweal/youfool/reportdetect/common/utils/ResourceExtractor.java @@ -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()); } } } diff --git a/src/main/resources/python-api/ocr_api_server.py b/src/main/resources/python-api/ocr_api_server.py index 3384235..b7dcd21 100644 --- a/src/main/resources/python-api/ocr_api_server.py +++ b/src/main/resources/python-api/ocr_api_server.py @@ -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: