Biomedical image segmentation is critical for accurate identification and analysis of anatomical structures in medical imaging, particularly in cardiac MRI. However, manual segmentation is labor-intensive, time-consuming, and prone to variability, necessitating automated methods. Current machine learning approaches, while promising, face challenges such as overfitting, high computational demands, and the need for extensive annotated data. To address these issues, we propose a UU-Mamba model that integrates the U-Mamba model with the Sharpness-Aware Minimization optimizer and an uncertainty-aware loss function. SAM enhances generalization by finding flat minima in the loss landscape, mitigating overfitting. The uncertainty-aware loss combines region-based, distribution-based, and pixel-based losses, improving segmentation accuracy and robustness. Our method, evaluated on the ACDC cardiac dataset, outperforms state-of-the-art models (TransUNet, Swin-Unet, nnUNet, nnFormer), achieving superior Dice Similarity Coefficient and Mean Squared Error results, demonstrating the effectiveness of our approach in cardiac MRI segmentation.