The final model
wcatch opened this issue · 7 comments
I tested your road_mapper_final.h5 in test datasets, the output showed a blank image. Did you upload your trained parameters? or we need to train the model by ourselves?
Yes, I had uploaded the complete model and you can start testing with the model I uploaded.
Please Use the following code to load the model.
from keras.models import load_model
model = load_model("./Models/road_mapper_final.h5", custom_objects={'soft_dice_loss': soft_dice_loss, 'iou_coef': iou_coef})
You will have to define and load the custom losses to get predictions. Do let me know if this doesn't work.
Thank you.
now this is a terrible question but how do i test it with my own images?
i read the code, what is the test mask? do i need a test mask to use the model with my own images?
and i also i face this :
ValueError: Unknown loss function:dice_coef_loss
while trying to test the network
i have defined the two functions for the custom loss that you have in your code , before the load_model , but its still complaining that :
ValueError: Unknown loss function:dice_coef_loss
I managed to run the code with the given model. You can use the below script. However, Im not 100% sure this is the right way to do.
def iou_coef(y_true, y_pred, smooth=1):
intersection = K.sum(K.abs(y_true * y_pred), axis=[1, 2, 3])
union = K.sum(y_true, [1, 2, 3]) + K.sum(y_pred, [1, 2, 3]) - intersection
iou = K.mean((intersection + smooth) / (union + smooth), axis=0)
return iou
def dice_coef_loss(y_true, y_pred, smooth=1):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)
def soft_dice_loss(y_true, y_pred):
return 1 - dice_coef_loss(y_true, y_pred)
model = load_model("../Models/road_mapper_2.h5",
custom_objects={'soft_dice_loss': soft_dice_loss, 'iou_coef': iou_coef,
"dice_coef_loss": dice_coef_loss, "dice_loss": dice_coef_loss})
Hi!
When trying to load de model I get this error:
'OSError: Unable to open file (file signature not found)' related with h5 file.
Searching around the most common source of this error is a bad or corrupt file. Anyone had the same error? Any hints?
Thanks in advance.
I tested your road_mapper_final.h5 in test datasets, the output showed a blank image. Did you upload your trained parameters? or we need to train the model by ourselves?
Hey, I am also facing the same problem, were you able to solve it? Please help me out