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: 1,220 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 33 34 35 36 37 38 39 40 41 42 | """YAMNet audio classification postprocessor.
Input: [numFrames, 521] score matrix
Output: {"kind": "classifications", "classifications": [{"class", "score"}]}
"""
import numpy as np
def postprocess_yamnet(
predictions: dict,
config: dict,
orig_w: int,
orig_h: int,
scale: float,
pad: tuple[int, int],
) -> dict:
"""Average scores across frames, return top classes above threshold."""
labels = config.get("labels", [])
min_score = config.get("confidence", 0.1)
# Get output_0 (scores) — shape [numFrames, 521]
raw = np.array(list(predictions.values())[0]).astype(np.float32)
if raw.ndim == 1:
raw = raw.reshape(1, -1)
num_frames, num_classes = raw.shape
# Average across frames
avg_scores = np.mean(raw, axis=0)
# Collect classes above threshold, sorted by score
results = []
for c in range(num_classes):
score = float(avg_scores[c])
if score >= min_score:
label = labels[c] if c < len(labels) else str(c)
results.append({"class": label, "score": round(score, 4)})
results.sort(key=lambda x: x["score"], reverse=True)
return {"kind": "classifications", "classifications": results}
|