*Article* **Designing the Architecture of a Convolutional Neural Network Automatically for Diabetic Retinopathy Diagnosis**

**Fahman Saeed <sup>1</sup> , Muhammad Hussain 2,\*, Hatim A. Aboalsamh <sup>2</sup> , Fadwa Al Adel <sup>3</sup> and Adi Mohammed Al Owaifeer <sup>4</sup>**


**Abstract:** Diabetic retinopathy (DR) is a leading cause of blindness in middle-aged diabetic patients. Regular screening for DR using fundus imaging aids in detecting complications and delays the progression of the disease. Because manual screening takes time and is subjective, deep learning has been used to help graders. Pre-trained or brute force CNN models are used in existing DR grading CNN-based approaches that are not suited to fundus image complexity. To solve this problem, we present a method for automatically customizing CNN models based on fundus image lesions. It uses k-medoid clustering, principal component analysis (PCA), and inter-class and intra-class variations to determine the CNN model's depth and width. The designed models are lightweight, adapted to the internal structures of fundus images, and encode the discriminative patterns of DR lesions. The technique is validated on a local dataset from King Saud University Medical City, Saudi Arabia, and two challenging Kaggle datasets: EyePACS and APTOS2019. The auto-designed models outperform well-known pre-trained CNN models such as ResNet152, DenseNet121, and ResNeSt50, as well as Google's AutoML and Auto-Keras models based on neural architecture search (NAS). The proposed method outperforms current CNN-based DR screening methods. The proposed method can be used in various clinical settings to screen for DR and refer patients to ophthalmologists for further evaluation and treatment.

**Keywords:** classification; deep learning; DeepPCANet; diabetic retinopathy; medical imaging; PCA; AutoML; NAS

**MSC:** 68T07
