Skip to content

Commit

Permalink
feat: update training script and config
Browse files Browse the repository at this point in the history
This now reflects what we actually used during training :^)
  • Loading branch information
beuss-git committed May 18, 2023
1 parent 1f63d2a commit dc1ea49
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 26 deletions.
31 changes: 15 additions & 16 deletions model_research/nina.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
path: C:\Users\benja\Documents\datasets\nina_yolo

path: path/to/dataset # change this

# These are relative to the path above
train: obj_train_data
val: obj_train_data
train: train.txt
val: val.txt
test:

nc: 9
names: [
"Gjedde",
"Gullbust",
"Rumpetroll",
"Stingsild",
"Ørekyt",
"Abbor",
"Brasme",
"Mort",
"Vederbuk"
]
names:
0: Gjedde
1: Gullbust
2: Rumpetroll
3: Stingsild
4: Ørekyt
5: Abbor
6: Brasme
7: Mort
8: Vederbuk
9: Frosk
10: "Annen Fisk"
45 changes: 35 additions & 10 deletions model_research/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,44 @@
# Use if you want to debug
# os.environ["CUDA_LAUNCH_BLOCKING"] = "1"

if __name__ == "__main__":
ultralytics.checks()

def train(resume: bool) -> None:
"""Train the model.
Args:
resume: If True, resume training from last checkpoint.
"""
# Initialize with starting weights
model = YOLO("yolov8s.pt")

# Train
model.train(
data="nina_new.yaml",
epochs=100,
resume=resume,
data="nina.yaml",
epochs=120,
val=True,
batch=16,
batch=8,
imgsz=640,
device=0,
half=True,
workers=8,
device=None,
close_mosaic=10,
lr0=0.001,
lrf=0.01,
weight_decay=0.001,
degrees=10,
scale=0.6,
perspective=0.0005,
flipud=0.01,
hsv_h=0.2,
hsv_s=0.7,
hsv_v=0.7,
v5loader=True,
) # train the model
workers=16,
)


if __name__ == "__main__":
# Perform checks
ultralytics.checks()

# model.val(data="brackish.yaml", batch_size=8) # test the model
# Start/resume training
train(resume=False)

0 comments on commit dc1ea49

Please sign in to comment.