This model is a fine-tuned version of a custom U-Net architecture enhanced with ASPP(Atrous Spatial Pyramid Pooling), Squeeze-and-Excitation blocks, and dilated convolutions.
It is designed for semantic segmentation of lung regions in chest X-ray images.
The model was further trained on a curated set of difficult X-ray examples with low contrast, overlapping anatomical structures, or weak/incomplete ground truth annotations.
To improve structural realism, the model was fine-tuned using a PatchGAN discriminator in an adversarial training setup.
This encouraged the generation of sharper, more anatomically consistent masks, especially on noisy or edge-case images.
The model also outperforms the original ground-truth masks on visual quality and edge precision.
It was trained on the publicly available
COVID-19 Radiography Database.
The final model achieves a Dice score of 95.9% on the internal validation set.
Model Format & Loading Instructions
This model contains custom loss functions and metrics, so you must load it using
custom_objects in Keras
Example: Load the model (Keras 3+)
--- custom functions required by the model ---
def dice_coefficient(y_true, y_pred):
numerator = 2 * K.sum(y_true * y_pred) + 1e-6
denominator = K.sum(y_true + y_pred) + 1e-6
return numerator / denominator
def iou_metric(y_true, y_pred):
intersection = K.sum(y_true * y_pred)
union = K.sum(y_true) + K.sum(y_pred) - intersection
return (intersection + 1e-6) / (union + 1e-6)
def dice_loss(y_true, y_pred):
return 1 - dice_coefficient(y_true, y_pred)
def combined_loss(y_true, y_pred):
return 0.5 * dice_loss(y_true, y_pred) + 0.5 * tf.keras.losses.binary_crossentropy(
y_true, y_pred
)
custom_objects = {
"dice_coefficient": dice_coefficient,
"iou_metric": iou_metric,
"dice_loss": dice_loss,
"combined_loss": combined_loss,
}
--- load model ---
model = keras.models.load_model(
"model.keras",
custom_objects=custom_objects,
)