aws-samples / amazon-sagemaker-pytorch-detectron2

This repository shows how to train an object detection algorithm with Detectron2 on Amazon SageMaker
MIT No Attribution
27 stars 15 forks source link

Hyperparameter Limit Constraint #10

Closed anabia-alam closed 2 years ago

anabia-alam commented 2 years ago

Hi,

I am working on this notebook, to use detectron2's Retinanet on our custom dataset, instead of SKU110k dataset. Our dataset has 140 labels, so while running the training job this error is coming up

'hyperParameters' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 2500, Member must have length greater than or equal to 0, Member must satisfy regular expression pattern: .*]

Can you suggest a workaround for this issue? TIA

paoloirrera commented 2 years ago

Hi,

Could you please share the definition of the hyper-parameters that you would like to tune?

anabia-alam commented 2 years ago

These are the hyper parameters,

od_algorithm = "retinanet" # choose one in ("faster_rcnn", "retinanet") training_job_hp = {

Dataset

"classes": json.dumps(classes),
"dataset-name": json.dumps("sku110k"),
"label-name": json.dumps(classes2),
# Algo specs
"model-type": json.dumps(od_algorithm),
"backbone": json.dumps("R_101_FPN"),
# Data loader
"num-iter": 900,
"log-period": 500,
"batch-size": 16,
"num-workers": 8,
# Optimization
"lr": 0.005,
"lr-schedule": 3,
# Faster-RCNN specific
"num-rpn": 517,
"bbox-head-pos-fraction": 0.2,
"bbox-rpn-pos-fraction": 0.4,
# Prediction specific
"nms-thr": 0.2,
"pred-thr": 0.1,
"det-per-img": 300,
# Evaluation
"evaluation-type": "fast",

}

Classes here is the list of 140 labels on which we're trying to perform object detection. Here's a snippet of the classes list image

paoloirrera commented 2 years ago

Could you also tell me the results of the following? len(json.dumps(classes))

anabia-alam commented 2 years ago

image

paoloirrera commented 2 years ago

OK, that is the problem. As the error message indicates, each hyper-parameter must not exceed 2500 chars. This is a SageMaker condition, and, hence, beyond the scope of this repository. In your case, it is 3508. I would suggest to rename your classes so that json.dumps(classes) does not exceed 2500.