feat: gate mask_from_stash (paint or zeros)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,3 +13,12 @@ MAX_ROUTES = 10
|
||||
|
||||
def route_tuple(chosen, image, blocker, max_routes=MAX_ROUTES):
|
||||
return tuple(image if i == chosen else blocker for i in range(max_routes))
|
||||
|
||||
|
||||
def mask_from_stash(data, image):
|
||||
b, h, w = image.shape[0], image.shape[1], image.shape[2]
|
||||
if not data:
|
||||
return torch.zeros((b, h, w), dtype=torch.float32)
|
||||
m = Image.open(io.BytesIO(data)).convert("L")
|
||||
arr = np.array(m, dtype=np.float32) / 255.0
|
||||
return torch.from_numpy(arr).unsqueeze(0)
|
||||
|
||||
Reference in New Issue
Block a user