PaddlePaddle/PaddleOCR · critical

PaddleOCRCore requires pre-resolved detection and recognitio

Error message

PaddleOCRCore requires pre-resolved detection and recognition asset descriptors.

What it means

Thrown by getResolvedAssets() in OcrPipelineCore: the assets record must contain usable det and rec ModelAsset objects before core construction. The core does not resolve or download models itself — it expects the caller (usually the config normalization + loader layer) to have already resolved asset descriptors for both models. Missing either one aborts construction immediately.

Source

Thrown at paddleocr-js/packages/core/src/pipelines/ocr/core.ts:86

export interface OcrPipelineRunnerOptions {
  pipelineConfig: NormalizedPipelineConfig;
  ortOptions?: OrtOptions | NormalizedOrtOptions;
  fetch?: typeof fetch;
  ensureServedFromHttp?: EnsureServedFromHttpFn;
  sourceToMat?: SourceToMatFn;
}

function noopEnsureServedFromHttp(): void {}

function getResolvedAssets(assets: Partial<Record<string, ModelAsset>> | undefined): {
  det: ModelAsset;
  rec: ModelAsset;
} {
  const det = assets?.det;
  const rec = assets?.rec;
  if (!det || typeof det !== "object" || !rec || typeof rec !== "object") {
    throw new Error(
      "PaddleOCRCore requires pre-resolved detection and recognition asset descriptors."
    );
  }
  return { det, rec };
}

export class OcrPipelineRunner {
  protected options: OcrPipelineRunnerOptions;
  protected modelConfig: OcrModelConfig;
  protected runtimeDefaults: Partial<OcrRuntimeParamsInput>;
  protected cv: OpenCv | null;
  protected ort: OrtModule | null;
  protected detModel: DetModel | null;
  protected recModel: RecModel | null;
  protected webgpuState: WebGpuState;
  protected pipelineConfig: NormalizedPipelineConfig;
  protected lastInitializationSummary: InitializationSummary | null;
  private ensureServedFromHttp: EnsureServedFromHttpFn;

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Use the provided high-level loader/factory that runs normalizeOcrPipelineConfig and resolves both det and rec assets for you
  2. If constructing manually, verify assets.det and assets.rec are both non-null objects before calling the constructor
  3. Trace why one asset is missing — usually the corresponding module's model_dir/model_name in the config was incomplete

Example fix

// before
new PaddleOCRCore({ assets: { det: detAsset } }); // throws: rec missing

// after
new PaddleOCRCore({ assets: { det: detAsset, rec: recAsset } });
Defensive patterns

Strategy: validation

Validate before calling

function isModelAsset(v: unknown): v is { url?: string } {
  return typeof v === "object" && v !== null;
}
if (!isModelAsset(assets?.det) || !isModelAsset(assets?.rec)) {
  throw new Error("Both det and rec assets must be resolved before constructing the core");
}

Type guard

function hasResolvedDetRec(assets: Partial<Record<string, unknown>> | undefined): assets is { det: object; rec: object } {
  return typeof assets?.det === "object" && assets.det !== null && typeof assets?.rec === "object" && assets.rec !== null;
}

Prevention

When it happens

Trigger: Constructing PaddleOCRCore directly with assets: { det: {...} } (rec missing), with nullish entries, or with non-object values; building the assets record from a config where one module's model_dir was null so no asset was produced.

Common situations: Bypassing the high-level pipeline factory and wiring the core by hand; a loader step silently skipping a failed asset resolution so the record ends up half-populated; passing the raw config object where a resolved-assets record is expected.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/bd4bd05ffeddc4a4. Report an issue: GitHub.