Skip to content

Commit 26aa525

Browse files
committed
Update prompt metadata generation
1 parent c3a64a2 commit 26aa525

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

meshroom/imageSegmentation/ImageSegmentationSam3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ def processChunk(self, chunk):
308308
metadata_deep_model = {}
309309
metadata_deep_model["Meshroom:mrSegmentation:DeepModelName"] = "SegmentAnything"
310310
metadata_deep_model["Meshroom:mrSegmentation:DeepModelVersion"] = "sam3"
311-
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = ""
312-
for textPrompt in textPrompts:
313-
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] += textPrompt + ";"
311+
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = ";".join(textPrompts)
314312

315313
detectedShapeBboxes = []
316314

meshroom/imageSegmentation/VideoSegmentationSam3.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,12 @@ def processChunk(self, chunk):
314314
negClickDictFromShape = self.getClickDictWithViewIdAsKeyFromShape(chunk.node.negativeClicks)
315315
posBboxDictFromShape = self.getBboxDictWithViewIdAsKeyFromShape(chunk.node.boxPrompt)
316316

317+
prompt = chunk.node.prompt.value.splitlines()[0]
318+
317319
metadata_deep_model = {}
318320
metadata_deep_model["Meshroom:mrSegmentation:DeepModelName"] = "SegmentAnything"
319321
metadata_deep_model["Meshroom:mrSegmentation:DeepModelVersion"] = "sam3-Video"
320-
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = chunk.node.prompt.value
322+
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = prompt
321323

322324
pil_images = []
323325
clicks = {}
@@ -415,7 +417,7 @@ def processChunk(self, chunk):
415417
type="add_prompt",
416418
session_id=session_id,
417419
frame_index=fIdx,
418-
text=chunk.node.prompt.value,
420+
text=prompt,
419421
)
420422
)
421423
outputs_per_frame_curr_fwd = self.propagate_in_video(video_predictor, session_id, fIdx, max_frame_num_to_track_fwd, "forward")
@@ -433,7 +435,7 @@ def processChunk(self, chunk):
433435
type="add_prompt",
434436
session_id=session_id,
435437
frame_index=fIdx,
436-
text=chunk.node.prompt.value,
438+
text=prompt,
437439
)
438440
)
439441
outputs_per_frame_curr_bwd = self.propagate_in_video(video_predictor, session_id, fIdx, max_frame_num_to_track_bwd, "backward")
@@ -456,7 +458,7 @@ def processChunk(self, chunk):
456458

457459
if len(masks.keys()) > 0:
458460
colorPalette.generate_palette(max(masks.keys()) + 1)
459-
cryptoName = "object" if chunk.node.prompt.value == "" else chunk.node.prompt.value
461+
cryptoName = "object" if prompt == "" else prompt
460462
for key, mask in masks.items():
461463
maskImage[mask] = [255, 255, 255]
462464
color = colorPalette.at(int(key)) if colorPalette.at(int(key)) is not None else [255, 255, 255]

meshroom/imageSegmentation/VideoSegmentationSam3Text.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,8 @@ def processChunk(self, chunk):
432432

433433
image.writeCryptomatte(cryptomattePath, cryptoName, img.shape[1], img.shape[0], manifest_bwd, crypto_id_bwd, crypto_cov_bwd)
434434

435-
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = ""
436-
for textPrompt in self.textPrompts:
437-
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] += textPrompt + ";"
435+
prompts = [textPrompt.strip() for textPrompt in self.textPrompts if textPrompt.strip()]
436+
metadata_deep_model["Meshroom:mrSegmentation:Prompt"] = ";".join(prompts)
438437

439438
for frameId in range(frameNumber):
440439
if chunk.node.maskInvert.value:

0 commit comments

Comments
 (0)