Model Maker Error - max_instances_per_image

Using model maker with roughly ~2000 images. Appears to be throwing a max_instances_per_image error.

Is this the batch and epoch number balance or do I need to set the max_instances_per_image value somewhere? If so, where do i set it?

Epoch 1/20
 9/40 [=====>........................] - ETA: 9:38 - det_loss: 1.9883 - cls_loss: 1.2422 - box_loss: 0.0149 - reg_l2_loss: 0.0659 - loss: 2.0542 - learning_rate: 0.0112 - gradient_norm: 0.6159
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-12-54438fa21142> in <module>()
----> 1 model = object_detector.create(train_data, model_spec=spec, batch_size=32, epochs=20, train_whole_model=True, validation_data=validation_data)

4 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     53     ctx.ensure_initialized()
     54     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 55                                         inputs, attrs, num_outputs)
     56   except core._NotOkStatusException as e:
     57     if name is not None:

InvalidArgumentError: Graph execution error:

assertion failed: [ERROR: please increase config.max_instances_per_image] [Condition x < y did not hold element-wise:] [x (parser/strided_slice_17:0) = ] [251] [y (parser/assert_less/y:0) = ] [100]
	 [[{{node parser/assert_less/Assert/Assert}}]]
	 [[MultiDeviceIteratorGetNextFromShard]]
	 [[RemoteCall]]
	 [[IteratorGetNext]] [Op:__inference_train_function_193197]

Any help is always greatly appreciated.

Cheers

I think its max number of detections on one image.

Did you try this?
https://tensorflow-prod.ospodiscourse.com/t/tflite-model-maker-training-error-custom-object-detection/6696/6

1 Like

Can confirm declaring this hyper parameter works :+1:

# instead of spec = model_spec.get('efficientdet_lite0')

spec = object_detector.EfficientDetSpec(
  model_name='efficientdet-lite0', 
  uri='https://tfhub.dev/tensorflow/efficientdet/lite0/feature-vector/1', 
  hparams={'max_instances_per_image': 8000})
2 Likes

tks, this work 4 me too :smiley: