keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

TypeError when predicting from saved model with Keras (YOLOV8)

Open roversi opened this issue 2 years ago • 8 comments
trafficstars

After training a YOLOV8 Object Detection model using a custom dataset as presented in this example, I've saved the model and could load it again perfectly, but I am not being able to predict from it.

When running .predict it is presenting the folowing TypeError:


TypeError: in user code:

File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2341, in predict_function  *
    return step_function(self, iterator)
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2327, in step_function  **
    outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2315, in run_step  **
    outputs = model.predict_step(data)
File "/usr/local/lib/python3.10/dist-packages/keras_cv/models/object_detection/yolo_v8/yolo_v8_detector.py", line 610, in predict_step
    return self.decode_predictions(outputs, args[-1])
File "/usr/local/lib/python3.10/dist-packages/keras_cv/models/object_detection/yolo_v8/yolo_v8_detector.py", line 603, in decode_predictions
    return self.prediction_decoder(box_preds, scores)

TypeError: '_DictWrapper' object is not callable

Predict was working normally after .fit. Using the model that was just trained... Does the input of .predict require a different format when loading from saved model???

roversi avatar Sep 14 '23 08:09 roversi