Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -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