jakeret / tf_unet

Generic U-Net Tensorflow implementation for image segmentation
GNU General Public License v3.0
1.9k stars 748 forks source link

Training Accuracy is always 1.00 and the Minibatch error is always 0.0% #292

Open ChristmasLatte opened 4 years ago

ChristmasLatte commented 4 years ago

Hi, I have a trouble when i was training model.The minibatch loss seems normal, but the training accuracy is always 1 and minibatch error is always 0.0%. 图片 And I just want extract buildings from image, and my mask label channels is 3,should i set n_class=3 ?

Here is my code:

from tf_unet import unet, util, image_util

data_provider = image_util.ImageDataProvider("data/train/*.tif") net = unet.Unet(layers=3, features_root=64, channels=3, n_class=3) trainer = unet.Trainer(net) path = trainer.train(data_provider, "./data/unet_trained_bgs_example_data", training_iters=32, epochs=100, dropout=0.5)

verification

... data_provider = image_util.ImageDataProvider("data/test/*.tif") x_test, y_test = data_provider(1) prediction = net.predict("./data/unet_trained_bgs_example_data/model.ckpt", x_test) unet.error_rate(prediction, util.crop_to_shape(y_test, prediction.shape)) img = util.combine_img_prediction(x_test, y_test, prediction) util.save_image(img, "prediction.jpg")

jakeret commented 4 years ago

Hi @ChristmasLatte , hard to tell whats going on from what I see here.

I'm currently working on a re-implementation of tf_unet that is based on tensorflow 2 & keras and addressing some of the issues tf_unet had. Maybe this could help you: https://github.com/jakeret/unet

ChristmasLatte commented 4 years ago

Okay, thanks for your answer @jakeret .I will refre another projected. Sorry i am a beginner in u-net, I also have a little question that if i want to class an image into foreground and background, should i set n_class 1? I would appreciate it if you have time to reply.

AzizahMasturina commented 4 years ago

Hi @ChristmasLatte, I am experiencing the same problem and was wondering if you managed to solve it? Thank you.