Enhanced logging, diagnostics, and robustness throughout
Added NLog-based logging and diagnostics to Console and WPF apps, with programmatic configuration and support for debugger output. Refactored apps to use dependency injection and Microsoft.Extensions.Hosting. Improved output layer extraction and fallback logic in detection/recognition, including objectness-class probability multiplication. Added crop saving for diagnostics. Introduced new CLI options for diagnostics. MainViewModel and MainWindow now use DI and log errors. NumberRecognitionEngine supports logging, crop saving, and robust fallback. Added Python diagnostic script. Improved error handling and argument parsing.
This commit is contained in:
parent
769afc08fb
commit
d2206a00cb
14 changed files with 571 additions and 78 deletions
32
scripts/py_diag.py
Normal file
32
scripts/py_diag.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import cv2
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
weights = 'models/detection.weights'
|
||||
cfg = 'models/detection.cfg'
|
||||
img = sys.argv[1]
|
||||
|
||||
net = cv2.dnn.readNet(weights, cfg)
|
||||
blob = cv2.dnn.blobFromImage(cv2.imread(img), 0.00392, (416,416), (0,0,0), True, crop=False)
|
||||
net.setInput(blob)
|
||||
|
||||
layer_names = net.getLayerNames()
|
||||
unconnected = net.getUnconnectedOutLayers()
|
||||
indices = []
|
||||
if isinstance(unconnected, np.ndarray):
|
||||
indices = unconnected.flatten()
|
||||
else:
|
||||
try:
|
||||
indices = [u[0] if hasattr(u, '__iter__') else u for u in unconnected]
|
||||
except Exception:
|
||||
indices = list(unconnected)
|
||||
|
||||
output_layers = [layer_names[int(i) - 1] for i in indices]
|
||||
print('output_layers=', output_layers)
|
||||
|
||||
outs = net.forward(output_layers)
|
||||
print('outs len:', len(outs))
|
||||
for i, om in enumerate(outs):
|
||||
print(i, 'rows', om.shape[0], 'cols', om.shape[1])
|
||||
for r in range(min(3, om.shape[0])):
|
||||
print(' row', r, om[r,:10])
|
||||
Loading…
Add table
Add a link
Reference in a new issue