Given the importance and interest of buildings in the urban environment, numerous studies have focused on automatically extracting building outlines by exploiting different datasets and techniques. Recent advancements in unmanned aerial vehicles (UAVs) and their associated sensors have made it possible to obtain high-resolution data to update building information. These detailed, up-to-date geographic data on the built environment are essential and present a practical approach to comprehending how assets and people are exposed to hazards. This paper presents an effective method for extracting building outlines from UAV-derived orthomosaics using a semantic segmentation approach based on a U-Net architecture with a ResNet-34 backbone (UResNet-34). The novelty of this work lies in integrating a grey wolf optimiser (GWO) to fine-tune the hyperparameters of the UResNet-34 model, significantly enhancing building extraction accuracy across various localities. The experimental results, based on testing data from four different localities, demonstrate the robustness and generalisability of the approach. In this study, Locality-1 is well-laid buildings with roads, Locality-2 is dominated by slum buildings in proximity, Locality-3 has few buildings with background vegetation and Locality-4 is a conglomeration of Locality-1 and Locality-2. The proposed GWO-UResNet-34 model produced superior performance, surpassing the U-Net and UResNet-34. Thus, for Locality-1, the GWO-UResNet-34 achieved 94.74% accuracy, 98.11% precision, 84.85% recall, 91.00% F1-score, and 88.16% MIoU. For Locality-2, 90.88% accuracy, 73.23% precision, 75.65% recall, 74.42% F1-score, and 74.06% MioU was obtained.The GWO-UResNet-34 had 99.37% accuracy, 90.97% precision, 88.42% recall, 89.68% F1-score, and 90.21% MIoU for Locality-3, and 95.30% accuracy, 93.03% precision, 89.75% recall, 91.36% F1-score, and 88.92% MIoU for Locality-4.