This commit is contained in:
2026-05-21 17:53:27 +02:00
parent 4b56e164a1
commit b2c0110d11

View File

@@ -29,9 +29,9 @@ Original file is located at
import sys
IN_COLAB = 'google.colab' in sys.modules
# if IN_COLAB:
# !pip install pandas numpy matplotlib seaborn pillow scikit-learn tensorflow
# !pip install --upgrade kagglehub[pandas-datasets,hf-datasets]
#if IN_COLAB:
# !pip install pandas numpy matplotlib seaborn pillow scikit-learn tensorflow
# !pip install --upgrade kagglehub[pandas-datasets,hf-datasets]
import kagglehub
@@ -282,28 +282,24 @@ data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomContrast(0.1),
])
with strategy.scope():
base_model = DenseNet121(
weights='imagenet',
include_top=False,
input_shape=(224, 224, 3)
)
base_model = DenseNet121(
weights='imagenet',
include_top=False,
input_shape=(224, 224, 3)
)
with strategy.scope():
inputs = tf.keras.Input(shape=(224,224,3))
inputs = tf.keras.Input(shape=(224,224,3))
x = data_augmentation(inputs)
x = data_augmentation(inputs)
with strategy.scope():
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation='relu')(x) # Added another Dense layer
x = Dense(256, activation='relu')(x) # Existing Dense layer
predictions = Dense(1, activation='sigmoid')(x) # Output layer for binary classification
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation='relu')(x) # Added another Dense layer
x = Dense(256, activation='relu')(x) # Existing Dense layer
predictions = Dense(1, activation='sigmoid')(x) # Output layer for binary classification
with strategy.scope():
model = Model(inputs=base_model.input, outputs=predictions)
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])
model = Model(inputs=base_model.input, outputs=predictions)
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])
"""## 4. Data Generators