code wiki / (root) / nx_photoreal_critic_sota_fetch.nx

nx_photoreal_critic_sota_fetch.nx source

↩ module page · 72 lines · 4976 B

1// nx_photoreal_critic_sota_fetch.nx -- DEEP SOTA for the PHOTOREAL CRITIC (operator 2026-07-04: "you need a 2// HARD critic ... nishi researcher"; and the fresh lesson: real research = arXiv PAPERS + GitHub CODE + 3// papers-with-code LEADERBOARD, NOT wikipedia). Banks the actual image-quality-assessment / perceptual-metric 4// literature that a hard photoreal critic is built on: LPIPS + FID (perceptual/distributional), the IQA metric 5// catalogs (BRISQUE/NIQE/MUSIQ/MANIQA/CLIP-IQA = no-reference natural-scene-statistics), DISTS, and the PWC 6// leaderboards. Same sovereign stack as nx_voicegen_sota_fetch: own TLS-1.3, Mozilla CA, idempotent have-skip. 7// Saves knowledge/fetched/prc_*.raw. expect_exit: 0 license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_x509_trust_store.nx" 10import "nx_trust_store_load_from_certdata.nx" 11import "nx_https_fetch_follow.nx" 12const K_MAGIC_4194304: i64 = 4194304 13const K_MAGIC_8388608: i64 = 8388608 14 15func pc_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 16func pc_putn(v: i64) -> i64 { 17 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 18 var m: i64 = v 19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 20 let d: *u8 = sys_mmap(24); var k: i64 = 0 21 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 22 var j: i64 = k - 1 23 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 24 return 0 25} 26func have_file(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 27func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 28 if have_file(opath) == 1 { pc_puts(opath); pc_puts(" [have-skip]\n"); return 1 } 29 let status: *i64 = sys_mmap(8) as *i64 30 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status) 31 pc_puts(url); pc_puts(" status="); pc_putn(status[0]); pc_puts(" bytes="); pc_putn(n) 32 if n <= 0 { pc_puts(" FETCH-FAIL\n"); return 0 } 33 var gz: i64 = 0 34 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } } 35 if gz == 1 { pc_puts(" [GZIP-skip]\n"); return 0 } 36 let fd: i64 = sys_openat_wr(opath, 0x1a4) 37 if fd < 0 { pc_puts(" SAVE-FAIL\n"); return 0 } 38 sys_write(fd, out, n); sys_close(fd) 39 pc_puts(" SAVED\n") 40 return 1 41} 42 43func main() -> i64 { 44 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 45 if r <= 0 { pc_puts("PRC: certdata load failed\n"); return 1 } 46 let store: *TrustStore = r as *TrustStore 47 pc_puts("CA roots="); pc_putn(trust_store_count(store)); pc_puts("\n") 48 let cap: i64 = K_MAGIC_8388608 49 let out: *u8 = sys_mmap(cap) 50 var ok: i64 = 0 51 52 pc_puts("== arXiv PAPERS (the actual perceptual/quality metrics) ==\n") 53 ok = ok + fetch_save("https://arxiv.org/abs/1801.03924" as *u8, "knowledge/fetched/prc_lpips_paper.raw" as *u8, store, out, cap) // LPIPS perceptual metric 54 ok = ok + fetch_save("https://arxiv.org/abs/1706.08500" as *u8, "knowledge/fetched/prc_fid_paper.raw" as *u8, store, out, cap) // FID (TTUR) 55 ok = ok + fetch_save("https://arxiv.org/abs/2004.07728" as *u8, "knowledge/fetched/prc_dists_paper.raw" as *u8, store, out, cap) // DISTS (deep structure+texture) 56 ok = ok + fetch_save("https://arxiv.org/abs/2108.05997" as *u8, "knowledge/fetched/prc_musiq_paper.raw" as *u8, store, out, cap) // MUSIQ multi-scale IQA 57 ok = ok + fetch_save("https://arxiv.org/abs/2207.12396" as *u8, "knowledge/fetched/prc_clipiqa_paper.raw" as *u8, store, out, cap) // CLIP-IQA look&feel 58 59 pc_puts("== GitHub CODE (IQA metric CATALOGS -- the measured toolbox) ==\n") 60 ok = ok + fetch_save("https://raw.githubusercontent.com/chaofengc/IQA-PyTorch/main/README.md" as *u8, "knowledge/fetched/prc_iqapytorch_code.raw" as *u8, store, out, cap) 61 ok = ok + fetch_save("https://raw.githubusercontent.com/photosynthesis-team/piq/master/README.md" as *u8, "knowledge/fetched/prc_piq_code.raw" as *u8, store, out, cap) 62 ok = ok + fetch_save("https://raw.githubusercontent.com/richzhang/PerceptualSimilarity/master/README.md" as *u8, "knowledge/fetched/prc_lpips_code.raw" as *u8, store, out, cap) 63 64 pc_puts("== papers-with-code (the MEASURED IQA leaderboards) ==\n") 65 ok = ok + fetch_save("https://paperswithcode.com/task/no-reference-image-quality-assessment" as *u8, "knowledge/fetched/prc_pwc_nriqa.raw" as *u8, store, out, cap) 66 ok = ok + fetch_save("https://paperswithcode.com/task/image-quality-assessment" as *u8, "knowledge/fetched/prc_pwc_iqa.raw" as *u8, store, out, cap) 67 68 pc_puts("photoreal-critic SOTA: fetched/have="); pc_putn(ok); pc_puts(" / 10\n") 69 if ok >= 6 { pc_puts("verdict=GREEN (real IQA papers+code+leaderboard on disk; grep knowledge/fetched/prc_*.raw)\n"); sys_exit(0); return 0 } 70 pc_puts("verdict=PARTIAL (re-run to resume; some hosts may gzip/block -> note which)\n") 71 sys_exit(1); return 1 72}