Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
param([string]$Root = 'D:\NDC_MISSIONCORE\runtime\simulation')
|
||||
$ErrorActionPreference='Stop'
|
||||
$ProgressPreference='SilentlyContinue'
|
||||
[Console]::OutputEncoding=[System.Text.Encoding]::UTF8
|
||||
$revision='d633b2072669ca68d8f8e309de9b52bfdbf6bf72'
|
||||
$out=Join-Path $Root ('assets\segformer-b2-cityscapes\'+$revision)
|
||||
New-Item -ItemType Directory -Force $out | Out-Null
|
||||
$files=@{
|
||||
'config.json'='3bafe3a84c87270732bb383f6ef33801d1cd441907da8cedc2c8a4986276945d'
|
||||
'preprocessor_config.json'='d96ab2cb112985c19d5ea32f1d1f2369104fc78b1379f5ce26e33ca8646202a7'
|
||||
'README.md'='dee0efc3c26c7f670a15fb47ea01e92c884f985304944db8b881f057bb31a81e'
|
||||
'pytorch_model.bin'='584d72ace8c17c5683c198e1a4c3eda2e1026bafc02711ac5e5a4dc097bd05fe'
|
||||
}
|
||||
foreach($name in $files.Keys) {
|
||||
$path=Join-Path $out $name
|
||||
if (!(Test-Path $path)) {
|
||||
$part=$path+'.part'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://huggingface.co/nvidia/segformer-b2-finetuned-cityscapes-1024-1024/resolve/$revision/$name" -OutFile $part
|
||||
if ((Get-FileHash $part -Algorithm SHA256).Hash.ToLower() -ne $files[$name]) { throw "Downloaded model checksum mismatch: $name" }
|
||||
Move-Item $part $path
|
||||
}
|
||||
if ((Get-FileHash $path -Algorithm SHA256).Hash.ToLower() -ne $files[$name]) { throw "Installed model checksum mismatch: $name" }
|
||||
}
|
||||
$receipt=@{schema_version='missioncore.ai-polygon-cityscapes-install/v1';revision=$revision;files=$files;assets=$out;installed_at=[DateTime]::UtcNow.ToString('o');scope='simulation evaluation';rollback='Remove this optional provider from composition; existing models preserved'}
|
||||
[IO.File]::WriteAllText((Join-Path $out 'installation.json'),($receipt|ConvertTo-Json -Depth 4),[Text.UTF8Encoding]::new($false))
|
||||
$receipt|ConvertTo-Json -Depth 4 -Compress
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"model_id": "segformer-b2-cityscapes19",
|
||||
"repository": "nvidia/segformer-b2-finetuned-cityscapes-1024-1024",
|
||||
"revision": "d633b2072669ca68d8f8e309de9b52bfdbf6bf72",
|
||||
"files": {
|
||||
"config.json": "3bafe3a84c87270732bb383f6ef33801d1cd441907da8cedc2c8a4986276945d",
|
||||
"preprocessor_config.json": "d96ab2cb112985c19d5ea32f1d1f2369104fc78b1379f5ce26e33ca8646202a7",
|
||||
"pytorch_model.bin": "584d72ace8c17c5683c198e1a4c3eda2e1026bafc02711ac5e5a4dc097bd05fe"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
"""Resident, pinned ADE20K surface provider. RGB only; no scene truth input."""
|
||||
"""Resident, pinned SegFormer surface providers. RGB only; no scene truth input."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
@@ -21,7 +22,11 @@ FILES = {
|
||||
|
||||
|
||||
def main():
|
||||
for name, expected in FILES.items():
|
||||
city = os.environ.get("MISSIONCORE_SEGFORMER_PROFILE", "ade") == "cityscapes"
|
||||
descriptor = json.loads(Path(__file__).with_name("cityscapes.json").read_text()) if city else None
|
||||
files = descriptor["files"] if city else FILES
|
||||
surfaces = (0, 1, 9) if city else SURFACES
|
||||
for name, expected in files.items():
|
||||
if hashlib.sha256((Path("/assets") / name).read_bytes()).hexdigest() != expected:
|
||||
raise RuntimeError("SegFormer asset identity changed: " + name)
|
||||
processor = SegformerImageProcessor.from_pretrained("/assets", local_files_only=True)
|
||||
@@ -42,8 +47,15 @@ def main():
|
||||
)
|
||||
confidence, labels = logits.softmax(1).max(1)
|
||||
labels = labels[0].cpu().numpy().astype(np.uint8)
|
||||
candidate = np.isin(labels, SURFACES) & (confidence[0].cpu().numpy() >= 0.55)
|
||||
return labels.tobytes() + candidate.astype(np.uint8).tobytes()
|
||||
known = confidence[0].cpu().numpy() >= 0.55
|
||||
candidate = np.isin(labels, surfaces) & known
|
||||
# The same confidence gate applies to permissions and exclusions.
|
||||
# Unknown is neither free ground nor a semantic barrier.
|
||||
return (
|
||||
labels.tobytes()
|
||||
+ candidate.astype(np.uint8).tobytes()
|
||||
+ known.astype(np.uint8).tobytes()
|
||||
)
|
||||
|
||||
infer(np.zeros((600, 800, 3), dtype=np.uint8))
|
||||
|
||||
@@ -62,7 +74,7 @@ def main():
|
||||
def do_GET(self):
|
||||
self.reply(
|
||||
200 if self.path == "/ready" else 404,
|
||||
json.dumps({"model": "segformer-b2-ade150"}).encode(),
|
||||
json.dumps({"model": "segformer-b2-cityscapes19" if city else "segformer-b2-ade150"}).encode(),
|
||||
)
|
||||
|
||||
def do_POST(self):
|
||||
|
||||
Reference in New Issue
Block a user