hamer-p150 / code /hamer /__init__.py
changh95's picture
Python API (2026-10-04): pip install -e code/, from_pretrained() + model(...), Python-first quickstart
1b17257 verified
Raw History Blame Contribute Delete
1.57 kB
# SPDX-FileCopyrightText: © 2026 Tenstorrent Inc.
# SPDX-License-Identifier: Apache-2.0
"""Tenstorrent Blackhole port of the HaMeR per-frame regressor.
Python API (see ``PYTHON.md``)::
from hamer import HamerModel
with HamerModel.from_pretrained(device_id=0) as model:
hand = model("frame.jpg", bbox=[x1, y1, x2, y2], is_right=True)
Lower-level pieces (unchanged)::
from hamer import Hamer, build_reference, build_from_reference, sample_input
from hamer import load_hamer_checkpoint
from hamer.preprocess import preprocess
Importing the package does not import ``ttnn``; the device stack loads when a model is built.
"""
from __future__ import annotations
import importlib
from typing import Any
from .api import HamerModel, HandPrediction, apply_served_config, load_reference, open_device
__version__ = "0.1.0"
_LAZY = {
"Hamer": ".reference",
"HamerConfig": ".reference",
"build_reference": ".reference",
"sample_input": ".reference",
"TtHamer": ".model",
"build_from_reference": ".model",
"load_hamer_checkpoint": ".checkpoint",
}
__all__ = [
"HamerModel",
"HandPrediction",
"open_device",
"load_reference",
"apply_served_config",
*_LAZY,
]
def __getattr__(name: str) -> Any:
mod = _LAZY.get(name)
if mod is None:
raise AttributeError(f"module 'hamer' has no attribute {name!r}")
value = getattr(importlib.import_module(mod, __name__), name)
globals()[name] = value
return value
def __dir__():
return sorted(set(globals()) | set(_LAZY))