Smart factories merge various technologies in a manufacturing environment in order to improve factory performance and product quality. In recent years, these smart factories have received a lot of attention from researchers. In this paper, we introduce a defective product classification system based on deep learning for application in smart factories. The key component of the proposed system is a programmable logic controller (PLC) artificial intelligence (AI) embedded board; we call this an AI Edge-PLC module. A pre-trained defective product classification model is uploaded to a cloud service from where the AI Edge-PLC can access and download it for use on a certain product, in this case, electrical wiring. Next, we setup the system to collect electrical wiring data in a real-world factory environment. Then, we applied preprocessing to the collected data in order to extract a region of interest (ROI) from the images. Due to limitations on the availability of appropriate labeled data, we used the transfer learning method to re-train a classification model for our purposes. The pre-trained models were then optimized for applications on AI Edge-PLC boards. After carrying out classification tasks, on our electrical wire dataset and on a previously published casting dataset, using various deep neural networks including VGGNet, ResNet, DenseNet, and GoogLeNet, we analyzed the results achieved by our system. The experimental results show that our system is able to classify defective products quickly with high accuracy in a real-world manufacturing environment.