horde-image-utilities
======================

The "annotators" capability runs third-party software that this repository does not vendor. Instead, the
software is obtained at runtime by cloning an upstream project at a pinned commit and importing it. The
attributions below satisfy the notice requirements of that project's license.


ControlNet auxiliary preprocessors (the "annotators" capability)
----------------------------------------------------------------

The controlnet preprocessor detectors are obtained by cloning:

    comfyui_controlnet_aux
    https://github.com/Fannovel16/comfyui_controlnet_aux
    Copyright (c) Fannovel16 and contributors
    Licensed under the Apache License, Version 2.0

    Pinned upstream commit: e8b689a513c3e6b63edc44066560ca5919c0576e

The clone is checked out at the exact commit above (see
`src/horde_image_utilities/annotators/upstream_manifest.json`) into a vendor directory under the
service's data root, its `src` directory is prepended to `sys.path`, and the package
`custom_controlnet_aux` is imported directly. No upstream source is copied into this repository and the
clone is not pip-installed.

comfyui_controlnet_aux itself vendors and adapts the `controlnet_aux` lineage
(https://github.com/huggingface/controlnet_aux, and before it lllyasviel/ControlNet and
Mikubill/sd-webui-controlnet), together with the upstream research implementations each detector is
built on. Those upstream copyrights and licenses are retained in the cloned source. The classic OpenPose
preprocessor in that lineage is licensed by CMU for non-commercial use only.

Runtime monkeypatches applied to the imported clone (see
`src/horde_image_utilities/annotators/upstream_patches.py`):

  - `custom_controlnet_aux.util.custom_hf_download` is replaced so detector weight loads resolve to a
    pre-populated checkpoint directory (the on-disk layout is byte-identical to upstream's) instead of
    downloading, raising a typed error when a required file is absent and downloads are disabled. This is
    installed before any detector module is imported, because detector modules bind the name at import
    time.
  - `custom_controlnet_aux.leres.LeresDetector.from_pretrained` is replaced so it loads only the depth
    model (`res101.pth`) and never the pix2pix "boost" model (`latest_net_G.pth`), which this service's
    defaults never enable.

The UniFormer semantic-segmentation detector (`seg` control type) is served by the clone's bundled
`custom_mmpkg` (MMSegmentation + MMCV) subtree, which imports and runs without compiled CUDA/C++ ops. Its
config machinery relies on the pure-python MMCV dependency stack (`addict`, `yapf`, `pyyaml`, `pydot`),
declared in the `annotators` dependency extra.

Detector weight checkpoints are distributed separately by their respective authors (for example the
`lllyasviel/Annotators` and `Intel/dpt-hybrid-midas` HuggingFace repositories) under their own terms and
are not included in this repository.
