Skip to content

custom detection always returns "No custom models found" until /v1/vision/custom/list is called #7

Description

@kmbrimble

Summary

In detect_adapter.py, the custom command checks a cache that only the list-custom command ever populates. After the module process starts, every /v1/vision/custom/<model> request fails with "No custom models found" until something calls /v1/vision/custom/list at least once.

Current main, lines 125-128:

elif data.command == "custom":                  # Perform custom object detection

    if not self.custom_model_names:
        return { "success": False, "error": "No custom models found" }

self.custom_model_names is initialised to [] (line 25) and is assigned only inside _list_custom_models() (line 208), which is reached only from the list-custom branch (line 97). The custom branch reads the cache but never fills it.

Impact

This is the cause of the recurring "Blue Iris suddenly reports nothing found" reports, e.g. codeproject/CodeProject.AI-Server#311 (currently marked answered with "update Blue Iris" / "restart Windows" — both of which work only because they restart Blue Iris, which makes it re-enumerate models and call list-custom).

It is hard to spot because /v1/status/ping keeps returning 200, so Blue Iris reports the server online and simply logs every alert as Alert canceled [nothing found]. A client configured for custom models only sees 100% detection failure with no error surfaced anywhere obvious.

The older ObjectDetectionYOLOv5-6.2 adapter has no such guard in its custom branch, so this is a regression introduced with the YOLOv8 module. That is also why "revert to YOLOv5" circulates as a workaround.

Reproduction

  1. Place a custom model (e.g. ipcam-general.pt) in custom-models/.
  2. Restart the module (or the container).
  3. Without calling /v1/vision/custom/list, POST an image to /v1/vision/custom/ipcam-general.

Actual:

{"success":false,"error":"No custom models found","code":500,"moduleId":"ObjectDetectionYOLOv8"}

Then POST /v1/vision/custom/list and repeat step 3 — it now succeeds and runs inference normally.

A useful tell in the failing state is latency: the error path returns in ~10-20ms where real inference takes ~200-300ms.

Suggested fix

Populate the cache on demand. _list_custom_models() already rate-limits itself to one scandir per 60s, so this costs nothing in the steady state:

elif data.command == "custom":                  # Perform custom object detection

    if not self.custom_model_names:
        self._list_custom_models()

    if not self.custom_model_names:
        return { "success": False, "error": "No custom models found" }

PR to follow.

Environment

  • CodeProject.AI Server 2.9.5 (Docker, codeproject/ai-server:cuda12_2)
  • ObjectDetectionYOLOv8 1.6.2, GPU (CUDA)
  • Client: Blue Iris 5.x configured for custom models only

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions