You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# select the percentage of layers to be trained while using the transfer learning
# technique. The selected layers will be close to the output/final layers.
unfreeze_percentage = 0
learning_rate = 0.001
if training_format == "scratch":
print("Training a model from scratch")
model = scratch(train, val, learning_rate)
elif training_format == "transfer_learning":
print("Fine Tuning the MobileNet model")
model = transfer_learn(train, val, unfreeze_percentage, learning_rate)
i see messages like that: Corrupt JPEG data: 65 extraneous bytes before marker 0xd9
i googled that and the problem is with corrupted images in dataset (cats and dogs). to fix that one needs to use code to clean dataset:
import os
num_skipped = 0
for folder_name in ("Cat", "Dog"):
folder_path = os.path.join("PetImages", folder_name)
for fname in os.listdir(folder_path):
fpath = os.path.join(folder_path, fname)
try:
fobj = open(fpath, "rb")
is_jfif = tf.compat.as_bytes("JFIF") in fobj.peek(10)
finally:
fobj.close()
if not is_jfif:
num_skipped += 1
# Delete corrupted image
os.remove(fpath)
print("Deleted %d images" % num_skipped)
Activity
chapter 4: