google / automl

Google Brain AutoML
Apache License 2.0
6.23k stars 1.45k forks source link

Binary Classification of Grayscale Images with TF2 #1043

Open thiagoribeirodamotta opened 3 years ago

thiagoribeirodamotta commented 3 years ago

Have anyone managed to make a successful training on a Binary Classification of Grayscale images with TF2?

I did manage to start training, but after 20 epochs, Validation accuracy was close to 0.5 and loss was around 7 for both Train and Validation. Dataset is composed of 15k+ images and I can usually get a Validation Accuracy of 0.8+ with EfficientNetB0.

Using Adam optimizer, tried Learning Ratio of 0.01 and 0.001, using either WarmupLearningRateSchedule (with config.train values) or just regular Learning Ratio. Loss is BinaryCrossentropy with Accuracy as metric.

I'm not using the main_tf2 script though, as I wanted to reuse a previous code with ImageDataGenerator.

In order to do so, I had to change the code a bit here and there.. for instance. train_step and test_step now both sets images, labels = data directly, since I don't have the features array, with 'image' and 'label' fields, anymore. (Last time I checked, both variables, images and labels, had its shapes being all None. Is this expected?)

I'm also not touching anything related to mixed precision, float16, TPU or fine tuning. Training is done on a single GPU.

I did not manage to find where in the code I should use n_channels=1 instead of n_channels=3 (or where to change the input_shape overall) neither could check how activation was done.

Have anyone manage to accomplish this task? Thank you.

halftru commented 2 years ago

Did you ever fix this issue?