Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
{
|
||||
"0": {"isthing": 0, "name": "wall"},
|
||||
"1": {"isthing": 0, "name": "building"},
|
||||
"2": {"isthing": 0, "name": "sky"},
|
||||
"3": {"isthing": 0, "name": "floor"},
|
||||
"4": {"isthing": 0, "name": "tree"},
|
||||
"5": {"isthing": 0, "name": "ceiling"},
|
||||
"6": {"isthing": 0, "name": "road, route"},
|
||||
"7": {"isthing": 1, "name": "bed"},
|
||||
"8": {"isthing": 1, "name": "window "},
|
||||
"9": {"isthing": 0, "name": "grass"},
|
||||
"10": {"isthing": 1, "name": "cabinet"},
|
||||
"11": {"isthing": 0, "name": "sidewalk, pavement"},
|
||||
"12": {"isthing": 1, "name": "person"},
|
||||
"13": {"isthing": 0, "name": "earth, ground"},
|
||||
"14": {"isthing": 1, "name": "door"},
|
||||
"15": {"isthing": 1, "name": "table"},
|
||||
"16": {"isthing": 0, "name": "mountain, mount"},
|
||||
"17": {"isthing": 0, "name": "plant"},
|
||||
"18": {"isthing": 1, "name": "curtain"},
|
||||
"19": {"isthing": 1, "name": "chair"},
|
||||
"20": {"isthing": 1, "name": "car"},
|
||||
"21": {"isthing": 0, "name": "water"},
|
||||
"22": {"isthing": 1, "name": "painting, picture"},
|
||||
"23": {"isthing": 1, "name": "sofa"},
|
||||
"24": {"isthing": 1, "name": "shelf"},
|
||||
"25": {"isthing": 0, "name": "house"},
|
||||
"26": {"isthing": 0, "name": "sea"},
|
||||
"27": {"isthing": 1, "name": "mirror"},
|
||||
"28": {"isthing": 0, "name": "rug"},
|
||||
"29": {"isthing": 0, "name": "field"},
|
||||
"30": {"isthing": 1, "name": "armchair"},
|
||||
"31": {"isthing": 1, "name": "seat"},
|
||||
"32": {"isthing": 1, "name": "fence"},
|
||||
"33": {"isthing": 1, "name": "desk"},
|
||||
"34": {"isthing": 0, "name": "rock, stone"},
|
||||
"35": {"isthing": 1, "name": "wardrobe, closet, press"},
|
||||
"36": {"isthing": 1, "name": "lamp"},
|
||||
"37": {"isthing": 1, "name": "tub"},
|
||||
"38": {"isthing": 1, "name": "rail"},
|
||||
"39": {"isthing": 1, "name": "cushion"},
|
||||
"40": {"isthing": 0, "name": "base, pedestal, stand"},
|
||||
"41": {"isthing": 1, "name": "box"},
|
||||
"42": {"isthing": 1, "name": "column, pillar"},
|
||||
"43": {"isthing": 1, "name": "signboard, sign"},
|
||||
"44": {"isthing": 1, "name": "chest of drawers, chest, bureau, dresser"},
|
||||
"45": {"isthing": 1, "name": "counter"},
|
||||
"46": {"isthing": 0, "name": "sand"},
|
||||
"47": {"isthing": 1, "name": "sink"},
|
||||
"48": {"isthing": 0, "name": "skyscraper"},
|
||||
"49": {"isthing": 1, "name": "fireplace"},
|
||||
"50": {"isthing": 1, "name": "refrigerator, icebox"},
|
||||
"51": {"isthing": 0, "name": "grandstand, covered stand"},
|
||||
"52": {"isthing": 0, "name": "path"},
|
||||
"53": {"isthing": 1, "name": "stairs"},
|
||||
"54": {"isthing": 0, "name": "runway"},
|
||||
"55": {"isthing": 1, "name": "case, display case, showcase, vitrine"},
|
||||
"56": {"isthing": 1, "name": "pool table, billiard table, snooker table"},
|
||||
"57": {"isthing": 1, "name": "pillow"},
|
||||
"58": {"isthing": 1, "name": "screen door, screen"},
|
||||
"59": {"isthing": 0, "name": "stairway, staircase"},
|
||||
"60": {"isthing": 0, "name": "river"},
|
||||
"61": {"isthing": 0, "name": "bridge, span"},
|
||||
"62": {"isthing": 1, "name": "bookcase"},
|
||||
"63": {"isthing": 0, "name": "blind, screen"},
|
||||
"64": {"isthing": 1, "name": "coffee table"},
|
||||
"65": {"isthing": 1, "name": "toilet, can, commode, crapper, pot, potty, stool, throne"},
|
||||
"66": {"isthing": 1, "name": "flower"},
|
||||
"67": {"isthing": 1, "name": "book"},
|
||||
"68": {"isthing": 0, "name": "hill"},
|
||||
"69": {"isthing": 1, "name": "bench"},
|
||||
"70": {"isthing": 1, "name": "countertop"},
|
||||
"71": {"isthing": 1, "name": "stove"},
|
||||
"72": {"isthing": 1, "name": "palm, palm tree"},
|
||||
"73": {"isthing": 1, "name": "kitchen island"},
|
||||
"74": {"isthing": 1, "name": "computer"},
|
||||
"75": {"isthing": 1, "name": "swivel chair"},
|
||||
"76": {"isthing": 1, "name": "boat"},
|
||||
"77": {"isthing": 0, "name": "bar"},
|
||||
"78": {"isthing": 1, "name": "arcade machine"},
|
||||
"79": {"isthing": 0, "name": "hovel, hut, hutch, shack, shanty"},
|
||||
"80": {"isthing": 1, "name": "bus"},
|
||||
"81": {"isthing": 1, "name": "towel"},
|
||||
"82": {"isthing": 1, "name": "light"},
|
||||
"83": {"isthing": 1, "name": "truck"},
|
||||
"84": {"isthing": 0, "name": "tower"},
|
||||
"85": {"isthing": 1, "name": "chandelier"},
|
||||
"86": {"isthing": 1, "name": "awning, sunshade, sunblind"},
|
||||
"87": {"isthing": 1, "name": "street lamp"},
|
||||
"88": {"isthing": 1, "name": "booth"},
|
||||
"89": {"isthing": 1, "name": "tv"},
|
||||
"90": {"isthing": 1, "name": "plane"},
|
||||
"91": {"isthing": 0, "name": "dirt track"},
|
||||
"92": {"isthing": 1, "name": "clothes"},
|
||||
"93": {"isthing": 1, "name": "pole"},
|
||||
"94": {"isthing": 0, "name": "land, ground, soil"},
|
||||
"95": {"isthing": 1, "name": "bannister, banister, balustrade, balusters, handrail"},
|
||||
"96": {"isthing": 0, "name": "escalator, moving staircase, moving stairway"},
|
||||
"97": {"isthing": 1, "name": "ottoman, pouf, pouffe, puff, hassock"},
|
||||
"98": {"isthing": 1, "name": "bottle"},
|
||||
"99": {"isthing": 0, "name": "buffet, counter, sideboard"},
|
||||
"100": {"isthing": 0, "name": "poster, posting, placard, notice, bill, card"},
|
||||
"101": {"isthing": 0, "name": "stage"},
|
||||
"102": {"isthing": 1, "name": "van"},
|
||||
"103": {"isthing": 1, "name": "ship"},
|
||||
"104": {"isthing": 1, "name": "fountain"},
|
||||
"105": {"isthing": 0, "name": "conveyer belt, conveyor belt, conveyer, conveyor, transporter"},
|
||||
"106": {"isthing": 0, "name": "canopy"},
|
||||
"107": {"isthing": 1, "name": "washer, automatic washer, washing machine"},
|
||||
"108": {"isthing": 1, "name": "plaything, toy"},
|
||||
"109": {"isthing": 0, "name": "pool"},
|
||||
"110": {"isthing": 1, "name": "stool"},
|
||||
"111": {"isthing": 1, "name": "barrel, cask"},
|
||||
"112": {"isthing": 1, "name": "basket, handbasket"},
|
||||
"113": {"isthing": 0, "name": "falls"},
|
||||
"114": {"isthing": 0, "name": "tent"},
|
||||
"115": {"isthing": 1, "name": "bag"},
|
||||
"116": {"isthing": 1, "name": "minibike, motorbike"},
|
||||
"117": {"isthing": 0, "name": "cradle"},
|
||||
"118": {"isthing": 1, "name": "oven"},
|
||||
"119": {"isthing": 1, "name": "ball"},
|
||||
"120": {"isthing": 1, "name": "food, solid food"},
|
||||
"121": {"isthing": 1, "name": "step, stair"},
|
||||
"122": {"isthing": 0, "name": "tank, storage tank"},
|
||||
"123": {"isthing": 1, "name": "trade name"},
|
||||
"124": {"isthing": 1, "name": "microwave"},
|
||||
"125": {"isthing": 1, "name": "pot"},
|
||||
"126": {"isthing": 1, "name": "animal"},
|
||||
"127": {"isthing": 1, "name": "bicycle"},
|
||||
"128": {"isthing": 0, "name": "lake"},
|
||||
"129": {"isthing": 1, "name": "dishwasher"},
|
||||
"130": {"isthing": 1, "name": "screen"},
|
||||
"131": {"isthing": 0, "name": "blanket, cover"},
|
||||
"132": {"isthing": 1, "name": "sculpture"},
|
||||
"133": {"isthing": 1, "name": "hood, exhaust hood"},
|
||||
"134": {"isthing": 1, "name": "sconce"},
|
||||
"135": {"isthing": 1, "name": "vase"},
|
||||
"136": {"isthing": 1, "name": "traffic light"},
|
||||
"137": {"isthing": 1, "name": "tray"},
|
||||
"138": {"isthing": 1, "name": "trash can"},
|
||||
"139": {"isthing": 1, "name": "fan"},
|
||||
"140": {"isthing": 0, "name": "pier"},
|
||||
"141": {"isthing": 0, "name": "crt screen"},
|
||||
"142": {"isthing": 1, "name": "plate"},
|
||||
"143": {"isthing": 1, "name": "monitor"},
|
||||
"144": {"isthing": 1, "name": "bulletin board"},
|
||||
"145": {"isthing": 0, "name": "shower"},
|
||||
"146": {"isthing": 1, "name": "radiator"},
|
||||
"147": {"isthing": 1, "name": "glass, drinking glass"},
|
||||
"148": {"isthing": 1, "name": "clock"},
|
||||
"149": {"isthing": 1, "name": "flag"}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"url": "https://huggingface.co/datasets/shi-labs/oneformer_demo/resolve/4d683bd5bf84e9c8b5537dce306230bde409fe89/ade20k_panoptic.json",
|
||||
"sha256": "9d47d3bf5cedeefee0a41888b069bde254bf614f738ae43e4b423d1b2f321427"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"repository": "shi-labs/oneformer_ade20k_swin_large",
|
||||
"revision": "4a5bac8e64f82681a12db2e151a4c2f4ce6092b2",
|
||||
"asset_directory": "oneformer-ade20k",
|
||||
"qualification_only": true,
|
||||
"files": {
|
||||
"config.json": "27452b656a467dbdebdf879dc413d6f3facd2bfe3643824ae66c32c22884b4bd",
|
||||
"preprocessor_config.json": "49e2c8f207405d063cf7824f97c2814fa864f8f19ea9e02c9e20a9ff539c6d49",
|
||||
"tokenizer_config.json": "968a6126200b3c8f68fe955d61da20f3537e641a1deb538dc39fdad142248d72",
|
||||
"special_tokens_map.json": "c4864a9376a8401918425bed71fc14fc0e81f9b59ec45c1cf96cccb2df508eac",
|
||||
"vocab.json": "e089ad92ba36837a0d31433e555c8f45fe601ab5c221d4f607ded32d9f7a4349",
|
||||
"merges.txt": "9fd691f7c8039210e0fced15865466c65820d09b63988b0174bfe25de299051a",
|
||||
"README.md": "987c2f143f6f899d037e24d0110630fbc6eba57ab73b6e0d8c83868597b4c348",
|
||||
"pytorch_model.bin": "c0b2fe11dfecee6f2f1f315f466946e96f4e94813f3f6d660ff3747b83c28cc9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Prepare only the pinned optional research model; no host packages or services."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def sha(path):
|
||||
with path.open("rb") as stream:
|
||||
return hashlib.file_digest(stream, "sha256").hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, default=Path("D:/NDC_MISSIONCORE/runtime/simulation"))
|
||||
args = parser.parse_args()
|
||||
descriptor = json.loads(Path(__file__).with_name("model.json").read_text())
|
||||
output = args.root / "assets" / descriptor["asset_directory"] / descriptor["revision"]
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for name, expected in descriptor["files"].items():
|
||||
path = output / name
|
||||
if not path.exists():
|
||||
part = path.with_name(name + f".{os.getpid()}.part")
|
||||
url = f'https://huggingface.co/{descriptor["repository"]}/resolve/{descriptor["revision"]}/{name}'
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=60) as response, part.open("xb") as stream:
|
||||
while chunk := response.read(1024 * 1024):
|
||||
stream.write(chunk)
|
||||
if sha(part) != expected:
|
||||
raise ValueError("Downloaded model checksum mismatch: " + name)
|
||||
part.replace(path)
|
||||
finally:
|
||||
part.unlink(missing_ok=True)
|
||||
if sha(path) != expected:
|
||||
raise ValueError("Existing model checksum mismatch: " + name)
|
||||
receipt = dict(schema_version="missioncore.optional-model-preparation/v1",
|
||||
descriptor=descriptor, utc=datetime.now(UTC).isoformat(),
|
||||
assets=str(output), scope="offline simulation qualification",
|
||||
rollback="Remove this optional qualification asset; no active model was changed")
|
||||
(output / "installation.json").write_text(json.dumps(receipt, indent=2))
|
||||
print(json.dumps(receipt))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Pinned OneFormer comparison on recorded views; no rover commands."""
|
||||
import hashlib
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
from transformers import CLIPTokenizer, OneFormerConfig, OneFormerForUniversalSegmentation, OneFormerProcessor, OneFormerImageProcessor
|
||||
|
||||
|
||||
def sha(path):
|
||||
digest = hashlib.sha256()
|
||||
with path.open('rb') as stream:
|
||||
for chunk in iter(lambda: stream.read(1024*1024), b''):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
torch.set_num_threads(3)
|
||||
assets = Path('/assets')
|
||||
descriptor = json.loads(Path('/adapter/model.json').read_text())
|
||||
for name, expected in descriptor['files'].items():
|
||||
assert sha(assets/name) == expected, name
|
||||
metadata = json.loads(Path('/adapter/metadata-source.json').read_text())
|
||||
assert sha(Path('/adapter/ade20k_panoptic.json')) == metadata['sha256']
|
||||
config = json.loads((assets/'preprocessor_config.json').read_text())
|
||||
config['repo_path'] = '/adapter'
|
||||
processor = OneFormerProcessor(image_processor=OneFormerImageProcessor(**config),
|
||||
tokenizer=CLIPTokenizer.from_pretrained(assets, local_files_only=True))
|
||||
model = OneFormerForUniversalSegmentation(OneFormerConfig.from_pretrained(assets, local_files_only=True))
|
||||
state = torch.load(assets/'pytorch_model.bin', weights_only=True, map_location='cpu')
|
||||
model.load_state_dict(state, strict=True)
|
||||
del state
|
||||
model.cuda().eval()
|
||||
rows=[]
|
||||
output=Path('/evidence')
|
||||
for source in json.loads(Path('/inputs/manifest.json').read_text()):
|
||||
path=Path('/inputs')/source['file']
|
||||
assert sha(path)==source['sha256']
|
||||
original=Image.open(path).convert('RGB')
|
||||
for crop in (True,False):
|
||||
side=min(original.size);x=(original.width-side)//2;y=(original.height-side)//2
|
||||
image=original.crop((x,y,x+side,y+side)) if crop else original
|
||||
inputs=processor(images=image,task_inputs=['semantic'],return_tensors='pt').to('cuda')
|
||||
torch.cuda.synchronize();begin=time.monotonic()
|
||||
with torch.inference_mode():
|
||||
prediction=model(**inputs)
|
||||
labels=processor.post_process_semantic_segmentation(prediction,target_sizes=[(image.height,image.width)])[0].cpu().numpy().astype(np.uint8)
|
||||
torch.cuda.synchronize();elapsed=time.monotonic()-begin
|
||||
name=path.stem+('-crop' if crop else '-full')
|
||||
Image.fromarray(labels).save(output/(name+'.labels.png'))
|
||||
colors=np.zeros((*labels.shape,3),dtype=np.uint8)
|
||||
colors[np.isin(labels,(11,52))]=[20,220,170];colors[labels==6]=[220,40,50]
|
||||
Image.blend(image,Image.fromarray(colors),.45).save(output/(name+'.jpg'))
|
||||
ids,counts=np.unique(labels,return_counts=True)
|
||||
row=dict(case=name,source=source,utc=datetime.now(timezone.utc).isoformat(),monotonic=time.monotonic(),inference_seconds=elapsed,
|
||||
sidewalk_fraction=float(np.isin(labels,(11,52)).mean()),road_fraction=float((labels==6).mean()),
|
||||
classes={model.config.id2label[int(i)]:int(n) for i,n in zip(ids,counts)})
|
||||
rows.append(row);(output/'results.json').write_text(json.dumps(rows,indent=2))
|
||||
print(json.dumps(row),flush=True)
|
||||
(output/'artifact-sha256.json').write_text(json.dumps({p.name:sha(p) for p in output.iterdir() if p.is_file()},indent=2))
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
@@ -0,0 +1,57 @@
|
||||
"""One offline GPU job under a Core simulation reservation, with exact cleanup."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--reservation", type=Path, required=True)
|
||||
parser.add_argument("--inputs", type=Path, required=True)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
parser.add_argument("--root", type=Path, default=Path("D:/NDC_MISSIONCORE/runtime/simulation"))
|
||||
args = parser.parse_args()
|
||||
receipt = json.loads(args.reservation.read_text())
|
||||
assert receipt["state"] == "reserved" and receipt["owner_id"].startswith("airun-")
|
||||
assert not (args.root / "state/active.json").exists(), "A rover run is active"
|
||||
assert 0 <= (datetime.now(UTC) - datetime.fromisoformat(receipt["utc"])).total_seconds() < 900
|
||||
adapter = Path(__file__).parent.resolve()
|
||||
descriptor = json.loads((adapter / "model.json").read_text())
|
||||
assets = args.root / "assets" / descriptor["asset_directory"] / descriptor["revision"]
|
||||
assert (assets / "installation.json").is_file()
|
||||
args.output.mkdir(parents=True, exist_ok=False)
|
||||
identity = None
|
||||
begin = time.monotonic()
|
||||
try:
|
||||
identity = subprocess.check_output([
|
||||
"docker", "run", "-d", "--name", "ndc-oneformer-qualification-" + receipt["owner_id"][-8:],
|
||||
"--gpus", "all", "--cpus", "3", "--memory", "6g",
|
||||
"--label", "com.nodedc.product=mission-core", "--label", "com.nodedc.stack=ai-polygon-qualification",
|
||||
"--label", "com.nodedc.role=qualification", "--label", "com.nodedc.managed-by=ai-polygon-qualification",
|
||||
"--mount", f"type=bind,source={adapter},target=/adapter,readonly",
|
||||
"--mount", f"type=bind,source={assets},target=/assets,readonly",
|
||||
"--mount", f"type=bind,source={args.inputs.resolve()},target=/inputs,readonly",
|
||||
"--mount", f"type=bind,source={args.output.resolve()},target=/evidence",
|
||||
"--entrypoint", "/opt/conda/envs/goose/bin/python",
|
||||
"sha256:f37681beb9feecee991e71a60a68259f15b56b168c939db3c3cb259c322e9536",
|
||||
"-B", "/adapter/qualify.py",
|
||||
], text=True).strip()
|
||||
result = subprocess.check_output(["docker", "wait", identity], timeout=240, text=True).strip()
|
||||
logs = subprocess.check_output(["docker", "logs", identity], stderr=subprocess.STDOUT, text=True)
|
||||
(args.output / "execution.log").write_text(logs)
|
||||
print(logs[-14000:])
|
||||
assert result == "0", "Model qualification failed: exit " + result
|
||||
finally:
|
||||
released = identity is None or subprocess.run(["docker", "rm", "-f", identity], capture_output=True).returncode == 0
|
||||
(args.output / "cleanup.json").write_text(json.dumps(dict(
|
||||
owner_id=receipt["owner_id"], released=released, utc=datetime.now(UTC).isoformat(),
|
||||
elapsed_seconds=time.monotonic() - begin)))
|
||||
assert released
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user