image-segmentation-keras icon indicating copy to clipboard operation
image-segmentation-keras copied to clipboard

Metric changes

Open mavaylon1 opened this issue 3 years ago • 2 comments

Is there a way to change the metric from accuracy to a custom metric like iou?

I changed train.py to have

model.compile(loss=loss_k, optimizer=optimizer_name, metrics=[iou]) #replaced accuracy with iou

where i defined iou as def iou(y_true, y_pred): intersection = K.sum(y_true * y_pred) sum_ = K.sum(y_true + y_pred) jac = (intersection + smooth) / (sum_ - intersection + smooth) return jac

It trains but it still says "accuracy" while training. When I change it to the following, it still doesn't show both. Just accuracy. Is there other changes to train i missed?

model.compile(loss=loss_k, optimizer=optimizer_name, metrics=['accuracy', iou])

Even this doesn't do anything. model.compile(loss=loss_k, optimizer=optimizer_name, metrics=[tf.keras.metrics.MeanIoU(num_classes=2)])

mavaylon1 avatar Nov 29 '21 20:11 mavaylon1

Same problem.

leo96code avatar Dec 06 '21 15:12 leo96code

Hey Guys,

I know it's little bit late but got also a really strange behavior. When I'm using my Ubuntu workstation meanIOU (from Keras metrics) works really fine. It's displayed and could be used for early stopping. (Keras 2.4.3) (Just import and add to metrics list)

But on my MacbookPro training is not even starting.

Any ideas?

momoai96 avatar Jan 10 '22 11:01 momoai96