Ayesha-Majeed commited on
Commit
fcce079
Β·
verified Β·
1 Parent(s): ffe6aa0

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -39,12 +39,13 @@ def prepare_clean_examples(src_folder, prefix, limit=10):
39
  src_path = os.path.join(root, fname)
40
  dst_name = f"{prefix}_{count}.jpg"
41
  try:
42
- img = Image.open(src_path).convert('RGB')
43
- img.save(dst_name, "JPEG", quality=90)
44
  results.append(dst_name)
45
  count += 1
46
  if count >= limit: break
47
- except: pass
 
48
  if count >= limit: break
49
  return results
50
 
@@ -108,14 +109,8 @@ def draw_boxes(img_rgb, boxes, labels, color=(0, 215, 255)):
108
  # Bottom-Right
109
  cv2.line(out, (x2, y2), (x2 - length, y2), color, thick, cv2.LINE_AA)
110
  cv2.line(out, (x2, y2), (x2, y2 - length), color, thick, cv2.LINE_AA)
111
-
112
- # Sleek Floating Badge for text (Tesla/Palantir UI style)
113
- (w, h), _ = cv2.getTextSize(label, cv2.FONT_HERSHEY_DUPLEX, 0.5, 1)
114
- cv2.rectangle(out, (x1, max(y1 - 32, 0)), (x1 + w + 16, max(y1 - 32, 0) + h + 12), color, -1)
115
 
116
- # Black text on Cyan badge gives a very premium, high-contrast look
117
- cv2.putText(out, label, (x1 + 8, max(y1 - 32, 0) + h + 8),
118
- cv2.FONT_HERSHEY_DUPLEX, 0.5, (0, 0, 0), 1, cv2.LINE_AA)
119
  return out
120
 
121
  # ═══════════════════════════════════════════════════════════════════════════════
 
39
  src_path = os.path.join(root, fname)
40
  dst_name = f"{prefix}_{count}.jpg"
41
  try:
42
+ import shutil
43
+ shutil.copy2(src_path, dst_name)
44
  results.append(dst_name)
45
  count += 1
46
  if count >= limit: break
47
+ except Exception as e:
48
+ print(f"Error copying {src_path}: {e}")
49
  if count >= limit: break
50
  return results
51
 
 
109
  # Bottom-Right
110
  cv2.line(out, (x2, y2), (x2 - length, y2), color, thick, cv2.LINE_AA)
111
  cv2.line(out, (x2, y2), (x2, y2 - length), color, thick, cv2.LINE_AA)
 
 
 
 
112
 
113
+ # Text labels have been removed to prevent obstructing the view of the segmentation masks.
 
 
114
  return out
115
 
116
  # ═══════════════════════════════════════════════════════════════════════════════