I test the model performance but cannot get what I want
import keras from classification_models.tfkeras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18') base_model = ResNet18(input_shape=(224,224,3)) base_model.load_weights('resnet18_imagenet_1000.h5') base_model.compile( optimizer="sgd", loss=["categorical_crossentropy"], metrics=["categorical_accuracy"], ) def preprocess(data): img = lqz.preprocess_input(data["image"]*255) print(img) label = tf.one_hot(data["label"], 1000) return img, label dataset = ( tfds.load("imagenet2012:5.0.0", split=tfds.Split.VALIDATION) .map(preprocess, num_parallel_calls=tf.data.experimental.AUTOTUNE) .batch(128) .prefetch(1) )
base_model.evaluate(dataset)
Would you like to tell me where I am doing wrong?
Hi, What results did you get? Is performance a little bit worse or completely dropped?
Hi,
I also have the same issue. I run the ResNET-18 and I got 64%. What pre-processing did you used to get 68%?
Thanks,
I have the same issue. Top-1 accuracy is 64% for Resnet18 instead of the promised 68%.
Preprocessing I have used to evaluate models:
import albumentations as A
img_size = 256
crop_size = 224
transform = A.Compose([
A.PadIfNeeded(min_height=img_size, min_width=img_size),
A.SmallestMaxSize(max_size=img_size, interpolation=2),
A.CenterCrop(crop_size, crop_size, p=1.0),
], p = 1.0)
As you can notice we cut borders, image size is larger than crop size.