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

keras_cv.src.backend.keras' has no attribute 'src

Open deepdatadive opened this issue 1 year ago • 5 comments
trafficstars

Current Behavior:

I am following this guide: https://keras.io/guides/keras_cv/object_detection_keras_cv/

at this line: y_pred = pretrained_model.predict(image_batch). I get the following error:

AttributeError: module 'keras_cv.src.backend.keras' has no attribute 'src'

The traceback shows;

Cell In[15], line 1 ----> 1 y_pred = pretrained_model.predict(image_batch) 2 # y_pred is a bounding box Tensor: 3 # {"classes": ..., boxes": ...} 4 visualization.plot_bounding_box_gallery( 5 image_batch, 6 value_range=(0, 255), (...) 13 class_mapping=class_mapping, 14 )

File ~/venvs/yolov8_example/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122, in filter_traceback..error_handler(*args, **kwargs) 119 filtered_tb = _process_traceback_frames(e.traceback) 120 # To get the full stack trace, call: 121 # keras.config.disable_traceback_filtering() --> 122 raise e.with_traceback(filtered_tb) from None 123 finally: 124 del filtered_tb

File ~/venvs/yolov8_example/lib/python3.10/site-packages/keras_cv/src/models/object_detection/yolo_v8/yolo_v8_detector.py:616, in YOLOV8Detector.predict_step(self, *args) 614 return self.decode_predictions(outputs[0], args[-1]), outputs[1] 615 else: --> 616 return self.decode_predictions(outputs, args[-1])

File ~/venvs/yolov8_example/lib/python3.10/site-packages/keras_cv/src/models/object_detection/yolo_v8/yolo_v8_detector.py:602, in YOLOV8Detector.decode_predictions(self, pred, images) 599 stride_tensor = ops.expand_dims(stride_tensor, axis=-1) 601 box_preds = dist2bbox(boxes, anchor_points) * stride_tensor --> 602 box_preds = bounding_box.convert_format( 603 box_preds, 604 source="xyxy", 605 target=self.bounding_box_format, 606 images=images, 607 ) 609 return self.prediction_decoder(box_preds, scores)

File ~/venvs/yolov8_example/lib/python3.10/site-packages/keras_cv/src/backend/scope.py:33, in tf_data..wrapper(*args, **kwargs) 31 @functools.wraps(function) 32 def wrapper(*args, **kwargs): ---> 33 if keras_3() and keras.src.utils.backend_utils.in_tf_graph(): 34 with TFDataScope(): 35 return function(*args, **kwargs)

AttributeError: module 'keras_cv.src.backend.keras' has no attribute 'src'

Expected Behavior:

I would expect it to make a prediction.

Steps To Reproduce:

Just run the tutorial.

deepdatadive avatar Apr 23 '24 19:04 deepdatadive

I have experienced the same problem

flocho-hy avatar Apr 24 '24 06:04 flocho-hy

I have the same problem. image

TheSmileXiao avatar Apr 24 '24 15:04 TheSmileXiao

Thanks for reporting the issue. This issue could be due to the changes made here in the latest Keras version. @sampathweb , Could you please look into this.

Till we resolve the issue, you can downgrade the Keras version to 3.2.0 and continue using the tutorial without any error.

sachinprasadhs avatar Apr 25 '24 21:04 sachinprasadhs

👍🏼

flocho-hy avatar Apr 26 '24 07:04 flocho-hy

Changes have been made here https://github.com/keras-team/keras-cv/commit/fb4fca44d3ea8e43e84f66eee4acf4f9c7a6ec11 and it will be available in the next release( today or tomorrow)

sachinprasadhs avatar Apr 29 '24 22:04 sachinprasadhs

@flocho-hy @sachinprasadhs @deepdatadive @TheSmileXiao - Release KerasCV 0.9.0. Can you update your KerasCV version by pip install -U keras-cv and let me know if you still run into this issue?

sampathweb avatar May 01 '24 16:05 sampathweb

I had the same issue with Tensorflow 2.12 and keras_cv 0.9 on a conda envireronment. After trying a lot of solution, finally upgrade Tensorflow to 2.14 solved the issue.

babanthierry94 avatar May 02 '24 15:05 babanthierry94

@babanthierry94 , You can upgrade to latest Tensorflow version which comes with Keras 3 as a backend and keras_cv is also migarted to Keras 3

sachinprasadhs avatar May 02 '24 17:05 sachinprasadhs

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 17 '24 01:05 github-actions[bot]

Has been resolved.

divyashreepathihalli avatar May 30 '24 00:05 divyashreepathihalli