Sync from GitHub via hub-sync
Browse filesFiles changed (4)
- README.md+7-4
- SKILL.md+37-8
- falcon-perception-bucket.py+13-7
- falcon-perception.py+11-6
310 unmodified lines311312313314315316317318319320321322323324310 unmodified lines`falcon-perception-bucket.py` reads images from an HF bucket and writes resumable parquet parts back to a bucket — kill it and re-run the same command, done keys are skipped. Publish once at the end to use the rest of this directory:```pythonfrom datasets import load_datasetload_dataset("parquet", data_files="hf://buckets/you/bl-masks/part-*.parquet",split="train").push_to_hub("you/bl-masks")```### Output columns`objects.bbox` (`yolo`), `objects.category`, `objects.area`, `objects.rectangularity`, plus `image`, `image_id` (int64 — COCO-style trainers require an integer id), `source_id` (the original key), `width`, `height`, `n_instances`, and `masks_rle` (COCO RLE — segmentation rides along; the bbox scripts ignore it).### Train on the output310 unmodified lines311312313314315316317318319320321322323324325326327310 unmodified lines`falcon-perception-bucket.py` reads images from an HF bucket and writes resumable parquet parts back to a bucket — kill it and re-run the same command, done keys are skipped. Publish once at the end to use the rest of this directory:```pythonfrom datasets import ClassLabel, Sequence, load_datasetds = load_dataset("parquet", data_files="hf://buckets/<namespace>/<bucket>/part-*.parquet",split="train")feats = ds.features.copy() # parquet stores category as bare ints; name the classfeats["objects"]["category"] = Sequence(ClassLabel(names=[ds[0]["query"]]))ds.cast(feats).push_to_hub("<namespace>/<dataset>") # a dataset repo, distinct from the bucket```### Output columns`objects.bbox` (`yolo`), `objects.category` (a `ClassLabel` named after the query), `objects.area`, `objects.rectangularity`, plus `image`, `image_id` (int64 — COCO-style trainers require an integer id), `source_id` (the original key), `width`, `height`, `n_instances`, and `masks_rle` (COCO RLE — segmentation rides along; the bbox scripts ignore it).### Train on the output
39 unmodified lines404142434445464721 unmodified lines69707172737475767778798039 unmodified linesuv run https://huggingface.co/datasets/uv-scripts/object-detection/raw/main/falcon-perception.py \--dataset <USER>/<IMAGES> --limit 3 --query photograph --preview# or the same check as a small job (previews don't persist on Jobs — push a tiny dataset instead):hf jobs uv run --flavor t4-small --secrets HF_TOKEN \https://huggingface.co/datasets/uv-scripts/object-detection/raw/main/falcon-perception.py \--dataset <USER>/<IMAGES> --limit 3 --query photograph --out <USER>/<NAME>-check --private```21 unmodified lines--dataset <USER>/<IMAGES> --query photograph --out <USER>/<NAME>-photograph --private```- Avoid `a10g-small` — the engine sizes itself from the GPU and ignores host RAM, so it getsOOM-killed. `hf jobs hardware` lists current options and prices.- One job per class (step 1's rule). Merge per-class outputs by concatenating the `objects` entries ofrows with the same `image_id`.- Output schema: `objects.bbox` in **YOLO format** (normalized center x, y, w, h), `objects.category`,`objects.area`, `objects.rectangularity`, plus `image`, `image_id`, `width`, `height`.- There are **no confidence scores** (the model has none). `rectangularity` (mask area ÷ box area) is thetriage proxy: values near 0 are usually junk, 0.785 is a circle, 1.0 a full rectangle.- Submit with `--detach` (returns the job id immediately), then block on completion with39 unmodified lines40414243444546474821 unmodified lines70717273747576777879808182838485868788899091929394959697989910010110210310410510610710810939 unmodified linesuv run https://huggingface.co/datasets/uv-scripts/object-detection/raw/main/falcon-perception.py \--dataset <USER>/<IMAGES> --limit 3 --query photograph --preview# or the same check as a small job (previews don't persist on Jobs — push a tiny dataset instead).# l4x1 is the cheapest flavor that fits the engine (see step 2's flavor rule):hf jobs uv run --flavor l4x1 --secrets HF_TOKEN \https://huggingface.co/datasets/uv-scripts/object-detection/raw/main/falcon-perception.py \--dataset <USER>/<IMAGES> --limit 3 --query photograph --out <USER>/<NAME>-check --private```21 unmodified lines--dataset <USER>/<IMAGES> --query photograph --out <USER>/<NAME>-photograph --private```- Flavor rule (all three failures measured): the engine needs a **24 GB-VRAM GPU** (16 GB T4sCUDA-OOM during prefill) and **more than 15 GB host RAM** (the engine sizes itself from the GPUand ignores host RAM, so `t4-small` and `a10g-small` are OOMKilled before the first image).`hf jobs hardware --json` lists every flavor's `ram`, accelerator and price — `l4x1` is thecheapest fit (fine for the step-1 check); `a10g-large` is faster for a corpus pass.- One job per class (step 1's rule). Every run labels its boxes `category` 0 in a single-name`ClassLabel`, so a naive concat collapses the classes — renumber each run to its index in acombined `ClassLabel` when merging. Rows align on `image_id` (every run contains every image):```pythonfrom datasets import ClassLabel, Sequence, load_datasetnames = ["illustration", "map"]parts = [load_dataset(f"<USER>/<NAME>-{n}", split="train") for n in names]extra = [dict(zip(ds["image_id"], ds["objects"])) for ds in parts[1:]]def merge(row):o = {k: list(v) for k, v in row["objects"].items()}for i, run in enumerate(extra, start=1):r = run[row["image_id"]]o["bbox"] += r["bbox"]; o["area"] += r["area"]o["rectangularity"] += r["rectangularity"]o["category"] += [i] * len(r["bbox"])return {"objects": o, "n_instances": len(o["bbox"])}feats = parts[0].features.copy()feats["objects"]["category"] = Sequence(ClassLabel(names=names))merged = parts[0].map(merge, features=feats)```(`masks_rle` concatenates the same way if you need the masks.)- Output schema: `objects.bbox` in **YOLO format** (normalized center x, y, w, h), `objects.category`(a `ClassLabel` named after the query), `objects.area`, `objects.rectangularity`, plus `image`,`image_id`, `width`, `height`.- There are **no confidence scores** (the model has none). `rectangularity` (mask area ÷ box area) is thetriage proxy: values near 0 are usually junk, 0.785 is a circle, 1.0 a full rectangle.- Submit with `--detach` (returns the job id immediately), then block on completion with
25 unmodified lines26272829303132333435363 unmodified lines404142434445464725 unmodified lines7374757677787925 unmodified linesrun resumable (`completed_keys` reads the done-set back from `__source_key`).To hand the result to the rest of this directory, publish it once at the end:from datasets import load_datasetload_dataset("parquet", data_files="hf://buckets/you/bl-masks/part-*.parquet",split="train").push_to_hub("you/bl-masks")uv run validate-hf-dataset.py you/bl-masks --bbox-format yoloNote the parts carry `width`/`height` but no `image` column (the images stay inthe source bucket), so pass --image-column accordingly if a downstream script3 unmodified lines* --query is a CLASS NAME. "illustration" works; "the illustration, excludingcaptions" returns nothing.* torch.compile breaks on per-image dynamic shapes -> compile is OFF here.* engine_config_for_gpu() sizes from the GPU and ignores host RAM; ona10g-small it gets OOMKilled (exit 137) before processing anything.cudagraph is off by default here for the same reason.* xy in the output is the NORMALISED CENTRE, not a corner."""25 unmodified lines("height", pa.int32()),("objects", pa.struct([("bbox", pa.list_(pa.list_(pa.float32()))), # yolo: cx, cy, w, h normalised("category", pa.list_(pa.int64())), # single class per run, by design("area", pa.list_(pa.float32())),("rectangularity", pa.list_(pa.float32())), # triage proxy — no confidence score exists])),25 unmodified lines26272829303132333435363738393 unmodified lines43444546474849505125 unmodified lines77787980818283848525 unmodified linesrun resumable (`completed_keys` reads the done-set back from `__source_key`).To hand the result to the rest of this directory, publish it once at the end:from datasets import ClassLabel, Sequence, load_datasetds = load_dataset("parquet", data_files="hf://buckets/<namespace>/<bucket>/part-*.parquet",split="train")feats = ds.features.copy() # parquet stores category as bare ints; name the classfeats["objects"]["category"] = Sequence(ClassLabel(names=[ds[0]["query"]]))ds.cast(feats).push_to_hub("<namespace>/<dataset>") # a dataset repo, distinct from the bucketuv run validate-hf-dataset.py <namespace>/<dataset> --bbox-format yoloNote the parts carry `width`/`height` but no `image` column (the images stay inthe source bucket), so pass --image-column accordingly if a downstream script3 unmodified lines* --query is a CLASS NAME. "illustration" works; "the illustration, excludingcaptions" returns nothing.* torch.compile breaks on per-image dynamic shapes -> compile is OFF here.* engine_config_for_gpu() sizes from the GPU and ignores host RAM; the 15 GBflavors (t4-small, a10g-small) get OOMKilled (exit 137) before processinganything -- pick >15 GB `ram` from `hf jobs hardware --json`.cudagraph is off by default here for the same reason.* xy in the output is the NORMALISED CENTRE, not a corner."""25 unmodified lines("height", pa.int32()),("objects", pa.struct([("bbox", pa.list_(pa.list_(pa.float32()))), # yolo: cx, cy, w, h normalised("category", pa.list_(pa.int64())), # single class per run; the class NAME# is the `query` column — cast to# ClassLabel at publish (see docstring)("area", pa.list_(pa.float32())),("rectangularity", pa.list_(pa.float32())), # triage proxy — no confidence score exists])),
64 unmodified lines6566676869707172177 unmodified lines250251252253254255256257203 unmodified lines46146246346446546646746846947047147247364 unmodified lines* torch.compile is OFF. Per-image dynamic shapes break Inductor("ValueError: Exponent must be non-negative" after symbolic-shape recursion).* CUDA graphs are OFF by default. engine_config_for_gpu() sizes itself from theGPU and ignores host RAM; on a10g-small the container is OOMKilled (exit 137)before one image is processed. Use a10g-large, or pass --cudagraph knowingly."""import argparse177 unmodified lines{counters["images"]} images, {counters["instances"]} instances. Labels are **zero-shot weaklabels** from [Falcon-Perception](https://huggingface.co/tiiuae/Falcon-Perception) -- no humanannotated anything, and recall against human truth is unmeasured. `objects.bbox` is `yolo`format (normalised centre x, y, w, h); `objects.rectangularity` (mask area / box area) is thetriage proxy -- the model emits no confidence scores.## Reproduction203 unmodified lineshub_out = args.out and not args.out.endswith((".json", ".jsonl", ".parquet"))if hub_out:from datasets import Dataset, Features, Image as ImageFeat, Sequence as SeqFeat, Valuefeats = Features({"image": ImageFeat(), "image_id": Value("int64"), "source_id": Value("string"),"width": Value("int32"), "height": Value("int32"),"objects": {"bbox": SeqFeat(SeqFeat(Value("float32"))),"category": SeqFeat(Value("int64")),"area": SeqFeat(Value("float32")),"rectangularity": SeqFeat(Value("float32"))},"n_instances": Value("int32"), "masks_rle": Value("string"),64 unmodified lines65666768697071727374177 unmodified lines252253254255256257258259260203 unmodified lines46446546646746846947047147247347447547647747864 unmodified lines* torch.compile is OFF. Per-image dynamic shapes break Inductor("ValueError: Exponent must be non-negative" after symbolic-shape recursion).* CUDA graphs are OFF by default. engine_config_for_gpu() sizes itself from theGPU and ignores host RAM; on the 15 GB-host-RAM flavors (t4-small, a10g-small-- both measured) the container is OOMKilled (exit 137) before one image isprocessed. Pick a flavor with >15 GB `ram` from `hf jobs hardware --json`,or pass --cudagraph knowingly."""import argparse177 unmodified lines{counters["images"]} images, {counters["instances"]} instances. Labels are **zero-shot weaklabels** from [Falcon-Perception](https://huggingface.co/tiiuae/Falcon-Perception) -- no humanannotated anything, and recall against human truth is unmeasured. `objects.bbox` is `yolo`format (normalised centre x, y, w, h); `objects.category` is a `ClassLabel` named `{query}`;`objects.rectangularity` (mask area / box area) is the triage proxy -- the model emits noconfidence scores.## Reproduction203 unmodified lineshub_out = args.out and not args.out.endswith((".json", ".jsonl", ".parquet"))if hub_out:from datasets import ClassLabel, Dataset, Features, Image as ImageFeat, Sequence as SeqFeat, Valuefeats = Features({"image": ImageFeat(), "image_id": Value("int64"), "source_id": Value("string"),"width": Value("int32"), "height": Value("int32"),# category is a ClassLabel named after the query, so the class name travels# with the dataset (viewer, trainers, id2label) instead of a bare 0."objects": {"bbox": SeqFeat(SeqFeat(Value("float32"))),"category": SeqFeat(ClassLabel(names=[args.query])),"area": SeqFeat(Value("float32")),"rectangularity": SeqFeat(Value("float32"))},"n_instances": Value("int32"), "masks_rle": Value("string"),
README.md+7-4
SKILL.md+37-8
falcon-perception-bucket.py+13-7
falcon-perception.py+11-6