Advanced

Customize losses, backbones, and large vision models in Python.

The CLI covers built-in FPS workflows. For research extensions, use the Python API to inject losses, wrap custom encoders, or build feature banks from compatible model outputs.

Custom losses

Custom losses receive a dict-like context with batch, outputs, weights, schedules, step, and mutable state. Use extra_loss_terms to append a loss, or loss_terms to replace the default list.

from fps_uda import LossOutput

def extra_entropy_logit_penalty(ctx):
    logits = ctx["outputs"]["entropy.logits"]
    value = logits.sum() * 0.0 if ctx["step"] < 100 else 0.01 * logits.pow(2).mean()
    return LossOutput("extra_entropy_logit_penalty", value)

Backbones

PoolableBackbone handles flat, spatial, or token features

A custom backbone may return flat features, spatial maps, or token features. PoolableBackbone handles FPS-UDA clean and random-pooling views.

backbone:
  backend: hf_auto_vision
  name: google/siglip2-so400m-patch14-384
  pretrained: true
  pooling:
    feature_type: token
    random_strategy: token_channel_squared

Release choices

Public feature-bank release

Deterministic image views

The public feature-bank extraction simplifies random crop and contrast perturbations into deterministic views such as five-crop variants.

Random pooling retained

Random pooling remains part of the released view grid, so consistency training can still use paired stochastic feature views.

Configs re-searched

Because released banks differ slightly from the original experimental pipeline, benchmark hyperparameters were re-searched for the public configs.

Publishing

GitHub Pages setup

This documentation site has no build step. In repository settings, publish from the main branch and the /docs folder.

Settings -> Pages -> Deploy from a branch -> main / docs