Instructions to use camstack/camstack-trainer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use camstack/camstack-trainer with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("camstack/camstack-trainer", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
File size: 796 Bytes
ebeed67 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """ArcFace face embedding postprocessor.
Input: raw embedding tensor from ArcFace model
Output: {"kind": "embedding", "embedding": [...], "embeddingNorm": [...]}
"""
import numpy as np
def postprocess_arcface(
predictions: dict,
config: dict,
orig_w: int,
orig_h: int,
scale: float,
pad: tuple[int, int],
) -> dict:
"""L2-normalize the embedding vector."""
# Get the first output tensor (usually named "fc1" or similar)
raw = np.array(list(predictions.values())[0]).flatten().astype(np.float32)
norm = np.linalg.norm(raw)
if norm == 0:
normalized = np.zeros_like(raw)
else:
normalized = raw / norm
return {
"kind": "embedding",
"embedding": raw.tolist(),
"embeddingNorm": normalized.tolist(),
}
|