The U-Net architecture is a prominent technique for image segmentation. However, a significant challenge in utilizing this algorithm is the selection of appropriate hyperparameters. In this study, we aimed to address this issue using an evolutionary approach. We conducted experiments on four different geometric datasets (triangle, kite, parallelogram, and square), with 1,000 training samples and 200 test samples. Initially, we performed image segmentation without the evolutionary approach, manually adjusting the U-Net hyperparameters. The average accuracy rates for the geometric images were 0.94463, 0.96289, 0.96962, and 0.93971, respectively. Subsequently, we proposed a hybrid version of the U-Net architecture, incorporating the Grasshopper Optimization Algorithm (GOA) for an evolutionary approach. This method automatically discovered the optimal hyperparameters, resulting in improved image segmentation performance. The average accuracy rates achieved by the proposed method were 0.99418, 0.99673, 0.99143, and 0.99946, respectively, for the geometric images. Comparative analysis revealed that the proposed UNet-GOA approach outperformed the traditional U-Net architecture, yielding higher accuracy rates.