Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified some functions in C4W3 CarDetection file to make Tensorflow v2 compatible. #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Raghav4138
Copy link

modified some functions to be compatible with
TensorFlow version2.
The following file was modified.
".\coursera-deep-learning-specialization\C4 - Convolutional Neural Networks\Week 3\Car detection for Autonomous Driving\Autonomous_driving_application_Car_detection_v3a.ipynb"

DESCRIPTION:

General changes:
---------tf.function() -> tf.compat.v1.function()	

----------------------------------------------------------------------------
In function yolo_filter_boxes()
    K.argmax -> tf.argmax
    K.reduce_max -> tf.reduce_max
----------------------------------------------------------------------------
In function iou()
    used better names, to reduce code redundancy
----------------------------------------------------------------------------
In function yolo_non_max_suppression()
---------these 2 lines were changed
    max_boxes_tensor = K.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    K.get_session().run(tf.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

---------new lines
    max_boxes_tensor = tf.keras.backend.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    with tf.compat.v1.Session() as sess:
        sess.run(tf.compat.v1.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

--------- K.gather()  ->  tf.gather()
----------------------------------------------------------------------------

Raghav4138 added 2 commits August 24, 2024 02:08
    TensorFlow version2.
    The following file was modified.
    ".\coursera-deep-learning-specialization\C4 - Convolutional Neural Networks\Week 3\Car detection for Autonomous Driving\Autonomous_driving_application_Car_detection_v3a.ipynb"

DESCRIPTION:

General changes:
---------tf.function() -> tf.compat.v1.function()

----------------------------------------------------------------------------
In function yolo_filter_boxes()
    K.argmax -> tf.argmax
    K.reduce_max -> tf.reduce_max
----------------------------------------------------------------------------
In function iou()
    used better names, to reduce code redundancy
----------------------------------------------------------------------------
In function yolo_non_max_suppression()
---------these 2 lines were changed
    max_boxes_tensor = K.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    K.get_session().run(tf.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

---------new lines
    max_boxes_tensor = tf.keras.backend.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    with tf.compat.v1.Session() as sess:
        sess.run(tf.compat.v1.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

--------- K.gather()  ->  tf.gather()
----------------------------------------------------------------------------
    TensorFlow version2.
    The following file was modified.
    ".\coursera-deep-learning-specialization\C4 - Convolutional Neural Networks\Week 3\Car detection for Autonomous Driving\Autonomous_driving_application_Car_detection_v3a.ipynb"

DESCRIPTION:

General changes:
---------tf.function() -> tf.compat.v1.function()

----------------------------------------------------------------------------
In function yolo_filter_boxes()
    K.argmax -> tf.argmax
    K.reduce_max -> tf.reduce_max
----------------------------------------------------------------------------
In function iou()
    used better names, to reduce code redundancy
----------------------------------------------------------------------------
In function yolo_non_max_suppression()
---------these 2 lines were changed
    max_boxes_tensor = K.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    K.get_session().run(tf.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

---------new lines
    max_boxes_tensor = tf.keras.backend.variable(max_boxes, dtype='int32')     # tensor to be used in tf.image.non_max_suppression()
    with tf.compat.v1.Session() as sess:
        sess.run(tf.compat.v1.variables_initializer([max_boxes_tensor])) # initialize variable max_boxes_tensor

--------- K.gather()  ->  tf.gather()
----------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant