Skip to content

Commit 10843d1

Browse files
vsc38511claude
andcommitted
Fix LangSAM API: pass lists instead of bare string to predict()
The updated LangSAM API expects predict([image], [text]) with lists. Passing a bare string caused it to iterate over characters (e.g. "bear" -> ["b","e","a","r"]), breaking mask prediction entirely. Also handles the new list[dict] return format and guards against empty mask results. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 31a758f commit 10843d1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

gaussctrl/gc_pipeline.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ def render_reverse(self):
148148
if self.config.langsam_obj != "":
149149
langsam_obj = self.config.langsam_obj
150150
langsam_rgb_pil = Image.fromarray((rendered_rgb.cpu().numpy() * 255).astype(np.uint8))
151-
masks, _, _, _ = self.langsam.predict(langsam_rgb_pil, langsam_obj)
152-
mask_npy = masks.clone().cpu().numpy()[0] * 1
151+
# The new LangSAM API expects lists; passing a bare string causes it to
152+
# iterate over characters (e.g. "bear" -> ["b","e","a","r"]), breaking batching.
153+
results = self.langsam.predict([langsam_rgb_pil], [langsam_obj])
154+
result_masks = results[0]["masks"] # new API returns list[dict]
155+
mask_npy = result_masks[0] * 1 if len(result_masks) > 0 else None
153156

154157
if self.config.langsam_obj != "":
155158
self.update_datasets(cam_idx, rendered_rgb.cpu(), rendered_depth, latent, mask_npy)

0 commit comments

Comments
 (0)