-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from scaleoutsystems/feature/compute-package
Feature/compute package
- Loading branch information
Showing
37 changed files
with
395 additions
and
1,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Configuration for YOLOv8 Model and Dataset Paths | ||
# Adjust settings here to define model size, class details, and dataset paths | ||
|
||
model_size: nano # Options: nano, small, medium, large, x-large | ||
num_classes: 3 # Number of classes | ||
class_names: ['Class 1', 'Class 2', 'Class 3'] # A list of class names | ||
|
||
train: fed_dataset/train/images # Configure paths (usually not needed to be configured) | ||
val: fed_dataset/valid/images | ||
test: fed_dataset/test/images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import yaml | ||
import os | ||
|
||
# Load server configuration | ||
with open('client/global_config.yaml', 'r') as config_file: | ||
server_config = yaml.safe_load(config_file) | ||
|
||
# Extract configuration values | ||
model_size = server_config.get("model_size", "nano").lower() | ||
num_classes = server_config.get("num_classes", 1) | ||
class_names = server_config.get("class_names", [f"Class {i}" for i in range(num_classes)]) | ||
|
||
# Dataset paths from config | ||
train_path = server_config.get("train", "fed_dataset/train/images") | ||
val_path = server_config.get("val", "fed_dataset/valid/images") | ||
test_path = server_config.get("test", "fed_dataset/test/images") | ||
|
||
# Paths for model files | ||
model_folder = "client/yolov8models" | ||
model_file = os.path.join(model_folder, f"{model_size}.yaml") | ||
output_model_file = "client/model.yaml" | ||
output_data_file = "client/data.yaml" | ||
|
||
# Generate model.yaml with 'nc' on line 4 | ||
if not os.path.exists(model_file): | ||
print(f"Error: Model file '{model_file}' does not exist in '{model_folder}'.") | ||
else: | ||
# Read the model file content as a list of lines | ||
with open(model_file, 'r') as file: | ||
model_lines = file.readlines() | ||
|
||
# Insert the nc line at line 4 (index 3) | ||
model_lines.insert(3, f"nc: {num_classes} # Number of classes from global_config\n") | ||
|
||
# Write the modified content to the model.yaml file | ||
with open(output_model_file, 'w') as output_file: | ||
output_file.writelines(model_lines) | ||
|
||
print(f"'{output_model_file}' created successfully with nc: {num_classes} based on '{model_file}'") | ||
|
||
# Generate data.yaml with paths, nc, and names | ||
data_content = { | ||
"train": train_path, | ||
"val": val_path, | ||
"test": test_path, | ||
"nc": num_classes, | ||
"names": {i: class_name for i, class_name in enumerate(class_names)} | ||
} | ||
|
||
# Write the data.yaml content | ||
with open(output_data_file, 'w') as data_file: | ||
yaml.dump(data_content, data_file, sort_keys=False) | ||
|
||
print(f"'{output_data_file}' created successfully with paths from global_config.yaml, nc: {num_classes}, and indexed class names.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Ultralytics YOLO 🚀, AGPL-3.0 license | ||
# YOLOv8 object detection model with P3-P5 outputs, fixed to YOLOv8l scale | ||
|
||
|
||
# YOLOv8l backbone | ||
backbone: | ||
- [-1, 1, Conv, [64, 3, 2]] | ||
- [-1, 1, Conv, [128, 3, 2]] | ||
- [-1, 3, C2f, [128, True]] | ||
- [-1, 1, Conv, [256, 3, 2]] | ||
- [-1, 6, C2f, [256, True]] | ||
- [-1, 1, Conv, [384, 3, 2]] | ||
- [-1, 6, C2f, [384, True]] | ||
- [-1, 1, Conv, [512, 3, 2]] | ||
- [-1, 3, C2f, [512, True]] | ||
- [-1, 1, SPPF, [512, 5]] | ||
|
||
# YOLOv8l head | ||
head: | ||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 6], 1, Concat, [1]] | ||
- [-1, 3, C2f, [384]] | ||
|
||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 4], 1, Concat, [1]] | ||
- [-1, 3, C2f, [256]] | ||
|
||
- [-1, 1, Conv, [256, 3, 2]] | ||
- [[-1, 12], 1, Concat, [1]] | ||
- [-1, 3, C2f, [384]] | ||
|
||
- [-1, 1, Conv, [384, 3, 2]] | ||
- [[-1, 9], 1, Concat, [1]] | ||
- [-1, 3, C2f, [512]] | ||
|
||
- [[15, 18, 21], 1, Detect, [nc]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Ultralytics YOLO 🚀, AGPL-3.0 license | ||
# YOLOv8 object detection model with P3-P5 outputs, fixed to YOLOv8m scale | ||
|
||
|
||
# YOLOv8m backbone | ||
backbone: | ||
- [-1, 1, Conv, [48, 3, 2]] | ||
- [-1, 1, Conv, [96, 3, 2]] | ||
- [-1, 2, C2f, [96, True]] | ||
- [-1, 1, Conv, [192, 3, 2]] | ||
- [-1, 4, C2f, [192, True]] | ||
- [-1, 1, Conv, [384, 3, 2]] | ||
- [-1, 4, C2f, [384, True]] | ||
- [-1, 1, Conv, [512, 3, 2]] | ||
- [-1, 2, C2f, [512, True]] | ||
- [-1, 1, SPPF, [512, 5]] | ||
|
||
# YOLOv8m head | ||
head: | ||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 6], 1, Concat, [1]] | ||
- [-1, 3, C2f, [384]] | ||
|
||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 4], 1, Concat, [1]] | ||
- [-1, 3, C2f, [192]] | ||
|
||
- [-1, 1, Conv, [192, 3, 2]] | ||
- [[-1, 12], 1, Concat, [1]] | ||
- [-1, 3, C2f, [384]] | ||
|
||
- [-1, 1, Conv, [384, 3, 2]] | ||
- [[-1, 9], 1, Concat, [1]] | ||
- [-1, 3, C2f, [512]] | ||
|
||
- [[15, 18, 21], 1, Detect, [nc]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Ultralytics YOLO 🚀, AGPL-3.0 license | ||
# YOLOv8 object detection model with P3-P5 outputs, fixed to YOLOv8n scale | ||
|
||
|
||
# YOLOv8n backbone | ||
backbone: | ||
- [-1, 1, Conv, [16, 3, 2]] # 64 * 0.25 = 16 | ||
- [-1, 1, Conv, [32, 3, 2]] # 128 * 0.25 = 32 | ||
- [-1, 1, C2f, [32, True]] # min(128 * 0.25, 1024) = 32 | ||
- [-1, 1, Conv, [64, 3, 2]] # 256 * 0.25 = 64 | ||
- [-1, 2, C2f, [64, True]] # int(6 * 0.33) = 2; min(256 * 0.25, 1024) = 64 | ||
- [-1, 1, Conv, [128, 3, 2]] # 512 * 0.25 = 128 | ||
- [-1, 2, C2f, [128, True]] # min(512 * 0.25, 1024) = 128 | ||
- [-1, 1, Conv, [256, 3, 2]] # min(1024 * 0.25, 1024) = 256 | ||
- [-1, 1, C2f, [256, True]] | ||
- [-1, 1, SPPF, [256, 5]] | ||
|
||
# YOLOv8n head | ||
head: | ||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 6], 1, Concat, [1]] | ||
- [-1, 1, C2f, [128]] | ||
|
||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]] | ||
- [[-1, 4], 1, Concat, [1]] | ||
- [-1, 1, C2f, [64]] # P3/8-small | ||
|
||
- [-1, 1, Conv, [64, 3, 2]] | ||
- [[-1, 10], 1, Concat, [1]] | ||
- [-1, 1, C2f, [128]] # P4/16-medium | ||
|
||
- [-1, 1, Conv, [128, 3, 2]] | ||
- [[-1, 8], 1, Concat, [1]] | ||
- [-1, 1, C2f, [256]] # P5/32-large | ||
|
||
- [[13, 16, 19], 1, Detect, [nc]] |
Oops, something went wrong.