Hello, this is my very first Tenserflow project, Please help me to solve the issue below the description.
Traceback (most recent call last):
File "C:\Tensorflow\workspace\training_demo\training2\1.py", line 40, in <module>
model.add(ResNet50(include_top=False, pooling='avg', weights=resnet_weights_path))
File "C:\Users\kamil\.conda\envs\tensorflow\lib\site-packages\tensorflow\python\keras\applications\resnet.py", line 457, in ResNet50
return ResNet(stack_fn, False, True, 'resnet50', include_top, weights,
File "C:\Users\kamil\.conda\envs\tensorflow\lib\site-packages\tensorflow\python\keras\applications\resnet.py", line 124, in ResNet
raise ValueError('The `weights` argument should be either '
ValueError: The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.
(tensorflow) C:\Tensorflow\workspace\training_demo\training2>
Code:
image_size = 224
data_generator_with_aug = ImageDataGenerator(preprocessing_function=preprocess_input,
horizontal_flip=True,
width_shift_range=0.2,
height_shift_range=0.2)
train_path='C:/Tensorflow/workspace/training_demo/training2/training'
train_generator = data_generator_with_aug.flow_from_directory(train_path,
target_size=(image_size, image_size),
batch_size=24,
class_mode='categorical')
data_generator_with_no_aug = ImageDataGenerator(preprocessing_function=preprocess_input)
validation_path='C:/Tensorflow/workspace/training_demo/training2/validation'
validation_generator = data_generator_with_no_aug.flow_from_directory(validation_path,
target_size=(image_size, image_size),
batch_size=24,
class_mode='categorical')
resnet_weights_path = 'C:/Tensorflow/workspace/training_demo/training2resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5'#'C:/Tensorflow/workspace/training_demo/training2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5'
#resnet_weights_path = 'C:/Users/kamil/.keras/models/resnet50_weights_th_dim_ordering_th_kernels_notop.h5'
model = Sequential()
model.add(ResNet50(include_top=False, pooling='avg', weights=resnet_weights_path))
num_classes = 10
model.add(Dense(num_classes, activation='softmax'))
# Say not to train first layer (ResNet) model. It is already trained
model.layers[0].trainable = False
model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
model.fit_generator(train_generator,
steps_per_epoch=3,
epochs=20,
validation_data=validation_generator,
validation_steps=1)
I use my images and my json file with 3 classes.