from pathlib import Path
import argparse,json,subprocess,sys
p=argparse.ArgumentParser();p.add_argument('--repo',required=True);a=p.parse_args();ROOT=Path(__file__).resolve().parent;repo=Path(a.repo).resolve()
assert (repo/'inference_realesrgan.py').is_file()
records=[]
for label,tile,pad in [('whole',0,10),('pad0',64,0),('pad16',64,16)]:
 target=ROOT/'output'/label;target.mkdir(parents=True,exist_ok=True)
 command=[sys.executable,'inference_realesrgan.py','-n','RealESRGAN_x4plus','-i',str(ROOT/'input.png'),'-o',str(target),'--outscale','4','--fp32','--tile',str(tile),'--tile_pad',str(pad),'--ext','png']
 subprocess.run(command,cwd=repo,check=True);records.append({'label':label,'command':command,'model_run':True})
(ROOT/'output/run.json').write_text(json.dumps(records,indent=2)+'\n')
