Run this model with HF Jobs

Run khanhnd61/pop-so101 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/khanhnd61/pop-so101. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/khanhnd61/pop-so101 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
File size: 4,454 Bytes
5a3fcf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Step 3: list the finished shards in <work>/shards/index.json (what training reads) and write
<work>/shards/report.json: datasets kept and dropped by reason (selection and preprocessing), episodes dropped by
reason, frames and hours kept, and the camera roles (how often the motion test agrees with the original names).

    python scripts/build_index.py --work $POPT_WORK
"""
import argparse
import glob
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from popt.common import is_wrist_name, read_json, work_dirs, write_json  # noqa: E402


def main():
    p = argparse.ArgumentParser()
    p.add_argument("--work", default=os.environ.get("POPT_WORK"), required=os.environ.get("POPT_WORK") is None)
    a = p.parse_args()
    D = work_dirs(a.work)
    sel = read_json(D["selection"])
    shards, metas = [], []
    for done in sorted(glob.glob(os.path.join(D["shards"], "*", "DONE"))):
        sd = os.path.dirname(done)
        m = read_json(os.path.join(sd, "meta.json"))
        metas.append(m)
        shards.append({"dir": os.path.basename(sd), "dataset": m["dataset"], "frames": m["frames"],
                       "episodes": m["episodes"], "has_wrist": m["wrist"] is not None})
    assert shards, "no finished shards"
    for k in ("res", "chunk", "target_fps"):
        vals = {m[k] for m in metas}
        assert len(vals) == 1, f"shards disagree on {k}: {vals}"
    status = [read_json(f) for f in sorted(glob.glob(os.path.join(D["shards"], "_status", "*.json")))]
    done_ids = {m["dataset"] for m in metas}
    pending = [d for d in sel["kept"] if d not in done_ids and d not in {s["dataset"] for s in status}]

    def count(xs):
        out = {}
        for x in xs:
            out[x] = out.get(x, 0) + 1
        return dict(sorted(out.items(), key=lambda kv: -kv[1]))

    ep_drop = {}
    for m in metas:
        for r, n in m["episodes_dropped"].items():
            ep_drop[r] = ep_drop.get(r, 0) + n
    roles = {"wrist_found": sum(m["wrist"] is not None for m in metas),
             "no_wrist": sum(m["wrist"] is None for m in metas),
             "single_camera": sum(len(m["camera_names"]) == 1 for m in metas)}
    roles["datasets_with_a_camera_named_wrist"] = sum(any(is_wrist_name(n) for n in m["camera_names"].values()) for m in metas)
    roles["wrist_input_named_wrist"] = sum(is_wrist_name(m["wrist_name"]) for m in metas)
    roles["wrist_input_found_by_still_fraction_only"] = sum(m["wrist"] is not None and not is_wrist_name(m["wrist_name"]) for m in metas)
    frames = sum(s["frames"] for s in shards)
    report = {"revision": sel["revision"], "target_fps": metas[0]["target_fps"], "res": metas[0]["res"],
              "datasets_in_repo_selected": len(sel["kept"]) + len(sel["dropped"]),
              "dropped_at_selection": sel["dropped_by_reason"],
              "dropped_in_preprocessing": count(s.get("reason", "failed") for s in status if s["status"] == "dropped"),
              "failed": [s["dataset"] for s in status if s["status"] == "failed"],
              "not_processed_yet": pending,
              "kept": {"datasets": len(shards), "episodes": sum(s["episodes"] for s in shards), "frames": frames,
                       "hours": round(frames / metas[0]["target_fps"] / 3600, 2),
                       "frames_with_wrist": sum(s["frames"] for s in shards if s["has_wrist"])},
              "episodes_dropped_by_reason": dict(sorted(ep_drop.items(), key=lambda kv: -kv[1])),
              "camera_roles": roles}
    write_json(os.path.join(D["shards"], "index.json"),
               {"revision": sel["revision"], "target_fps": metas[0]["target_fps"], "res": metas[0]["res"],
                "chunk": metas[0]["chunk"], "frames": frames, "shards": shards})
    write_json(os.path.join(D["shards"], "report.json"), report)
    print(f"index: {len(shards)} shards, {frames} frames ({report['kept']['hours']} h at {metas[0]['target_fps']} Hz)")
    print(f"dropped at selection {report['dropped_at_selection']}; in preprocessing {report['dropped_in_preprocessing']}; "
          f"failed {len(report['failed'])}; not processed {len(pending)}")
    print(f"episodes dropped {report['episodes_dropped_by_reason']}")
    print(f"camera roles {roles}")
    if report["failed"] or pending:
        print("WARNING: some datasets failed or are not processed; see shards/_status/ and rerun step 2 before training")


if __name__ == "__main__":
    main()