babalae/better-genshin-impact · error · FileNotFoundException
自动钓鱼模型分类文件不存在
Error message
自动钓鱼模型分类文件不存在
What it means
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.
Source
Thrown at BetterGenshinImpact/Core/Recognition/ONNX/YOLO/Predictor.cs:24
namespace BetterGenshinImpact.Core.Recognition.ONNX.YOLO;
[Obsolete]
public class Predictor
{
private readonly InferenceSession _session;
private readonly string[] labels;
public Predictor()
{
var options = new SessionOptions();
var modelPath = Global.Absolute(@"Assets\Model\Fish\bgi_fish.onnx");
if (!File.Exists(modelPath)) throw new FileNotFoundException("自动钓鱼模型文件不存在", modelPath);
_session = new InferenceSession(modelPath, options);
var wordJsonPath = Global.Absolute(@"Assets\Model\Fish\label.json");
if (!File.Exists(wordJsonPath)) throw new FileNotFoundException("自动钓鱼模型分类文件不存在", wordJsonPath);
var json = File.ReadAllText(wordJsonPath);
labels = JsonSerializer.Deserialize<string[]>(json) ?? throw new Exception("label.json deserialize failed");
}
}
View on GitHub (pinned to a7cb36712d)
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.
Example fix
// before
var predictor = new Predictor(); // throws: label.json missing
// after
var labelPath = Global.Absolute(@"Assets\Model\Fish\label.json");
if (!File.Exists(labelPath)) throw new InvalidOperationException($"Fish label file missing: {labelPath}");
var predictor = new Predictor(); Defensive patterns
Strategy: validation
Validate before calling
var labelPath = Global.Absolute(@"Assets\Model\Fish\label.json");
if (!File.Exists(labelPath))
throw new InvalidOperationException($"Fish label.json missing: {labelPath}");
#pragma warning disable CS0612
var predictor = new Predictor();
#pragma warning restore CS0612 Try / catch
try { var p = new Predictor(); }
catch (FileNotFoundException ex) when (ex.Message.Contains("自动钓鱼模型分类文件不存在"))
{ Logger.LogError(ex, "Legacy fish labels missing."); throw; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 自动钓鱼模型文件不存在
- PaddleOCR config file {modelConfigFileName} not found: {conf
- Yap字典文件不存在
- Unable to GetLabelByIndex: index {i} out of range {labels.Co
- 无效的推理设备
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/5a25a6767e3f8591.
Report an issue: GitHub.