## 2 Materials and Methods  
### Histopathological Whole-Slide Images  
Histopathology sections were prepared in the Department of Pathology, Taipei Medical University Hospital and Mackay Memorial Hospital. The dermatopathological samples in the database are reserved for teaching, case reviews and discussion. Formalin-fixed, paraffin-embedded skin tissue samples were prepared in 5-\(\upmu\)m-thick sections. Skin incisional biopsies were obtained, and specimens were 1-2 cm in length and 0.5-1 cm in width. Ziehl-Neelsen stained slides in the database that were digitally scanned to be included in the study. The selected specimens had a staining quality adequate for a definite diagnosis. Nine samples of cutaneous mycobacterial infection were selected, which included atypical mycobacterial infection, paucbacillary leprosy, lepromatous leprosy, and erythema nodosum leprosum. The histopathological features were suppurative inflammation, granuloma formation, and foamy cell aggregation. Differential inflammatory cell infiltration, including histiocytes, neutrophils, and mast cells, were noted in these WSIs (Table 1). Histochemical stain preparation was performed with a standard protocol for Ziehl-Neelsen staining (Muto Pure Chemicals Co., Tokyo, Japan). Ziehl-Neelsen staining emphasizes acid-fast bacilli in the histopathological slides. The presence of mycolic acid in the cell walls of the mycobacteria bacilli appears reddish after staining. The cell walls of the mycobacteria bacilli retain red carbol fuchsin, which shows high contrast to the bluish color of the background [7]. These histopathological slides were prepared according to standard protocols and digitized using a ScanScope XT whole-slide scanner (Aperio, Vista, CA, USA). The image navigation software used was Aperio ImageScope v9.1.19 (Aperio, Vista, CA, USA). This study was approved by the Macky Memorial Hospital Institutional Review Board (IRB Number: 18 MMHIS121).  
To establish gold standards, the whole-slide images were subsequently cropped to \(20\times 20\) pixel (a pixel equals 0.017 mm wide), nonoverlapping image blocks, which is the optimal size for presenting bacilli [24]. One international board-certified dermatopathologist and one international dermatopathology fellow reviewed the whole histopathological slide images and identified acid-fast positive stained bacilli. The ground-truth was established by the consensus of both during the review. Positive mycobacterial bacilli image blocks showed the presence of reddish rod-shaped bacilli with a bluish to whitish background. Negative image blocks were chosen from noninfectious areas with stained reddish, bluish or whitish colors. In the process of establishing consensus, the discordance happened to some samples with incomplete fragmented rod-shaped looking, which may be contamination or a part of bacilli. These blocks were excluded in the experiment to reduce the uncertainty. A total of 613 representative positive image blocks, including various orientations of mycobacterial bacilli and different bacillus counts, were selected (Figure 1). These positive image blocks were used in each of the following experiments, while negative samples were individually selected according to the experiment purpose. Positive and negative image blocks were then fed into a transferred DCNN for classification.