Segmentation of medical images is a critical step in assisting doctors in making accurate diagnoses and planning appropriate treatments. Deep learning architectures often serve as the basis for computer models used for this task. However, a common challenge faced by segmentation models is class imbalance, which leads to a bias towards classes with a larger number of pixels, resulting in reduced accuracy for the minority-class regions. To address this problem, the \(\alpha \) -balanced variant of the focal loss function introduces a \(\alpha \) modulation factor that reduces the weight assigned to majority classes and gives greater weight to minority classes. This study proposes the use of a fuzzy inference system to automatically adjust the \(\alpha \) factor, rather than maintaining a fixed value as commonly implemented. The adaptive fuzzy focal loss (AFFL) achieves an appropriate adjustment in \(\alpha \) by employing fifteen fuzzy rules. To evaluate the effectiveness of AFFL, we implement an encoder-decoder segmentation model based on the UNet and Transformer architectures (AFFL-TransUNet) using the CHAOS dataset. We compare the performance of seven segmentation models implemented using the same data partition and hardware equipment. A statistical analysis, considering the DICE coefficient metric, demonstrates that AFFL-TransUNet outperforms four baseline models and performs comparably to the remaining models. Remarkably, AFFL-TransUNet achieves this high performance while significantly reducing training processing time by 66.31–72.39%. This reduction is attributed to the fuzzy system that effectively adapts the \(\alpha \) value of the loss function, stabilizing the model within just a few epochs.