ssand commited on
Commit
24efc8e
·
verified ·
1 Parent(s): a4593c3

Updated training file

Browse files
Files changed (1) hide show
  1. train.py +16 -11
train.py CHANGED
@@ -16,6 +16,10 @@ import os
16
  from pathlib import Path
17
  from ultralytics import YOLO
18
 
 
 
 
 
19
  def count_images(directory):
20
  """Count the number of JPG image files in a directory.
21
 
@@ -36,23 +40,22 @@ def count_images(directory):
36
  return count
37
 
38
 
39
- def find_dataset_yaml(current_dir):
40
- """Find data.yml file in dataset directories.
41
 
42
  Args:
43
  current_dir: Current directory to search from.
 
44
 
45
  Returns:
46
  Path to the data.yml file or None if not found.
47
  """
48
- datasets = ["veridis", "beet_augmented", "beet", "corn_augmented", "corn"]
 
49
 
50
- for dataset_name in datasets:
51
- dataset_path = current_dir / dataset_name
52
- yaml_path = dataset_path / "data.yml"
53
- if yaml_path.exists():
54
- print(f"Found dataset: {dataset_name}")
55
- return str(yaml_path), dataset_path
56
 
57
  return None, None
58
 
@@ -66,10 +69,12 @@ def main():
66
  current_dir = Path(__file__).parent
67
  os.chdir(current_dir)
68
 
69
- yaml_path, dataset_root = find_dataset_yaml(current_dir)
 
70
 
71
  if yaml_path is None:
72
- print("ERROR: No dataset with data.yml found")
 
73
  return
74
 
75
  train_images = count_images(dataset_root / "train" / "images")
 
16
  from pathlib import Path
17
  from ultralytics import YOLO
18
 
19
+
20
+ DATASET_NAME = "veridis"
21
+
22
+
23
  def count_images(directory):
24
  """Count the number of JPG image files in a directory.
25
 
 
40
  return count
41
 
42
 
43
+ def find_dataset_yaml(current_dir, dataset_name):
44
+ """Find data.yml file in a specific dataset directory.
45
 
46
  Args:
47
  current_dir: Current directory to search from.
48
+ dataset_name: Specific dataset name to use.
49
 
50
  Returns:
51
  Path to the data.yml file or None if not found.
52
  """
53
+ dataset_path = current_dir / dataset_name
54
+ yaml_path = dataset_path / "data.yml"
55
 
56
+ if yaml_path.exists():
57
+ print(f"Found dataset: {dataset_name}")
58
+ return str(yaml_path), dataset_path
 
 
 
59
 
60
  return None, None
61
 
 
69
  current_dir = Path(__file__).parent
70
  os.chdir(current_dir)
71
 
72
+ print(f"Training dataset: {DATASET_NAME}")
73
+ yaml_path, dataset_root = find_dataset_yaml(current_dir, DATASET_NAME)
74
 
75
  if yaml_path is None:
76
+ print(f"ERROR: Dataset '{DATASET_NAME}' not found or missing data.yml")
77
+ print("\nAvailable datasets: veridis, beet_augmented, beet, corn_augmented, corn")
78
  return
79
 
80
  train_images = count_images(dataset_root / "train" / "images")