Spaces:
Paused
Paused
Download scripts/package_evidence.py from Mike0021/qwen-image: direct link, hf CLI and curl.
- Browser
- Download file 4.93 kB
-
https://huggingface.co/spaces/Mike0021/qwen-image/resolve/main/scripts/package_evidence.py
- Command line
-
hf download hf://spaces/Mike0021/qwen-image/scripts/package_evidence.py
-
curl -L -o package_evidence.py https://huggingface.co/spaces/Mike0021/qwen-image/resolve/main/scripts/package_evidence.py
4.93 kB
| #!/usr/bin/env python3 | |
| """Copy actual collected evidence, without caches, credentials or synthetic outputs.""" | |
| from pathlib import Path | |
| import csv | |
| import hashlib | |
| import json | |
| import re | |
| import shutil | |
| ROOT=Path(__file__).resolve().parents[1] | |
| source=ROOT/'artifacts';dest=ROOT/'evidence';dest.mkdir(exist_ok=True) | |
| selected=[] | |
| for section in ['benchmarks','ui','validation','deployment','logs']: | |
| for p in (source/section).rglob('*'): | |
| if not p.is_file() or 'downloads' in p.relative_to(source).parts:continue | |
| if p.suffix not in {'.png','.jpg','.svg','.json','.jsonl','.log'}:continue | |
| # This old harness overwrote its PNG download with a screenshot. The actual | |
| # model PNG was subsequently recovered and is retained separately. | |
| if p.relative_to(source).as_posix()=='ui/20260920T211136-edit/edited.png':continue | |
| if p.name=='api.json':continue | |
| if p.name.startswith('css-candidate-'):continue # Temporary browser CSS probes, not deployed acceptance captures. | |
| if p.suffix in {'.json','.jsonl','.log'}: | |
| body=p.read_text() | |
| if re.search(r'hf_[A-Za-z0-9]{20,}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+',body): | |
| raise SystemExit(f'Credential-shaped content requires inspection: {p.name}') | |
| target=dest/p.relative_to(source);target.parent.mkdir(parents=True,exist_ok=True) | |
| shutil.copyfile(p,target);selected.append(target) | |
| rows=[] | |
| for p in sorted((dest/'benchmarks').glob('*/results.jsonl')): | |
| for line in p.read_text().splitlines(): | |
| r=json.loads(line);q=r.get('recipe',{});m=q.get('metrics',{});c=q.get('parameters',{});g=m.get('gpu',{}) | |
| rows.append({'suite':p.parent.name,'trial':r.get('index',r.get('trial_index')),'status':r['status'], | |
| 'image':str((p.parent/r['image_file']).relative_to(dest)) if r.get('image_file') else '', | |
| 'prompt_index':r.get('trial',{}).get('prompt_index'), 'seed':c.get('seed'),'steps':c.get('steps'), | |
| 'resolution':c.get('resolution'),'aspect':c.get('aspect'),'reference':bool(q.get('reference_pixel_sha256')), | |
| 'kv_cache':c.get('use_kv_cache'),'vae_tiling':c.get('vae_tiling'),'gpu_size':g.get('size'), | |
| 'boot_id':q.get('boot_id'),'request_index':q.get('request_index_in_boot'), | |
| 'worker_call_index':m.get('gpu_worker_call_index'), | |
| 'inference_seconds':m.get('inference_seconds'),'gpu_call_wall_seconds':m.get('gpu_call_wall_seconds'), | |
| 'client_wall_seconds':r.get('client_wall_seconds'),'peak_allocated_bytes':g.get('peak_allocated_bytes'), | |
| 'pixel_sha256':r.get('pixel_sha256')}) | |
| with (dest/'measurements.csv').open('w',newline='') as f: | |
| writer=csv.DictWriter(f,fieldnames=list(rows[0]));writer.writeheader();writer.writerows(rows) | |
| selected.append(dest/'measurements.csv') | |
| (dest/'README.md').write_text('''# Live evaluation evidence | |
| These files came from the authenticated deployed Space. Original model PNGs | |
| are distinct from browser screenshots (`-screen.png`), labelled comparison | |
| contact sheets, and alpha-compositing diagnostics. Historical failures remain | |
| visible; a failed browser script does not imply its server generation failed. | |
| See the [acceptance report](../reports/acceptance.md) for exact qualifications. | |
| - [Measured benchmarks](../reports/benchmarks.md) and [quality review](../reports/quality-review.md). | |
| - [Machine-readable measurements](measurements.csv) and [SHA-256 file manifest](files.json). | |
| - [Actual 2K edited image](ui/20260920T214909-edit-desktop/edited.png) and [its recipe](ui/20260920T214909-edit-desktop/edited.json). | |
| - [Desktop view](ui/20260920T214909-edit-desktop/edited-screen.png) and [mobile view](ui/20260920T214909-edit-desktop/edited-mobile-screen.png). | |
| - [Actual mobile generation](ui/20260920T222159-generate-mobile/generated.png) and [screenshot](ui/20260920T222159-generate-mobile/generated-screen.png). | |
| - [Four studies, original generation and cache replay](ui/20260920T215943-examples-desktop). | |
| - [All five 1K shapes](benchmarks/20260920T220347-shapes). | |
| - [24-image step comparison](benchmarks/20260920T205217-steps) and [12 held-out images](benchmarks/20260920T210724-challenge). | |
| - [Startup and failure logs](logs), [input validation](validation), [deployment observations](deployment). | |
| No token, JWT, cookie, browser storage state or HAR is included. The two historical | |
| model failures have no generated image. Cached study copies share original IDs; | |
| do not count repeated downloads as independent generations. The source scripts | |
| write fresh evaluation results to `artifacts/` before packaging them here. | |
| ''') | |
| selected.append(dest/'README.md') | |
| manifest=[{'path':str(p.relative_to(dest)),'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in sorted(selected)] | |
| (dest/'files.json').write_text(json.dumps(manifest,indent=2)+'\n') | |
| print(json.dumps({'files':len(manifest),'bytes':sum(r['bytes'] for r in manifest),'api_trials':len(rows), | |
| 'api_successes':sum(r['status']=='ok' for r in rows),'api_failures':sum(r['status']!='ok' for r in rows)})) | |