Download scripts/demo_innovation.py from PureOne/AUREOLE-R-v3: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/PureOne/AUREOLE-R-v3/resolve/main/scripts/demo_innovation.py
- Command line
-
hf download hf://PureOne/AUREOLE-R-v3/scripts/demo_innovation.py
-
curl -L -o demo_innovation.py https://huggingface.co/PureOne/AUREOLE-R-v3/resolve/main/scripts/demo_innovation.py
2.66 kB
| """Small standalone demonstration of bounded persistent query work.""" | |
| from pathlib import Path | |
| import argparse,json,sys | |
| ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) | |
| import numpy as np | |
| from aureole.renderer import Scene,receiver_grid,light_grid,unoccluded | |
| from aureole.certificates import CertificateMemory,visibility_certificate | |
| from aureole.innovation import prepare,eliminate | |
| def run(output): | |
| out=ROOT/output;out.mkdir(parents=True,exist_ok=True) | |
| points=receiver_grid(24,32);lights=light_grid(6);scene=Scene.create(1001) | |
| memory=CertificateMemory(points,lights,scene.spheres,namespace='demo-1001') | |
| b=unoccluded(points,lights);ids=np.arange(len(points));rng=np.random.default_rng(63) | |
| frames=[];records=[] | |
| for frame in range(24): | |
| memory.begin_geometry(scene.spheres);values,known=memory.lookup(ids) | |
| h,q=prepare(b,np.full(values.shape,.5),values,known,np.linalg.norm(b,axis=-1)+1e-12) | |
| counter=[0] | |
| def oracle(rr,j): | |
| v,m=visibility_certificate(scene,points[rr],lights[j]);memory.commit(rr,j,v,m) | |
| counter[0]+=len(rr);return b[rr,j]*v[:,None] | |
| result,_=eliminate(h,q,oracle,2,rng) | |
| frames.append(result.reshape(24,32,3));records.append({'frame':frame,'physical_queries':counter[0],'known_fraction_before':float(known.mean())}) | |
| reference=(b*scene.visibility(points[:,None,:],lights[None,:,:])[...,None]).sum(1).reshape(24,32,3) | |
| memory.save(out/'memory.npz');np.savez_compressed(out/'linear_frames.npz',frames=np.array(frames),reference=reference) | |
| report={'frames':24,'physical_queries':sum(r['physical_queries'] for r in records),'full_domain_terms':len(points)*len(lights), | |
| 'zero_query_final_frames':sum(r['physical_queries']==0 for r in records), | |
| 'final_max_error':float(np.max(np.abs(frames[-1]-reference))), | |
| 'records':records,'scope':'Finite static-scene visibility completion with a constant prior; no GPU or full neural pipeline.'} | |
| (out/'demo.json').write_text(json.dumps(report,indent=2)+'\n') | |
| import matplotlib;matplotlib.use('Agg');import matplotlib.pyplot as plt | |
| fig,axes=plt.subplots(1,3,figsize=(9,3)) | |
| for ax,i in zip(axes,(0,8,23)): | |
| ax.imshow(np.clip(frames[i],0,1)**(1/2.2));ax.set_title(f'Frame {i+1}: {records[i]["physical_queries"]} queries');ax.axis('off') | |
| fig.tight_layout();fig.savefig(out/'preview.png',dpi=160);plt.close(fig) | |
| print(json.dumps({k:v for k,v in report.items() if k!='records'},indent=2)) | |
| if __name__=='__main__': | |
| p=argparse.ArgumentParser();p.add_argument('--output',default='innovation_demo');run(p.parse_args().output) | |