sachin365123 / MRI-Brain-Tumor-Segmentation-Using-ResUNet-Deep-Learning-Architecture-

3 stars 1 forks source link

utilities.py error (fixed!) #1

Open govindvirdee opened 3 months ago

govindvirdee commented 3 months ago

Hi Sachin - there's an error in utilities.py when running the segmentation model.

All you need to fix it is to add these lines:

y_true_pos = tf.cast(y_true_pos,'float32')
y_pred_pos = tf.cast(y_pred_pos,'float32')

at lines 208 and 209 in tversky, so it looks like:

def tversky(y_true, y_pred, smooth = 1e-6): y_true_pos = K.flatten(y_true) y_pred_pos = K.flatten(y_pred) y_true_pos = tf.cast(y_true_pos,'float32') y_pred_pos = tf.cast(y_pred_pos,'float32') true_pos = K.sum(y_true_pos y_pred_pos) false_neg = K.sum(y_true_pos (1-y_pred_pos)) false_pos = K.sum((1-y_true_pos)y_pred_pos) alpha = 0.7 return (true_pos + smooth)/(true_pos + alphafalse_neg + (1-alpha)*false_pos + smooth)

Thanks! :)

sachin365123 commented 3 months ago

Hi, Book your session: sachin saxena (topmate.io) https://topmate.io/sachin_saxena?utm_source=linkedin&utm_medium=product&utm_campaign=ss

WITH REGARDS Sachin K Saxena

Sr Software Engineer - Data Scientist

GAVS Technologies Pvt. Ltd.

*Email: @. @.>*

LinkedIn Profile]( https://www.linkedin.com/in/sachin-saxena-graphic-designer/)

On Fri, 26 Apr 2024 at 12:49, Govindraj Singh Virdee < @.***> wrote:

Hi Sachin - there's an error in utilities.py when running the segmentation model.

All you need to fix it is to add these lines:

y_true_pos = tf.cast(y_true_pos,'float32') y_pred_pos = tf.cast(y_pred_pos,'float32')

at lines 208 and 209 in tversky, so it looks like:

def tversky(y_true, y_pred, smooth = 1e-6): y_true_pos = K.flatten(y_true) y_pred_pos = K.flatten(y_pred) y_true_pos = tf.cast(y_true_pos,'float32') y_pred_pos = tf.cast(y_pred_pos,'float32') true_pos = K.sum(y_true_pos y_pred_pos) false_neg = K.sum(y_true_pos (1-y_pred_pos)) false_pos = K.sum((1-y_true_pos)

y_pred_pos) alpha = 0.7 return (true_pos + smooth)/(true_pos + alphafalse_neg

  • (1-alpha)*false_pos + smooth)

Thanks! :)

— Reply to this email directly, view it on GitHub https://github.com/sachin365123/MRI-Brain-Tumor-Segmentation-Using-ResUNet-Deep-Learning-Architecture-/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKA3YEQ267JIUHNKMHDRE3LY7H5Y5AVCNFSM6AAAAABG2IAQKGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3DKMJSGUYDAOI . You are receiving this because you are subscribed to this thread.Message ID: <sachin365123/MRI-Brain-Tumor-Segmentation-Using-ResUNet-Deep-Learning-Architecture-/issues/1 @github.com>