Buckets:
| """Assemble an honest PyTorch package from an accepted semantic run.""" | |
| import argparse | |
| from copy import deepcopy | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| import shutil | |
| from training.model_factory import ROOT, CHECKPOINTS, configure_local_settings, public_mapping | |
| from training.segmentation_data import CANONICAL_IDS | |
| def digest(path):return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def main(): | |
| parser=argparse.ArgumentParser() | |
| parser.add_argument('--report',type=Path,required=True) | |
| parser.add_argument('--output',type=Path,default=ROOT/'model') | |
| args=parser.parse_args() | |
| output=args.output.resolve() | |
| if output != ROOT/'model' or (output/'model.json').exists(): | |
| raise ValueError('fresh project model package required') | |
| report=json.loads(args.report.read_text()) | |
| if report['status']!='PASSED' or report['kind']!='fine_tuning' or report['component']!='segmentation': | |
| raise ValueError('accepted semantic fine-tuning report required') | |
| checkpoint=Path(report['fit']['best_checkpoint']) | |
| if digest(checkpoint)!=report['checkpoint_sha256']: | |
| raise ValueError('selected checkpoint identity mismatch') | |
| configure_local_settings() | |
| import torch | |
| output.mkdir(exist_ok=True) | |
| checkpoints=output/'checkpoints';checkpoints.mkdir(exist_ok=False) | |
| detector=ROOT/'training/cache/checkpoints/yolo26n-obb.pt' | |
| assert digest(detector)==CHECKPOINTS[detector.name] | |
| shutil.copyfile(detector,checkpoints/'detector.pt') | |
| saved=torch.load(checkpoint,map_location='cpu',weights_only=False) | |
| module=deepcopy(saved['model']).float().cpu().eval() | |
| module.criterion=None | |
| torch.save({'model':module,'train_args':saved['train_args'], | |
| 'source_checkpoint_sha256':digest(checkpoint),'epoch':saved['epoch']},checkpoints/'segmenter.pt') | |
| baseline_path=ROOT/'evaluation/runs/2026-10-29-native1024/BASELINE_PRETRAINED.json' | |
| baseline=json.loads(baseline_path.read_text()) | |
| ontology=json.loads((ROOT/'datasets/ontology.json').read_text()) | |
| supported={1,2,3,4,5,6,7,8,12,13,14,15,16} | |
| config={'format_version':1,'name':'LongMemory-Geo','runtime':'pytorch-cpu', | |
| 'framework_version':'8.4.185','input':{'size':1024,'dtype':'uint8','layout':'HWC','color':'RGB'}, | |
| 'components':{ | |
| 'detection':{'path':'checkpoints/detector.pt','sha256':digest(checkpoints/'detector.pt'), | |
| 'source_class_mapping':public_mapping(torch.load(detector,map_location='cpu',weights_only=False)['model'].names,'detection'),'architecture':'YOLO26n-OBB','parameters':sum(p.numel() for p in torch.load(detector,map_location='cpu',weights_only=False)['model'].parameters()),'bytes':(checkpoints/'detector.pt').stat().st_size,'training_performed':False,'selection':'Pretrained retained because fine-tuning candidates regressed.'}, | |
| 'segmentation':{'path':'checkpoints/segmenter.pt','sha256':digest(checkpoints/'segmenter.pt'), | |
| 'architecture':'YOLO26n-sem','parameters':sum(p.numel() for p in module.parameters()),'bytes':(checkpoints/'segmenter.pt').stat().st_size,'training_performed':True,'source_checkpoint_sha256':digest(checkpoint), | |
| 'training_report_sha256':digest(args.report),'epoch':saved['epoch']}}, | |
| 'classes':{str(c['id']):c['name'] for c in ontology['classes'] if c['id'] in supported}, | |
| 'detection_class_ids':[3,4,5,6,7,8],'segmentation_class_ids':list(CANONICAL_IDS), | |
| 'unsupported_class_ids':[9,10,11],'ignore_id':255, | |
| 'detection_thresholds':baseline['calibration']['thresholds'], | |
| 'threshold_baseline_sha256':digest(baseline_path), | |
| 'tiling':{'size':1024,'overlap':.25,'nms_iou':.5,'fusion':'oriented_nms','semantic_stitch':'central_context'}, | |
| 'corpus_content_sha256':json.loads((ROOT/'datasets/corpus/stats.json').read_text())['validation_content_sha256'], | |
| 'fixed_manifest_sha256':digest(ROOT/'evaluation/quick_eval_manifest.json'), | |
| 'limitations':['Research package; DOTA source restrictions apply.','Detector is pretrained, not successfully fine-tuned.', | |
| 'Bare-ground recognition and bridge recall remain weaknesses.','Geographic independence is not fully established.', | |
| 'Tiled fusion has geometry tests; alternative fusion methods and multiscale are not benchmarked.', | |
| 'No independent external-imagery generalization claim.']} | |
| shutil.copyfile(ROOT/'training/requirements-model.lock',output/'requirements.lock') | |
| for name in ('ontology.json','SOURCES.json'):shutil.copyfile(ROOT/'datasets'/name,output/name) | |
| (output/'model.json').write_text(json.dumps(config,indent=2)) | |
| print(json.dumps({'package':str(output),'components':config['components']})) | |
| if __name__=='__main__':main() | |
Xet Storage Details
- Size:
- 4.78 kB
- Xet hash:
- 61dffed95c7054f6f2c102c48170255e8055076fa4923ea14ed541eac66bda39
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.