MCPcopy
hub / github.com/Lightricks/ComfyUI-LTXVideo / execute

Method execute

sparse_tracks.py:112–139  ·  view source on GitHub ↗
(
        cls,
        image,
        points_store: str,
        coordinates: str,
        points_to_sample: int,
    )

Source from the content-addressed store, hash-verified

110
111 @classmethod
112 def execute(
113 cls,
114 image,
115 points_store: str,
116 coordinates: str,
117 points_to_sample: int,
118 ) -> io.NodeOutput:
119 # Re-interpolate from control points so that changes to
120 # points_to_sample are always respected, regardless of JS sync.
121 try:
122 splines = json.loads(points_store) if points_store else []
123 except (json.JSONDecodeError, TypeError):
124 splines = []
125
126 if splines and isinstance(splines, list) and isinstance(splines[0], list):
127 interpolated = [_interpolate_spline(sp, points_to_sample) for sp in splines]
128 tracks = json.dumps(interpolated)
129 elif coordinates and coordinates != "[]":
130 tracks = coordinates
131 else:
132 tracks = "[]"
133
134 img_array = (image[0].cpu().numpy() * 255).astype(np.uint8)
135 img = Image.fromarray(img_array)
136 buf = BytesIO()
137 img.save(buf, format="JPEG", quality=75)
138 img_b64 = base64.b64encode(buf.getvalue()).decode("utf-8")
139 return io.NodeOutput(tracks, ui={"bg_image": [img_b64]})
140
141
142def _parse_tracks(raw: str) -> list[list[dict]]:

Callers

nothing calls this directly

Calls 2

_interpolate_splineFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected