Spinal deformities, including adolescent idiopathic scoliosis (AIS) and adult spinal deformity (ASD), affect many patients. The measurement of the Cobb angle on coronal radiographs is essential for their diagnosis and treatment planning. To enhance the precision of Cobb angle measurements for both AIS and ASD, we developed three distinct artificial intelligence (AI) algorithms: AIS/ASD-trained AI (trained with both AIS and ASD cases); AIS-trained AI (trained solely on AIS cases); ASD-trained AI (trained solely on ASD cases). We used 1,612 whole-spine radiographs, including 1,029 AIS and 583 ASD cases with variable postures, as teaching data. We measured the major and two minor curves. To assess the accuracy, we used 285 radiographs (159 AIS and 126 ASD) as a test set and calculated the mean absolute error (MAE) and intraclass correlation coefficient (ICC) between each AI algorithm and the average of manual measurements by four spine experts. The AIS/ASD-trained AI showed the highest accuracy among the three AI algorithms. This result suggested that learning across multiple diseases rather than disease-specific training may be an efficient AI learning method. The presented AI algorithm has the potential to reduce errors in Cobb angle measurements and improve the quality of clinical practice.