wuhp commited on
Commit
0425447
·
verified ·
1 Parent(s): 7e2847c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -31,7 +31,14 @@ def convert_seg_to_bbox(api_key: str, dataset_url: str):
31
  ws, proj, ver = parse_roboflow_url(dataset_url)
32
  version_obj = rf.workspace(ws).project(proj).version(ver)
33
  dataset = version_obj.download("coco-segmentation")
34
- root = dataset.location # e.g. "/home/user/app/YourProject"
 
 
 
 
 
 
 
35
 
36
  # 2) search for any JSON file with "train" in its name
37
  ann_file = None
@@ -39,6 +46,7 @@ def convert_seg_to_bbox(api_key: str, dataset_url: str):
39
  for fname in filenames:
40
  if 'train' in fname.lower() and fname.lower().endswith('.json'):
41
  ann_file = os.path.join(dirpath, fname)
 
42
  break
43
  if ann_file:
44
  break
@@ -60,6 +68,7 @@ def convert_seg_to_bbox(api_key: str, dataset_url: str):
60
  lbl_out = os.path.join(out_root, "labels")
61
  os.makedirs(img_out, exist_ok=True)
62
  os.makedirs(lbl_out, exist_ok=True)
 
63
 
64
  # 6) convert each segmentation annotation to a YOLO bbox line
65
  annos = {}
@@ -85,6 +94,7 @@ def convert_seg_to_bbox(api_key: str, dataset_url: str):
85
  for dirpath, _, files in os.walk(root):
86
  if any(f.lower().endswith(('.jpg', '.png', '.jpeg')) for f in files):
87
  train_img_dir = dirpath
 
88
  break
89
  if train_img_dir is None:
90
  raise FileNotFoundError(f"No image files found under {root}")
 
31
  ws, proj, ver = parse_roboflow_url(dataset_url)
32
  version_obj = rf.workspace(ws).project(proj).version(ver)
33
  dataset = version_obj.download("coco-segmentation")
34
+ root = dataset.location # e.g. "/home/user/app/ds-2"
35
+
36
+ # --- DEBUG: print out the downloaded directory tree ---
37
+ print(f"Dataset downloaded to: {root}")
38
+ for dirpath, dirnames, filenames in os.walk(root):
39
+ print(f"\nDirectory: {dirpath}")
40
+ print(f" Subdirs: {dirnames}")
41
+ print(f" Files: {filenames}")
42
 
43
  # 2) search for any JSON file with "train" in its name
44
  ann_file = None
 
46
  for fname in filenames:
47
  if 'train' in fname.lower() and fname.lower().endswith('.json'):
48
  ann_file = os.path.join(dirpath, fname)
49
+ print(f"Found annotation file: {ann_file}")
50
  break
51
  if ann_file:
52
  break
 
68
  lbl_out = os.path.join(out_root, "labels")
69
  os.makedirs(img_out, exist_ok=True)
70
  os.makedirs(lbl_out, exist_ok=True)
71
+ print(f"Preparing YOLOv8 output in: {out_root}")
72
 
73
  # 6) convert each segmentation annotation to a YOLO bbox line
74
  annos = {}
 
94
  for dirpath, _, files in os.walk(root):
95
  if any(f.lower().endswith(('.jpg', '.png', '.jpeg')) for f in files):
96
  train_img_dir = dirpath
97
+ print(f"Found image directory: {train_img_dir}")
98
  break
99
  if train_img_dir is None:
100
  raise FileNotFoundError(f"No image files found under {root}")