Intraoperative specimen mammography is a valuable tool in breast cancer surgery, providing immediate assessment of margins for a resected tumor. However, the accuracy of specimen mammography in detecting microscopic margin positivity is low. We sought to develop an artificial intelligence model to predict the pathologic margin status of resected breast tumors using specimen mammography. A dataset of specimen mammography images matched with pathologic margin status was collected from our institution from 2017 to 2020. The dataset was randomly split into training, validation, and test sets. Specimen mammography models pretrained on radiologic images were developed and compared with models pretrained on nonmedical images. Model performance was assessed using sensitivity, specificity, and area under the receiver operating characteristic curve (AUROC). The dataset included 821 images, and 53% had positive margins. For three out of four model architectures tested, models pretrained on radiologic images outperformed nonmedical models. The highest performing model, InceptionV3, showed sensitivity of 84%, specificity of 42%, and AUROC of 0.71. Model performance was better among patients with invasive cancers, less dense breasts, and non-white race. This study developed and internally validated artificial intelligence models that predict pathologic margins status for partial mastectomy from specimen mammograms. The models' accuracy compares favorably with published literature on surgeon and radiologist interpretation of specimen mammography. With further development, these models could more precisely guide the extent of resection, potentially improving cosmesis and reducing reoperations.