classification_models icon indicating copy to clipboard operation
classification_models copied to clipboard

ResNeXt-50 accuracy is 0%

Open gcunhase opened this issue 2 years ago • 10 comments

About

ResNeXt-50 accuracy is 0% instead of 77.36%. Are the pre-trained weights here updated?

Steps to reproduce

  1. Install requirements:
pip install tensorflow-gpu==2.8.0
pip install git+https://github.com/qubvel/classification_models.git
  1. Load the model as follows:
ResNeXt, preprocess_input = Classifiers.get("resnext50)
model = ResNeXt(
    include_top=True,
    input_shape=(224, 224, 3),
    weights="imagenet"
)
  1. Use preprocess_input as the preprocessing function on the ImageNet validation dataset.
  2. Compile the model and evaluate:
 model.compile(
    optimizer="sgd",
    loss=tf.keras.losses.SparseCategoricalCrossentropy(),
    metrics=["accuracy"],
)
_, model_accuracy = model.evaluate(val_batches)

Note that there are no issues with the ResNet models when I follow the above steps.

System info

Python 3.8, Ubuntu 18.04

gcunhase avatar May 23 '22 08:05 gcunhase

Is this repo still active?

gcunhase avatar May 25 '22 08:05 gcunhase

Anyone still maintaining this repo?

gcunhase avatar Jun 03 '22 04:06 gcunhase

Are you training in the image-net dataset? I've just tested with a small-size dataset from tensorflow-dataset and it works fine.

innat avatar Jun 03 '22 14:06 innat

Yes, but I’m using ImageNet in tfrecord format. Can you please share the steps tocante it work? How you loaded the data, preprocessing, model instantiation so I can reproduce your steps on my side? Thanks!

gcunhase avatar Jun 04 '22 01:06 gcunhase

HERE.

innat avatar Jun 04 '22 04:06 innat

@innat Thank you, have you tried evaluating the model directly with ImageNet (include_top=True)? Mine fails in that scenario.

gcunhase avatar Jun 07 '22 08:06 gcunhase

I don't have an ImageNet locally to test. But I did a test with include_top=true on the natural image. It did run but the results are kinda non-sense even on the natural images. You can see the above colab file again.

innat avatar Jun 07 '22 09:06 innat

@innat Right, this is what I'm experiencing. And then when I iterate over the validation dataset, the accuracy goes to 0%.

gcunhase avatar Jun 08 '22 05:06 gcunhase

Oh, I see. Next, the either we can look at the source code to find anomaly or search other possible solution. Can you check other similar architecture on image-net, for example se-resnext.

innat avatar Jun 09 '22 00:06 innat

@innat I'm able to get the correct accuracy with seresnext50... Note I'm using pre-processing as follows due to this issue:

tf.keras.applications.imagenet_utils.preprocess_input(image, mode='torch')

I think that the pre-trained weights for ResNext might be incorrect!

gcunhase avatar Dec 12 '22 17:12 gcunhase