fix: remove hardcoded path in facenet_embedding.swift (A-4.2)
Problem: - L24 had hardcoded model path as default_value - Would cause D-4 failure (strings shows dev path) Solution: - Remove default_value - Add runtime resolution: 1. CLI --model argument 2. MOMENTRY_MODELS_DIR env var 3. Sibling of binary (models/facenet512.mlpackage) Impact: - Swift CLI now portable - No dev path strings in binary - D-4 Gate condition satisfied Verification: grep shows 0 hardcoded paths
This commit is contained in:
@@ -21,14 +21,27 @@ struct FaceNetEmbedding: ParsableCommand {
|
||||
var uuid: String = ""
|
||||
|
||||
@Option(name: .long, help: "FaceNet model path (mlpackage directory)")
|
||||
var model: String = "/Users/accusys/momentry_core/models/facenet512.mlpackage"
|
||||
var model: String = ""
|
||||
|
||||
mutating func run() throws {
|
||||
let startTime = Date()
|
||||
print("[FaceNet] Loading FaceNet CoreML model...")
|
||||
|
||||
// Resolve model path: CLI arg > env var > sibling of binary
|
||||
let modelPath: String
|
||||
if !model.isEmpty {
|
||||
modelPath = model
|
||||
} else if let envPath = ProcessInfo.processInfo.environment["MOMENTRY_MODELS_DIR"] {
|
||||
modelPath = envPath + "/facenet512.mlpackage"
|
||||
} else {
|
||||
// Fallback: sibling of current binary
|
||||
let exePath = CommandLine.arguments[0]
|
||||
let exeDir = URL(fileURLWithPath: exePath).deletingLastPathComponent()
|
||||
modelPath = exeDir.appendingPathComponent("models/facenet512.mlpackage").path
|
||||
}
|
||||
|
||||
// Load FaceNet CoreML model
|
||||
let modelPackageURL = URL(fileURLWithPath: model)
|
||||
let modelPackageURL = URL(fileURLWithPath: modelPath)
|
||||
let modelURL = modelPackageURL.appendingPathComponent("Data/com.apple.CoreML/model.mlmodel")
|
||||
|
||||
guard FileManager.default.fileExists(atPath: modelURL.path) else {
|
||||
|
||||
Reference in New Issue
Block a user