keras-team / keras-cv

Industry-strength Computer Vision workflows with Keras
Other
1.01k stars 330 forks source link

In OD models we need input validation #1335

Open LukeWood opened 1 year ago

LukeWood commented 1 year ago

When you pass a dictionary with keras {"images": images, "bounding_boxes": boxes} keras will throw this error. This is definitely not what we want. Lets give a better error message telling users to unpackage the preprocessing format to a dictionary.

Traceback (most recent call last):
  File "/Users/lukewood/workspace/OD-benchmarking/tasks/pascal_voc2007/run.py", line 126, in <module>
    ml_experiments.run(run, FLAGS.config)
  File "/Users/lukewood/workspace/ml-experiments/ml_experiments/run.py", line 65, in run
    result = run(config)
  File "/Users/lukewood/workspace/OD-benchmarking/tasks/pascal_voc2007/run.py", line 107, in run
    history = model.fit(
  File "/usr/local/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/var/folders/03/4dl3rtgd0njccwgh38g1glr400fbw2/T/__autograph_generated_filenkc0i21u.py", line 15, in tf__train_function
    retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
  File "/Users/lukewood/workspace/keras-cv/keras_cv/models/object_detection/retina_net/retina_net.py", line 369, in train_step
    y = bounding_box.convert_format(
  File "/Users/lukewood/workspace/keras-cv/keras_cv/bounding_box/converters.py", line 360, in convert_format
    if boxes.shape[-1] != 4:
AttributeError: in user code:

    File "/usr/local/lib/python3.10/site-packages/keras/engine/training.py", line 1249, in train_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.10/site-packages/keras/engine/training.py", line 1233, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.10/site-packages/keras/engine/training.py", line 1222, in run_step  **
        outputs = model.train_step(data)
    File "/Users/lukewood/workspace/keras-cv/keras_cv/models/object_detection/retina_net/retina_net.py", line 369, in train_step
        y = bounding_box.convert_format(
    File "/Users/lukewood/workspace/keras-cv/keras_cv/bounding_box/converters.py", line 360, in convert_format
        if boxes.shape[-1] != 4:

    AttributeError: 'str' object has no attribute 'shape'

➜  pascal_voc2007 git:(master) ✗
jaygala223 commented 1 year ago

Hi @LukeWood, need some help on this