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
camstack-train 0.1.0: YOLOv9 root detector fine-tune (job.json in, result.json + bundle.tar out)
ebeed67 verified Download camstack_train/_vendor/pipeline_python/postprocessors/softmax.py from camstack/camstack-trainer: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/camstack/camstack-trainer/resolve/main/camstack_train/_vendor/pipeline_python/postprocessors/softmax.py
- Command line
-
hf download hf://camstack/camstack-trainer/camstack_train/_vendor/pipeline_python/postprocessors/softmax.py
-
curl -L -o softmax.py https://huggingface.co/camstack/camstack-trainer/resolve/main/camstack_train/_vendor/pipeline_python/postprocessors/softmax.py
1.91 kB
| """Softmax classifier postprocessor. | |
| Used for: animal-classifier, bird-classifier, vehicle-type-v1, and any custom | |
| softmax classifier. | |
| Input: raw logits tensor | |
| Output: {"kind": "classifications", "classifications": [{"class", "score"}]} | |
| """ | |
| import numpy as np | |
| def postprocess_softmax( | |
| predictions: dict, | |
| config: dict, | |
| orig_w: int, | |
| orig_h: int, | |
| scale: float, | |
| pad: tuple[int, int], | |
| ) -> dict: | |
| """Softmax + argmax + label lookup. | |
| When ``config['outputProbabilities']`` is set the model already applies | |
| softmax IN-GRAPH (e.g. the Google AIY Birds classifier) — its raw output is | |
| a probability distribution, so we consume it directly. Re-softmaxing an | |
| already-normalised probability vector is NOT a no-op: it collapses the | |
| distribution toward uniform (the top-1 score craters far below its true | |
| value), which silently defeats every downstream confidence gate. | |
| """ | |
| labels = config.get("labels", []) | |
| # Get first output tensor | |
| raw = np.array(list(predictions.values())[0]).flatten().astype(np.float32) | |
| if config.get("outputProbabilities"): | |
| # Model output is already a softmax distribution — do NOT re-softmax. | |
| probs = raw | |
| else: | |
| # Stable softmax over raw logits. | |
| shifted = raw - np.max(raw) | |
| exps = np.exp(shifted) | |
| probs = exps / np.sum(exps) | |
| # Return top-K classifications — normalization (top-1 + alternates) happens in TypeScript | |
| top_k = min(5, len(probs)) | |
| top_indices = np.argsort(probs)[::-1][:top_k] | |
| classifications = [] | |
| for idx in top_indices: | |
| idx = int(idx) | |
| score = float(probs[idx]) | |
| if score < 0.01: | |
| break | |
| label = labels[idx] if idx < len(labels) else str(idx) | |
| classifications.append({"class": label, "score": round(score, 4)}) | |
| return {"kind": "classifications", "classifications": classifications} | |