question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad prediction even with high training and validation accuracy

See original GitHub issue

hey guys,

i am using this code for image segmentation:

`from keras_segmentation.models.unet import unet

model = unet(n_classes=3) model.train(n_classes=3, train_images = “/content/Training/images”, train_annotations = “/content/Training/labels”, checkpoints_path = “/content/checkpoints” , epochs=1,validate=True,val_images=“/content/Test/images”,val_annotations=“/content/Test/labels”) ` Epoch 1/1 512/512 [==============================] - 252s 492ms/step - loss: 0.1199 - accuracy: 0.9728 - val_loss: 7.3933e-05 - val_accuracy: 1.0000 saved /content/checkpoints.model.0 Finished Epoch 0

I have high accuracies but bad prediction. I tried different models. All give me the same result.

Image index Label index Prediction prediction

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
reem90commented, Jan 12, 2020

I had the same issue and I solved it as follows: First of all, the labeled image generated from labelme tool has several channels. While the labeled image used in image-segmentation-keras has one channel. You can check that using Matlab. So, to convert all the labeled images from multiple channels to a single channel, create a small script in Matlab to read the png labeled images and save it again as png. It will directly save it as one channel image. Use these images for training. The generated images will look like black images. just try in a small dataset to make sure that it works.

It worked with me.

Best Regards,

0reactions
amil-rp-workcommented, Sep 7, 2020

@TharinduMoraDs
Hey can you please share the python code for the same. I am unfortunately not able to get grayscale image( image of single channel) and with values as 0 or 1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

keras - Very good validation accuracy but bad predictions
I'm building a keras model to classify cats and dogs. I used transfer learning with bottleneck features and fine tuning with vgg model....
Read more >
Why the predictions using keras saved models are bad when ...
Because it did overfitting, training accuracy will be very good. And since the model though giving very good accuracy on training set, doesn't...
Read more >
Keras model has a good validation accuracy but makes bad ...
This is the model I made but somehow the predictions are really bad even if the validation accuracy is really high (99%).
Read more >
Good accuracy but really bad predictions · Issue #8411 - GitHub
Good accuracy but really bad predictions #8411 ... The problem is that prediction on the training images(those 3 images) are not correct.
Read more >
Use of Bad Training Data for Better Predictions - NIPS papers
acheive high training set accuracy, cause poor predictions for new data. When using neural networks, this problem has two basic aspects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found