-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_model.py
More file actions
37 lines (31 loc) · 907 Bytes
/
Copy pathfix_model.py
File metadata and controls
37 lines (31 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import tensorflow as tf
from tensorflow.keras import layers, models
# ======================
# REBUILD MODEL
# ======================
base_model = tf.keras.applications.MobileNetV2(
input_shape=(224, 224, 3),
include_top=False,
weights="imagenet"
)
# Freeze same layers
for layer in base_model.layers[:-20]:
layer.trainable = False
# IMPORTANT: No augmentation here (for inference)
model = models.Sequential([
base_model,
layers.GlobalAveragePooling2D(),
layers.BatchNormalization(),
layers.Dense(64, activation='relu'),
layers.Dropout(0.5),
layers.Dense(1, activation='sigmoid')
])
# ======================
# LOAD WEIGHTS ONLY
# ======================
model.load_weights("image_quality_model_final.h5")
# ======================
# SAVE CLEAN MODEL
# ======================
model.save("image_quality_model.keras")
print("✅ Model fixed and saved successfully!")