Zhen Ye commited on
Commit
882ee33
·
1 Parent(s): e9834ad

removed extra bbox lable and track id

Browse files
Files changed (1) hide show
  1. inference.py +4 -5
inference.py CHANGED
@@ -208,9 +208,9 @@ def draw_masks(
208
  label = None
209
  if labels and idx < len(labels):
210
  label = labels[idx]
211
- if not label:
212
- label = f"object_{idx}"
213
- color = _color_for_label(label)
214
  overlay[mask_bool] = color
215
  output = cv2.addWeighted(output, 1.0, overlay, alpha, 0)
216
  contours, _ = cv2.findContours(
@@ -218,6 +218,7 @@ def draw_masks(
218
  )
219
  if contours:
220
  cv2.drawContours(output, contours, -1, color, thickness=2)
 
221
  if label:
222
  coords = np.column_stack(np.where(mask_bool))
223
  if coords.size:
@@ -2214,8 +2215,6 @@ def run_grounded_sam2_tracking(
2214
  display_labels.append("")
2215
  continue
2216
  lbl = d.get("label", "obj")
2217
- if "track_id" in d:
2218
- lbl = f"{d['track_id']} {lbl}"
2219
  if d.get("gpt_distance_m") is not None:
2220
  try:
2221
  lbl = f"{lbl} {int(float(d['gpt_distance_m']))}m"
 
208
  label = None
209
  if labels and idx < len(labels):
210
  label = labels[idx]
211
+ # Use a fallback key for consistent color even when no label text
212
+ color_key = label if label else f"object_{idx}"
213
+ color = _color_for_label(color_key)
214
  overlay[mask_bool] = color
215
  output = cv2.addWeighted(output, 1.0, overlay, alpha, 0)
216
  contours, _ = cv2.findContours(
 
218
  )
219
  if contours:
220
  cv2.drawContours(output, contours, -1, color, thickness=2)
221
+ # Only draw label text when explicit labels were provided
222
  if label:
223
  coords = np.column_stack(np.where(mask_bool))
224
  if coords.size:
 
2215
  display_labels.append("")
2216
  continue
2217
  lbl = d.get("label", "obj")
 
 
2218
  if d.get("gpt_distance_m") is not None:
2219
  try:
2220
  lbl = f"{lbl} {int(float(d['gpt_distance_m']))}m"