{"record":{"id":"5a25a6767e3f8591","repo":"babalae/better-genshin-impact","slug":"error-5a25a6","errorCode":null,"errorMessage":"自动钓鱼模型分类文件不存在","messagePattern":"自动钓鱼模型分类文件不存在","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Recognition/ONNX/YOLO/Predictor.cs","lineNumber":24,"sourceCode":"\nnamespace BetterGenshinImpact.Core.Recognition.ONNX.YOLO;\n\n[Obsolete]\npublic class Predictor\n{\n    private readonly InferenceSession _session;\n    private readonly string[] labels;\n\n    public Predictor()\n    {\n        var options = new SessionOptions();\n        var modelPath = Global.Absolute(@\"Assets\\Model\\Fish\\bgi_fish.onnx\");\n        if (!File.Exists(modelPath)) throw new FileNotFoundException(\"自动钓鱼模型文件不存在\", modelPath);\n\n        _session = new InferenceSession(modelPath, options);\n\n        var wordJsonPath = Global.Absolute(@\"Assets\\Model\\Fish\\label.json\");\n        if (!File.Exists(wordJsonPath)) throw new FileNotFoundException(\"自动钓鱼模型分类文件不存在\", wordJsonPath);\n\n        var json = File.ReadAllText(wordJsonPath);\n        labels = JsonSerializer.Deserialize<string[]>(json) ?? throw new Exception(\"label.json deserialize failed\");\n    }\n}\n","sourceCodeStart":6,"sourceCodeEnd":30,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Recognition/ONNX/YOLO/Predictor.cs#L6-L30","documentation":"The obsolete Predictor also loads Assets\\Model\\Fish\\label.json to obtain the YOLO class labels. FileNotFoundException is thrown when that label file is missing, so even if the ONNX model is present the labels array cannot be built.","triggerScenarios":"Calling new Predictor() when bgi_fish.onnx exists but Assets\\Model\\Fish\\label.json does not, or the labels file was not deployed alongside the model.","commonSituations":"Labels JSON omitted from the package; filename renamed (e.g. labels.json vs label.json); asset shipped in a different folder; obsolete path still referenced.","solutions":["Migrate off the obsolete Predictor to BgiYoloPredictor/BgiOnnxFactory, which does not read label.json this way.","Restore label.json under Assets\\Model\\Fish\\ with the exact expected name.","Verify the file contains a JSON array of label strings (JsonSerializer.Deserialize<string[]>).","Remove lingering references to the obsolete class."],"exampleFix":"// before\nvar predictor = new Predictor(); // throws: label.json missing\n\n// after\nvar labelPath = Global.Absolute(@\"Assets\\Model\\Fish\\label.json\");\nif (!File.Exists(labelPath)) throw new InvalidOperationException($\"Fish label file missing: {labelPath}\");\nvar predictor = new Predictor();","handlingStrategy":"validation","validationCode":"var labelPath = Global.Absolute(@\"Assets\\Model\\Fish\\label.json\");\nif (!File.Exists(labelPath))\n    throw new InvalidOperationException($\"Fish label.json missing: {labelPath}\");\n#pragma warning disable CS0612\nvar predictor = new Predictor();\n#pragma warning restore CS0612","typeGuard":null,"tryCatchPattern":"try { var p = new Predictor(); }\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"自动钓鱼模型分类文件不存在\"))\n{ Logger.LogError(ex, \"Legacy fish labels missing.\"); throw; }","preventionTips":["Prefer the non-obsolete fishing recognizer path.","Keep label.json next to bgi_fish.onnx with the exact expected name.","Verify the JSON is a flat string array before relying on it."],"tags":["yolo","onnx","fishing","asset-missing","obsolete","labels"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}