Datasets:
Download code/robohome/src/tools/asset_curation/decide.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 2.67 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/asset_curation/decide.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/tools/asset_curation/decide.py
-
curl -L -o decide.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/asset_curation/decide.py
2.67 kB
| import curation_paths as paths | |
| import csv,json,sqlite3,collections as C | |
| R=paths.R; W=paths.W | |
| B=paths.B+"/semantics/objects.csv" | |
| rows={r["id"]:r for r in csv.DictReader(open(B))} | |
| db=sqlite3.connect("file:"+paths.L+"/full_matrix_reviewed_compatibility_v7.sqlite3?mode=ro",uri=True) | |
| def vec(s): | |
| try: v=[float(x) for x in s.split(",")]; return v if len(v)==3 else None | |
| except Exception: return None | |
| def derive(m,up,fr): | |
| R3=[[m[0],m[1],m[2]],[m[4],m[5],m[6]],[m[8],m[9],m[10]]]; rot=lambda v:[sum(R3[i][j]*v[j] for j in range(3)) for i in range(3)] | |
| u,f=rot(up),rot(fr) | |
| if u[2]<.98 or abs(f[2])>.1: return None | |
| i=0 if abs(f[0])>=abs(f[1]) else 1 | |
| return ("+" if f[i]>0 else "-")+"XY"[i] if abs(f[i])>=.9 else None | |
| fix=set(json.load(open(W+"/release_pose/publication.json"))["fix"]) | |
| SYM={'rug','coffee_table','dining_table','side_table','stool','plant','table_lamp','floor_lamp','lamp','ceiling_light','decorative_object','cushion','bowl','plate','cup','bottle','book','clock','picture','basket','box','vase'} | |
| art={r[0]:(r[1],r[2],r[3]) for r in db.execute("select asset_id,front_axis,urdf_agreement,min_vote_share from static_front_from_articulation")} | |
| vlm={p["asset_id"]:p for p in json.load(open(W+"/out/proposals_v2.json"))} | |
| dec={};st=C.Counter();confl=[] | |
| for aid,cat,src,rj in db.execute("select asset_id,normalized_category,source,record_json from assets where asset_kind='OBJECT'"): | |
| rec=json.loads(rj); m=rec.get("canonical_transform"); c=a=v=None; crow=None | |
| if aid.startswith("hssd:objects/") and m: | |
| r=rows.get(aid.split("/")[-1]); up,fr=(vec(r["up"]),vec(r["front"])) if r else (None,None) | |
| if up and fr: | |
| c=derive(m,up,fr) | |
| if c: crow=dict(row_id=r["id"],up=up,front=fr,name=r["name"][:80]) | |
| if aid in art and art[aid][1]>=1.0 and art[aid][2]>=.8 and aid not in fix: a=art[aid][0] | |
| p=vlm.get(aid) | |
| if p and p["grade"]=="strong" and p["frame_ok"] and not p["render_unreliable"] and p["axis"] in("+X","-X","+Y","-Y") and src.lower()=="hssd" and cat not in SYM and p["zeros"]==0 and aid not in fix: v=p["axis"] | |
| if c and a and c!=a: st["conflict_csv_vs_articulation"]+=1; confl.append(aid); continue | |
| if c: dec[aid]=dict(source="csv",axis=c,csv=crow,other=dict(art=a,vlm=v)); st["csv"]+=1; st["csv_vlm_disagree"]+=bool(v and v!=c) | |
| elif a: dec[aid]=dict(source="art",axis=a); st["art"]+=1 | |
| elif v: dec[aid]=dict(source="vlm",axis=v); st["vlm"]+=1 | |
| print(dict(st)); print("axis by source:",{s:dict(C.Counter(d["axis"] for d in dec.values() if d["source"]==s)) for s in("csv","art","vlm")}) | |
| json.dump(dict(decisions=dec,conflicts=confl),open(W+"/out/front_decisions.json","w")) | |