Skip to main content

kcai-data-sampling-lama

The generative slot of kcai data-sampling: transformations where a model produces the output. Here the model is a tool — it fills in content that was not in the source sample, so the family's defining property is that the output is genuinely new rather than a rearrangement of the input.

This package implements inpainting with LaMa (Suvorov et al., WACV 2022) as a tool model, and exposes it through two entry-point groups: inpaint under kcai_data_sampling.transformations, and lama_inpaint under kcai_data_sampling.models.

A tool model declares model_role = "tool", which is what makes the framework treat it as generative. The map is deterministic — no randomness is drawn, so the recorded seed is None — and not reversible, because what was in the filled region is gone.

What it ships today

  • inpaint — one method: erase a rectangular region and let the model refill it.
  • lama_inpaint — the LaMa tool model behind it.

One method, as an example of the slot rather than a catalogue.

Install

pip install "kcai-data-sampling[lama]"

This is the package that brings torch. It is the only one of the transformation packages that depends on a deep-learning framework, so an install that does not ask for it stays torch-free. torch is imported lazily — importing this package does not itself require torch — and the checkpoint is a weights file fetched at run time, not a dependency.

The released big-lama TorchScript checkpoint (~200 MB) is downloaded into the weight cache on first use, from the upstream release. The cache is $KCAI_WEIGHTS_DIR when that is set; otherwise .cache/ beside the working directory — inside a checkout that resolves to the repository's own .cache/. Checkpoints are never committed.

Example

The models and operations sections of a job configuration:

models:
  lama:
    type: lama_inpaint
    weights: big-lama.pt
    params: { margin: 256 }
operations:
  transformations:
    - name: inpaint
      type: inpaint
      tool_model: lama
      top: 350
      left: 700
      height: 300
      width: 500

The transformation names its model with tool_model: lama, referring to the key under models:. top/left/height/width describe the rectangle to erase; the window must fit inside the frame, which is only knowable at run time, so a window that would leave it is refused rather than silently wrapped. margin is how many pixels of surrounding context are cropped around the mask for the network.

Only the channels the network consumes are sent to it — three, RGB — so the alpha plane of an RGBA batch is passed through untouched.

Bring your own model

Any object reachable through a kcai_data_sampling.models entry point is a model, exactly like a transformation. To use a custom inference routine, ship a small importable package that registers your adapter under that entry-point group and lets it declare its own dependencies (torch, your inference library) in its own metadata. They never belong to the core contracts or to the job package. A classic-sketch adapter to paste into your package:

class MyModel:
    channels = 3  # RGB only: the adapter receives exactly those planes

    def __init__(self, weights: str, **params):
        self.name = weights  # the ledger records this string
        self._load(weights, **params)

    def inpaint(self, xs, masks):
        """(B, H, W, C) uint8 image batch in, (B, H, W, C) uint8 out."""
        ...  # fill every masked pixel; leave the rest unchanged


def plugin() -> MyModel:
    return MyModel

and point [project.entry-points."kcai_data_sampling.models"] at it (e.g. mymodel = "my_package.models:plugin"). A tool model is recognised by a non-empty name plus an inpaint method, and conformance is checked against the tool role the transformation declares.

Known-architecture custom weights need no code at all: keep type: lama_inpaint and set weights to your own checkpoint file.

Metadata

Release files for kcai-data-sampling-lama 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kcai-data-sampling-lama 0.8.0
File Size Uploaded Provenance Actions
kcai_data_sampling_lama-0.8.0.tar.gz 11.9 kB Without provenance Details for kcai_data_sampling_lama-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kcai-data-sampling-lama 0.8.0
File Interpreter ABI Platform Actions
kcai_data_sampling_lama-0.8.0-py3-none-any.whl Python 3 none any Details for kcai_data_sampling_lama-0.8.0-py3-none-any.whl

Total release size: 25.2 kB

Release files / kcai_data_sampling_lama-0.8.0.tar.gz

Download URL kcai_data_sampling_lama-0.8.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
89c2159bbb527bb2a6c0c1541a90652eaa1b1472d9c999b283dd7a2040772fc5
BLAKE2b-256 checksum
How to use checksums
4d2d337f7c32db820ca263aa1379490263291ffa787a8cd15708b67f37daa9cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.17

Release files / kcai_data_sampling_lama-0.8.0-py3-none-any.whl

Download URL kcai_data_sampling_lama-0.8.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f369d661894a966ff044dbb0f9c1ed5a2277aa270dfaae308d395e390164108
BLAKE2b-256 checksum
How to use checksums
09772530d698f88084e95157a4d182af94d45f31fc0546239451b3b24fd14480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.17

Security for kcai-data-sampling-lama 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page