Fix AMD ALPR_OCR and custom model
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "ONNXEngine.h"
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
namespace ANSCENTER {
|
||||
namespace onnxocr {
|
||||
@@ -53,6 +55,25 @@ private:
|
||||
// Expand 4-point box using Clipper offset
|
||||
std::vector<cv::Point2f> UnclipPolygon(const std::array<cv::Point2f, 4>& box, float unclipRatio);
|
||||
|
||||
// AMD/DirectML self-heal helper — see ONNXOCRRecognizer for full
|
||||
// contract. On Run() failure: recreate session on the same EP first
|
||||
// (transient hiccup recovery), CPU fallback as last resort. Resets
|
||||
// _warmedUp so the new session gets re-warmed on next Detect call.
|
||||
void HandleRunFailureAndRecreate(const char* context, const std::exception& e);
|
||||
|
||||
// AMD/DirectML latency-based self-heal (Path B) — see ONNXOCRRecognizer
|
||||
// for the full rationale. Detector is observed to hit the same
|
||||
// slow-degradation pattern as the recognizer after a sibling DML
|
||||
// session takes a fatal: Run() doesn't throw, just gets slow.
|
||||
// 2 s threshold catches degraded individual Run() (healthy is 50–500 ms);
|
||||
// 60 s cooldown prevents thrash on permanently broken driver state.
|
||||
static constexpr double kSlowRecreateThresholdMs = 2000.0;
|
||||
static constexpr int64_t kRecreateCooldownMs = 60000;
|
||||
std::atomic<bool> _slowRecreatePending{false};
|
||||
std::chrono::steady_clock::time_point _lastRecreateAt{};
|
||||
void RecordRunLatency(const char* context, double ms);
|
||||
void ApplyPendingSlowRecreate(const char* context);
|
||||
|
||||
std::mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user