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 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.2xlarge", # 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 )
Start training job with training & validation datasets
estimator.fit({"train": train_input, "val": val_input})
need to add sagemaker debugger in it
- Assistant
- User
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ in :3 │ │ │ │ 1 import sagemaker │ │ 2 from sagemaker.estimator import Estimator │ │ ❱ 3 from sagemaker.debugger import DebuggerHookConfig, Rule, RuleConfig │ │ 4 import boto3 │ │ 5 │ │ 6 # Define AWS session │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ImportError: cannot import name 'RuleConfig' from 'sagemaker.debugger' (/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/sagemaker/debugger/init.py)
- Assistant
- User
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ in :58 │ │ │ │ 55 ) │ │ 56 │ │ 57 # Add the debugger hook configuration to the estimator │ │ ❱ 58 estimator.set_debugger_hook_config(debugger_hook_config) │ │ 59 │ │ 60 │ │ 61 # Start training job with training & validation datasets │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ AttributeError: 'Estimator' object has no attribute 'set_debugger_hook_config'
- Assistant
- User
what actually will its output
- Assistant
- 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"
- Assistant