Add files using upload-large-folder tool
Browse files- backup.py +14 -3
- symbolic/__pycache__/solver.cpython-311.pyc +0 -0
- symbolic/solver.py +36 -1
backup.py
CHANGED
|
@@ -21,11 +21,16 @@ anything outside the target you asked for:
|
|
| 21 |
("data/spatial codes/<model>/...") and ground-truth ("data/spatial codes/ground
|
| 22 |
truth/...") codes in one call, satisfying "upload after the regenerate spatial code
|
| 23 |
parts" without a separate target for it.
|
| 24 |
-
- "code" covers every source directory (harness, symbolic, analysis,
|
| 25 |
-
inference, tests) plus the top-level README.md, backup.py, and setup.sh -- everything
|
| 26 |
needed to reproduce or re-run the experiment, not just its output. Deliberately
|
| 27 |
excludes data/ and results/ (covered by their own targets already) and experiments/
|
| 28 |
-
(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
Usage:
|
| 31 |
python backup.py --repo-id <you>/<repo> --target A
|
|
@@ -40,8 +45,10 @@ Run after each plan finishes:
|
|
| 40 |
Plan B done -> python backup.py --repo-id <you>/<repo> --target B
|
| 41 |
Plan C done -> python backup.py --repo-id <you>/<repo> --target C
|
| 42 |
Plan D done -> python backup.py --repo-id <you>/<repo> --target D
|
|
|
|
| 43 |
symbolic runs done -> python backup.py --repo-id <you>/<repo> --target symbolic
|
| 44 |
code/setup changed -> python backup.py --repo-id <you>/<repo> --target code
|
|
|
|
| 45 |
|
| 46 |
--repo-id, --target, and the Hugging Face token are all prompted for interactively
|
| 47 |
(the token hidden) when not supplied via flag or $HF_TOKEN -- no separate shell wrapper
|
|
@@ -64,6 +71,8 @@ TARGETS = {
|
|
| 64 |
"B": ["results/B"],
|
| 65 |
"C": ["results/C"],
|
| 66 |
"D": ["results/D"],
|
|
|
|
|
|
|
| 67 |
"symbolic": ["results/symbolic"],
|
| 68 |
"spatial-codes": ["data/spatial codes"],
|
| 69 |
"code": [
|
|
@@ -73,10 +82,12 @@ TARGETS = {
|
|
| 73 |
"harness",
|
| 74 |
"symbolic",
|
| 75 |
"analysis",
|
|
|
|
| 76 |
"encoder",
|
| 77 |
"inference",
|
| 78 |
"tests",
|
| 79 |
],
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
|
|
|
|
| 21 |
("data/spatial codes/<model>/...") and ground-truth ("data/spatial codes/ground
|
| 22 |
truth/...") codes in one call, satisfying "upload after the regenerate spatial code
|
| 23 |
parts" without a separate target for it.
|
| 24 |
+
- "code" covers every source directory (harness, symbolic, analysis, corruption,
|
| 25 |
+
encoder, inference, tests) plus the top-level README.md, backup.py, and setup.sh -- everything
|
| 26 |
needed to reproduce or re-run the experiment, not just its output. Deliberately
|
| 27 |
excludes data/ and results/ (covered by their own targets already) and experiments/
|
| 28 |
+
(its own target below, not part of the reproducible pipeline this "code" target
|
| 29 |
+
covers).
|
| 30 |
+
- "experiments" covers the separate, concluded geometry-formula-tuning track (its own
|
| 31 |
+
code, caches, and results all live under one experiments/ tree) -- kept as its own
|
| 32 |
+
target rather than folded into "code" since it's large and conceptually separate from
|
| 33 |
+
the main A/B/C/D/symbolic pipeline.
|
| 34 |
|
| 35 |
Usage:
|
| 36 |
python backup.py --repo-id <you>/<repo> --target A
|
|
|
|
| 45 |
Plan B done -> python backup.py --repo-id <you>/<repo> --target B
|
| 46 |
Plan C done -> python backup.py --repo-id <you>/<repo> --target C
|
| 47 |
Plan D done -> python backup.py --repo-id <you>/<repo> --target D
|
| 48 |
+
blind floor (E) done -> python backup.py --repo-id <you>/<repo> --target E
|
| 49 |
symbolic runs done -> python backup.py --repo-id <you>/<repo> --target symbolic
|
| 50 |
code/setup changed -> python backup.py --repo-id <you>/<repo> --target code
|
| 51 |
+
experiments/ changed -> python backup.py --repo-id <you>/<repo> --target experiments
|
| 52 |
|
| 53 |
--repo-id, --target, and the Hugging Face token are all prompted for interactively
|
| 54 |
(the token hidden) when not supplied via flag or $HF_TOKEN -- no separate shell wrapper
|
|
|
|
| 71 |
"B": ["results/B"],
|
| 72 |
"C": ["results/C"],
|
| 73 |
"D": ["results/D"],
|
| 74 |
+
"E": ["results/E"],
|
| 75 |
+
"corruption": ["results/corruption"],
|
| 76 |
"symbolic": ["results/symbolic"],
|
| 77 |
"spatial-codes": ["data/spatial codes"],
|
| 78 |
"code": [
|
|
|
|
| 82 |
"harness",
|
| 83 |
"symbolic",
|
| 84 |
"analysis",
|
| 85 |
+
"corruption",
|
| 86 |
"encoder",
|
| 87 |
"inference",
|
| 88 |
"tests",
|
| 89 |
],
|
| 90 |
+
"experiments": ["experiments"],
|
| 91 |
}
|
| 92 |
|
| 93 |
|
symbolic/__pycache__/solver.cpython-311.pyc
CHANGED
|
Binary files a/symbolic/__pycache__/solver.cpython-311.pyc and b/symbolic/__pycache__/solver.cpython-311.pyc differ
|
|
|
symbolic/solver.py
CHANGED
|
@@ -56,7 +56,29 @@ import re
|
|
| 56 |
_NUMBER_RE = re.compile(r"[-+]?\d*\.?\d+")
|
| 57 |
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
def _parse_meters(s):
|
|
|
|
| 60 |
"""'3.59 meters' -> 3.59. Also accepts a bare number/int/float, so callers never need to
|
| 61 |
special-case whether a value has already been parsed."""
|
| 62 |
if isinstance(s, (int, float)):
|
|
@@ -68,6 +90,7 @@ def _parse_meters(s):
|
|
| 68 |
|
| 69 |
|
| 70 |
def _parse_square_meters(s):
|
|
|
|
| 71 |
"""'48.4 square meters' -> 48.4. Same numeric parse as _parse_meters -- 'square' doesn't
|
| 72 |
change the regex match, kept as a separate function name for readability at call sites."""
|
| 73 |
return _parse_meters(s)
|
|
@@ -82,6 +105,7 @@ def _parse_square_meters(s):
|
|
| 82 |
|
| 83 |
|
| 84 |
def _instance_xy(code, cls_name, index=0):
|
|
|
|
| 85 |
"""The (x, y) floor-plane position of one instance of `cls_name` -- index 0 (strongest
|
| 86 |
evidence) unless a specific instance is requested. Returns None if the class isn't in the
|
| 87 |
spatial code at all (SAM3 never detected it in this scene)."""
|
|
@@ -94,6 +118,7 @@ def _instance_xy(code, cls_name, index=0):
|
|
| 94 |
|
| 95 |
|
| 96 |
def _rel_direction(point_a, point_b, point_c, mode="hard"):
|
|
|
|
| 97 |
"""Standing at A facing B, where is C? Same formula as
|
| 98 |
encoder/geometric.py's answer_rel_direction(), specialized to the 2D floor plane (the
|
| 99 |
spatial code's frame has no raw height needed for this -- direction is a floor-plane
|
|
@@ -124,6 +149,7 @@ def _rel_direction(point_a, point_b, point_c, mode="hard"):
|
|
| 124 |
|
| 125 |
|
| 126 |
def _classify_turn(h_in, h_out):
|
|
|
|
| 127 |
"""Rotation h_in -> h_out in the floor plane -> 'turn left'/'turn right'/'turn back'
|
| 128 |
(135 degree cutoff, matching VSI's own 'back' threshold and
|
| 129 |
encoder/geometric.py's _classify_turn())."""
|
|
@@ -144,6 +170,7 @@ def _classify_turn(h_in, h_out):
|
|
| 144 |
|
| 145 |
|
| 146 |
def _primary_instance_distance_estimate(code, cls_a, cls_b):
|
|
|
|
| 147 |
"""A cheap, schema-safe lower-bound estimate of the distance between two classes' PRIMARY
|
| 148 |
(instance[0]) instances: 3D center-to-center distance minus each instance's own
|
| 149 |
'longest dimension' / 2 (a rough radius), floored at 0 -- built only from fields the
|
|
@@ -179,6 +206,7 @@ def _primary_instance_distance_estimate(code, cls_a, cls_b):
|
|
| 179 |
|
| 180 |
|
| 181 |
def _closest_distance_meters(code, cls_a, cls_b):
|
|
|
|
| 182 |
"""Reads the precomputed 'closest classes distance meters from' table directly -- this
|
| 183 |
engine never recomputes point-cloud distances itself (the spatial code doesn't carry raw
|
| 184 |
point clouds at all; the table is the only distance information available, by design)."""
|
|
@@ -201,6 +229,7 @@ def _closest_distance_meters(code, cls_a, cls_b):
|
|
| 201 |
|
| 202 |
|
| 203 |
def _find_class(name, code):
|
|
|
|
| 204 |
"""Best-effort match of a free-text object name to an actual class key in the spatial
|
| 205 |
code's objects dict -- exact match first, then substring either direction (mirrors
|
| 206 |
encoder/geometric.py's _find_cls() matching strategy). Returns None if nothing matches."""
|
|
@@ -642,7 +671,13 @@ def answer(question_type, question, options, code):
|
|
| 642 |
fn = _ANSWER_FUNCTIONS.get(question_type)
|
| 643 |
if fn is None:
|
| 644 |
return None
|
| 645 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
|
| 647 |
|
| 648 |
# ==========================================================================================
|
|
|
|
| 56 |
_NUMBER_RE = re.compile(r"[-+]?\d*\.?\d+")
|
| 57 |
|
| 58 |
|
| 59 |
+
# ==========================================================================================
|
| 60 |
+
# OPERATION COUNTING (H25) -- an executable per-question difficulty metric. Every core
|
| 61 |
+
# primitive increments a counter; answer() snapshots the counts for the question it just
|
| 62 |
+
# answered into LAST_ANSWER_OPS. Zero effect on any answer -- counting only.
|
| 63 |
+
# ==========================================================================================
|
| 64 |
+
|
| 65 |
+
_OP_KEYS = (
|
| 66 |
+
"numeric reads",
|
| 67 |
+
"class lookups",
|
| 68 |
+
"table lookups",
|
| 69 |
+
"geometric computations",
|
| 70 |
+
"direction classifications",
|
| 71 |
+
)
|
| 72 |
+
OP_COUNTS = {key: 0 for key in _OP_KEYS}
|
| 73 |
+
LAST_ANSWER_OPS = {}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def _count(op):
|
| 77 |
+
OP_COUNTS[op] += 1
|
| 78 |
+
|
| 79 |
+
|
| 80 |
def _parse_meters(s):
|
| 81 |
+
_count("numeric reads")
|
| 82 |
"""'3.59 meters' -> 3.59. Also accepts a bare number/int/float, so callers never need to
|
| 83 |
special-case whether a value has already been parsed."""
|
| 84 |
if isinstance(s, (int, float)):
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
def _parse_square_meters(s):
|
| 93 |
+
_count("numeric reads")
|
| 94 |
"""'48.4 square meters' -> 48.4. Same numeric parse as _parse_meters -- 'square' doesn't
|
| 95 |
change the regex match, kept as a separate function name for readability at call sites."""
|
| 96 |
return _parse_meters(s)
|
|
|
|
| 105 |
|
| 106 |
|
| 107 |
def _instance_xy(code, cls_name, index=0):
|
| 108 |
+
_count("geometric computations")
|
| 109 |
"""The (x, y) floor-plane position of one instance of `cls_name` -- index 0 (strongest
|
| 110 |
evidence) unless a specific instance is requested. Returns None if the class isn't in the
|
| 111 |
spatial code at all (SAM3 never detected it in this scene)."""
|
|
|
|
| 118 |
|
| 119 |
|
| 120 |
def _rel_direction(point_a, point_b, point_c, mode="hard"):
|
| 121 |
+
_count("direction classifications")
|
| 122 |
"""Standing at A facing B, where is C? Same formula as
|
| 123 |
encoder/geometric.py's answer_rel_direction(), specialized to the 2D floor plane (the
|
| 124 |
spatial code's frame has no raw height needed for this -- direction is a floor-plane
|
|
|
|
| 149 |
|
| 150 |
|
| 151 |
def _classify_turn(h_in, h_out):
|
| 152 |
+
_count("direction classifications")
|
| 153 |
"""Rotation h_in -> h_out in the floor plane -> 'turn left'/'turn right'/'turn back'
|
| 154 |
(135 degree cutoff, matching VSI's own 'back' threshold and
|
| 155 |
encoder/geometric.py's _classify_turn())."""
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
def _primary_instance_distance_estimate(code, cls_a, cls_b):
|
| 173 |
+
_count("geometric computations")
|
| 174 |
"""A cheap, schema-safe lower-bound estimate of the distance between two classes' PRIMARY
|
| 175 |
(instance[0]) instances: 3D center-to-center distance minus each instance's own
|
| 176 |
'longest dimension' / 2 (a rough radius), floored at 0 -- built only from fields the
|
|
|
|
| 206 |
|
| 207 |
|
| 208 |
def _closest_distance_meters(code, cls_a, cls_b):
|
| 209 |
+
_count("table lookups")
|
| 210 |
"""Reads the precomputed 'closest classes distance meters from' table directly -- this
|
| 211 |
engine never recomputes point-cloud distances itself (the spatial code doesn't carry raw
|
| 212 |
point clouds at all; the table is the only distance information available, by design)."""
|
|
|
|
| 229 |
|
| 230 |
|
| 231 |
def _find_class(name, code):
|
| 232 |
+
_count("class lookups")
|
| 233 |
"""Best-effort match of a free-text object name to an actual class key in the spatial
|
| 234 |
code's objects dict -- exact match first, then substring either direction (mirrors
|
| 235 |
encoder/geometric.py's _find_cls() matching strategy). Returns None if nothing matches."""
|
|
|
|
| 671 |
fn = _ANSWER_FUNCTIONS.get(question_type)
|
| 672 |
if fn is None:
|
| 673 |
return None
|
| 674 |
+
for key in _OP_KEYS:
|
| 675 |
+
OP_COUNTS[key] = 0
|
| 676 |
+
result = fn(question, options, code)
|
| 677 |
+
LAST_ANSWER_OPS.clear()
|
| 678 |
+
LAST_ANSWER_OPS.update(OP_COUNTS)
|
| 679 |
+
LAST_ANSWER_OPS["total"] = sum(OP_COUNTS.values())
|
| 680 |
+
return result
|
| 681 |
|
| 682 |
|
| 683 |
# ==========================================================================================
|