Vision Model Training on Hugging Face Jobs
Train object detection, image classification, and SAM/SAM2 segmentation models on managed cloud GPUs. No local GPU setup required—results are automatically saved to the Hugging Face Hub.
Detailed Guide
Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
When to Use This Skill
Use this skill when users want to:
- Fine-tune object detection models (D-FINE, RT-DETR v2, DETR, YOLOS) on cloud GPUs or local
- Fine-tune image classification models (timm: MobileNetV3, MobileViT, ResNet, ViT/DINOv3, or any Transformers classifier) on cloud GPUs or local
- Fine-tune SAM or SAM2 models for segmentation / image matting using bbox or point prompts
- Train bounding-box detectors on custom datasets
- Train image classifiers on custom datasets
- Train segmentation models on custom mask datasets with prompts
- Run vision training jobs on Hugging Face Jobs infrastructure
- Ensure trained vision models are permanently saved to the Hub
Prerequisites Checklist
Before starting any training job, verify:
Account & Authentication
- Hugging Face Account with Pro, Team, or Enterprise plan (Jobs require paid plan)
- Authenticated login: Check with
hf_whoami() (tool) or hf auth whoami (terminal)
- Token has write permissions
- MUST pass token in job secrets — see directive #3 below for syntax (MCP tool vs Python API)
Dataset Requirements — Object Detection
- Dataset must exist on Hub
- Annotations must use the
objects column with bbox, category (and optionally area) sub-fields
- Bboxes can be in xywh (COCO) or xyxy (Pascal VOC) format — auto-detected and converted
- Categories can be integers or strings — strings are auto-remapped to integer IDs
image_id column is optional — generated automatically if missing
- ALWAYS validate unknown datasets before GPU training (see Dataset Validation section)
Dataset Requirements — Image Classification
- Dataset must exist on Hub
- Must have an
image column (PIL images) and a label column (integer class IDs or strings)
- The label column can be
ClassLabel type (with names) or plain integers/strings — strings are auto-remapped
- Common column names auto-detected:
label, labels, class, fine_label
- ALWAYS validate unknown datasets before GPU training (see Dataset Validation section)
Dataset Requirements — SAM/SAM2 Segmentation
- Dataset must exist on Hub
- Must have an
image column (PIL images) and a mask column (binary ground-truth segmentation mask)
- Must have a prompt — either:
- A
prompt column with JSON containing {"bbox": [x0,y0,x1,y1]} or {"point": [x,y]}
- OR a dedicated
bbox column with [x0,y0,x1,y1] values
- OR a dedicated
point column with [x,y] or [[x,y],...] values
- Bboxes should be in xyxy format (absolute pixel coordinates)
- Example dataset:
merve/MicroMat-mini (image matting with bbox prompts)
- ALWAYS validate unknown datasets before GPU training (see Dataset Validation section)
Critical Settings
- Timeout must exceed expected training time — Default 30min is TOO SHORT. See directive #6 for recommended values.
- Hub push must be enabled —
push_to_hub=True, hub_model_id="username/model-name", token in secrets
Limitations
- Use this skill only when the task clearly matches its upstream product or API scope.
- Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
- Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
1---
2name: hugging-face-vision-trainer
3description: Train object detection, image classification, and SAM or SAM2 segmentation models locally or on Hugging Face Jobs, with dataset validation and results saved to the Hub.
4category: Document Processing
5source: antigravity
6tags: [python, api, mcp, ai, document, image, security, cro]
7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/hugging-face-vision-trainer
8metadata:
9 source: https://skillmd.com/skills/sickn33/hugging-face-vision-trainer
10---
11
12
13# Vision Model Training on Hugging Face Jobs
14
15Train object detection, image classification, and SAM/SAM2 segmentation models on managed cloud GPUs. No local GPU setup required—results are automatically saved to the Hugging Face Hub.
16
17## Detailed Guide
18
19Read [the detailed guide](references/detailed-guide.md) before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
20
21## When to Use This Skill
22
23Use this skill when users want to:
24- Fine-tune object detection models (D-FINE, RT-DETR v2, DETR, YOLOS) on cloud GPUs or local
25- Fine-tune image classification models (timm: MobileNetV3, MobileViT, ResNet, ViT/DINOv3, or any Transformers classifier) on cloud GPUs or local
26- Fine-tune SAM or SAM2 models for segmentation / image matting using bbox or point prompts
27- Train bounding-box detectors on custom datasets
28- Train image classifiers on custom datasets
29- Train segmentation models on custom mask datasets with prompts
30- Run vision training jobs on Hugging Face Jobs infrastructure
31- Ensure trained vision models are permanently saved to the Hub
32
33## Prerequisites Checklist
34
35Before starting any training job, verify:
36
37### Account & Authentication
38- Hugging Face Account with [Pro](https://hf.co/pro), [Team](https://hf.co/enterprise), or [Enterprise](https://hf.co/enterprise) plan (Jobs require paid plan)
39- Authenticated login: Check with `hf_whoami()` (tool) or `hf auth whoami` (terminal)
40- Token has **write** permissions
41- **MUST pass token in job secrets** — see directive #3 below for syntax (MCP tool vs Python API)
42
43### Dataset Requirements — Object Detection
44- Dataset must exist on Hub
45- Annotations must use the `objects` column with `bbox`, `category` (and optionally `area`) sub-fields
46- Bboxes can be in **xywh (COCO)** or **xyxy (Pascal VOC)** format — auto-detected and converted
47- Categories can be **integers or strings** — strings are auto-remapped to integer IDs
48- `image_id` column is **optional** — generated automatically if missing
49- **ALWAYS validate unknown datasets** before GPU training (see Dataset Validation section)
50
51### Dataset Requirements — Image Classification
52- Dataset must exist on Hub
53- Must have an **`image` column** (PIL images) and a **`label` column** (integer class IDs or strings)
54- The label column can be `ClassLabel` type (with names) or plain integers/strings — strings are auto-remapped
55- Common column names auto-detected: `label`, `labels`, `class`, `fine_label`
56- **ALWAYS validate unknown datasets** before GPU training (see Dataset Validation section)
57
58### Dataset Requirements — SAM/SAM2 Segmentation
59- Dataset must exist on Hub
60- Must have an **`image` column** (PIL images) and a **`mask` column** (binary ground-truth segmentation mask)
61- Must have a **prompt** — either:
62 - A **`prompt` column** with JSON containing `{"bbox": [x0,y0,x1,y1]}` or `{"point": [x,y]}`
63 - OR a dedicated **`bbox`** column with `[x0,y0,x1,y1]` values
64 - OR a dedicated **`point`** column with `[x,y]` or `[[x,y],...]` values
65- Bboxes should be in **xyxy** format (absolute pixel coordinates)
66- Example dataset: `merve/MicroMat-mini` (image matting with bbox prompts)
67- **ALWAYS validate unknown datasets** before GPU training (see Dataset Validation section)
68
69### Critical Settings
70- **Timeout must exceed expected training time** — Default 30min is TOO SHORT. See directive #6 for recommended values.
71- **Hub push must be enabled** — `push_to_hub=True`, `hub_model_id="username/model-name"`, token in `secrets`
72
73## Limitations
74
75- Use this skill only when the task clearly matches its upstream product or API scope.
76- Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
77- Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.