import sagemaker from sagemaker.estimator import Estimator import boto3 Define AWS…
- User
import sagemaker from sagemaker.estimator import Estimator
import boto3
Define AWS session
sagemaker_session = sagemaker.Session() role = "arn:aws:iam::654654331173:role/service-role/AmazonSageMaker-ExecutionRole-20250109T162756" # Update with your SageMaker execution role ARN
Define S3 paths
input_data_bucket = "uh-sagemaker-test-bucket" input_data_prefix = "datasets/roadsign_dataset/" output_model_path = f"s3://{input_data_bucket}/models/" output_metrics_key = f"{output_model_path}/validation_results.json"
Define training input channels
train_input = sagemaker.inputs.TrainingInput( s3_data=f"s3://{input_data_bucket}/{input_data_prefix}train/", distribution="FullyReplicated", )
val_input = sagemaker.inputs.TrainingInput( s3_data=f"s3://{input_data_bucket}/{input_data_prefix}val/", distribution="FullyReplicated", )
Define Debugger hook configuration
debugger_hook_config = DebuggerHookConfig( s3_output_path=output_model_path, # Path to save Debugger outputs hook_parameters={ "save_interval": "500", # Save tensors every 500 steps "trainable_parameters": "True" # Enable saving trainable parameters } )
Define Estimator for SageMaker training job
estimator = Estimator( image_uri="654654331173.dkr.ecr.us-east-2.amazonaws.com/asset-model-training:latest", # Update with your ECR URI role=role, instance_count=1, instance_type="ml.g4dn.xlarge", # Use GPU for YOLO training volume_size=100, # Size of the EBS volume max_run=432000, # Max training duration (seconds) hyperparameters={ "epochs": 1, "batch_size": 16, "imgsz": 640, "learning_rate": 0.001, "weight_decay": 1e-5, "patience": 5 }, sagemaker_session=sagemaker_session, output_path=output_model_path, # Save trained model in S3 debugger_hook_config=debugger_hook_config # Pass the DebuggerHookConfig directly
)
Start training job with training & validation datasets
estimator.fit({"train": train_input, "val": val_input})
folders are creating inside the s3 bucket for saving the debugger logs but no logs are fount out in there they all are empty
- Assistant