INNER CODE UNIT · Python
get_slot_embedding
GenielabsOpenSource/spine-animation-ai · reskin-app/app/backend/server.py:292
def get_slot_embedding(skin_name: str, slot: str):
"""Proxy to the SAM segmentation server's /image_segmentation route to
get an image embedding for the slot's raw image. The embedding lives
locally so the frontend can run mask decoding ONNX inference without
re-uploading the image each time.
Returns the embedding payload directly (the same JSON shape the SAM
server returns), with the embedding bytes in base64.
"""
import base64
import numpy as np
import requests
project = _State.require_project()
raw_path = project.workdir / "skins" / skin_name / "extracted_raw" / f"{slot}.png"
if not raw_path.exists():
legacy = project.workdir / "skins" / skin_name / "extracted" / f"{slot}.png"
if legacy.exists():