{'fraction_non_alphanumeric': 0.022932958439504436, 'fraction_numerical': 0.005755206045162991, 'mean_word_length': 5.1223776223776225, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unsupervised Domain Adaptation with Histogram-gated Image Translation for Delayered IC Image Analysis

Deep learning has achieved great success in the challenging circuit annotation task by employing Convolutional Neural Networks (CNN) for the segmentation of circuit structures. The deep learning approaches require a large amount of manually annotated training data to achieve a good performance, which could cause a degradation in performance if a deep learning model trained on a given dataset is applied to a different dataset. This is commonly known as the domain shift problem for circuit annotation, which stems from the possibly large variations in distribution across different image datasets. The different image datasets could be obtained from different devices or different layers within a single device. To address the domain shift problem, we propose Histogram-gated Image Translation (HGIT), an unsupervised domain adaptation framework which transforms images from a given source dataset to the domain of a target dataset, and utilize the transformed images for training a segmentation network. Specifically, our HGIT performs generative adversarial network (GAN)-based image translation and utilizes histogram statistics for data curation. Experiments were conducted on a single labeled source dataset adapted to three different target datasets (without labels for training) and the segmentation performance was evaluated for each target dataset. We have demonstrated that our method achieves the best performance compared to the reported domain adaptation techniques, and is also reasonably close to the fully supervised benchmark.


I. INTRODUCTION
Integrated Circuit (IC) analysis is a highly reliable approach for hardware assurance, and it is commonly employed for applications such as hardware Trojan detection [1], intellectual property protection [2], and counterfeit detection [3]. Circuit extraction is one of the most accurate methods for manufactured IC analysis, and it consists of several steps, including package removal, chip delayering, imaging, circuit annotation, schematic read-back and final circuit analysis [4]- [8]. Circuit annotation is a critical step in circuit extraction, as it transforms the image information taken of an actual IC device to a digital representation of all the circuitry in the device. Fig. 1(a) illustrates our circuit annotation task, whereby the scanning electron microscopy (SEM) images (left) are annotated and the objective is to obtain predictions (right) that are as close as possible to the ground truths (middle). Image processing techniques such as histogram analysis [9] and machine learning techniques such as support vector machine [10] have been reported for the annotation of circuit structures, but their performance could be hampered when encountered with noise, pixel intensity variations, or texture differences in the IC images. With the rapid rise in popularity of deep learning in recent years, Convolutional Neural Networks (CNN) have been applied for a multitude of tasks in IC and printed circuit board (PCB) analysis [11]- [13]. In [13]- [15], deep learning networks such as Fully Convolutional Network (FCN) [16] and U-Net [17] were reported for circuit annotation by formulating it as a pixel-wise segmentation task. The deep learning methods were reported to achieve significantly better performance than the conventional image processing and machine learning methods for circuit annotation.
However, the performance of deep learning methods could be degraded when applied to circuit images belonging to different ICs or different layers from a single IC. Fig. 1(a) depicts a satisfactory result for circuit annotation that was obtained by a fully supervised model trained on a given circuit dataset. The performance is far from satisfactory if the same model is utilized for circuit annotation of another IC dataset, as depicted in Fig. 1(b). The performance degradation is caused by the discrepancy in distribution of the IC images from the different datasets. This could be due to differences in distribution of pixel intensities, the amount of contrast between background and foreground, the presence of noise, etc. This is commonly known as the domain shift challenge in circuit images, which could stem from variations in the IC manufacturing process, sample preparation process, or imaging process [5]. The conventional way to tackle the domain shift challenge is by repeating the fully supervised method, including the data collection and labeling process, for every new dataset to be analyzed. However, this could be impractical as it requires a large amount of manual effort and has to be repeated for different ICs or for different layers from a single IC.
To address the above-mentioned domain shift problem, we intend to utilize an IC dataset with known labels (denoted as the source dataset) for the training of a segmentation model, and adapt it to another dataset without labels (denoted as the the target dataset). This is known as the unsupervised domain adaptation scenario. We explore techniques which can leverage labeled data in the source domain and transfer the learned knowledge to adapt the model to the target domain [18]. The aim is to eliminate the need for manual labeling in the target dataset when training a deep learning model for circuit annotation, whilst still achieving an acceptable segmentation accuracy.
In this paper, we propose Histogram-gated Image Translation (HGIT), an unsupervised domain adaptation framework for circuit annotation. Our method leverages generative adversarial networks (GAN) [19] for image translation, which are trained on just the unlabeled source and target circuit images, and then utilized to transform the source images into the domain of the target images. We then perform a statistical comparison between the histograms of the transformed images and the target dataset to curate the transformed images. The curated transformed images are paired with the source masks for the training of a segmentation model for circuit annotation. The trained segmentation model is subsequently applied to the target circuit images for circuit annotation.
The contributions of this paper are summarized as follow: • We propose HGIT, an unsupervised domain adaptation framework for circuit annotation that combines GANbased image translation and histogram-based data curation.
• Our HGIT demonstrated the best performance as compared to the reported domain adaptation techniques, achieving a 8.76% improvement in segmentation performance as compared to the second best method. • Our HGIT does not require any additional data labeling on the target dataset, significantly saving time and effort when performing the analysis on new datasets of different ICs or different layers. • To the best of our knowledge, this is the first work utilizing unsupervised domain adaptation for IC image analysis.

II. RELATED WORK
Unsupervised domain adaptation leverages sufficient labeled data in a source domain and transfers the learned knowledge to adapt a segmentation model to the target domain. It has attracted significant research interest in recent years due to its ability to remove the need for manual annotation on new datasets. Domain adaptation involves the alignment of the domain shift between the distributions of a known source dataset and a new or unknown target dataset. Image translation, feature matching, or a combination of image and feature matching have been reported for unsupervised domain adaptation.
Image translation is popularly adopted for domain adaptation, which could be achieved with techniques such as image processing and generative adversarial networks (GAN)-based [19] methods. Conventional image processing techniques were adopted for image translation in [20], where histogram matching was utilized to align the histogram statistics of the source domain with the target domain. Histogram matching involves transforming the probability density function of pixel intensities in the source images to become the same as the target images. However, histogram matching could have a degraded image translation performance in IC images with few circuit structures, whereby enforcing a specific pixel intensity distribution could cause unwanted bright or dark regions in the transformed images, which is not ideal for segmentation model training.
GAN-based techniques have achieved promising performance for image translation in multiple domains [21]- [23]. CycleGAN [21] employs a GAN-based framework with a cycle consistency loss to learn the transformation from source to target domain (and vice-versa) while preserving the semantic content of the images. The transformation is achieved by training a pair of generator networks with a cycle consistency loss that enforces that the image from the original domain can be recovered after performing a two way translation. Adversarial training with a discriminator network [19] is also implemented in CycleGAN to achieve good realism in the transformed images. However, due to the stochastic nature of neural network training, it can be difficult to ensure the quality of all the transformed images without performing visual inspection of the transformed results.
Fourier domain adaptation (FDA) proposed in [24] utilized Fourier Transform to transfer the frequency features of the target domain to the source domain to achieve image translation.

Image Translation Network
2) Histogram-gated Image Translation

Histogrambased Data Curation
Source Images Transformed Images Transformed Images

Segmentation Network
Source Masks

4) Circuit Annotation of Target Images Segmentation Network
Target Images Annotation Result

Image Translation Network
Source Images Target Images The low frequency part of the source amplitude is replaced with the corresponding region from the target amplitude and an inverse Fourier Transform is then computed to obtain the transformed image. One key advantage of FDA is that it does not require the training of a deep neural network for the translation step. However, the transformation quality could be degraded on circuit images that have a lower visual complexity or a small spatial dimension. The Simplified Unsupervised Image Translation (SUIT) technique proposed in [25] combines feature and image alignment for effective domain adaptation. A consistency loss achieved through a separate segmentation network and a feature extractor (using pre-trained CNN) was introduced to improve the feature alignment of source and target domain. The consistency loss is utilized to optimize the generator network to improve the visual appearance of the transformed images.

III. METHODOLOGY
In unsupervised domain adaptation for circuit annotation, we denote the labeled source domain as D S = {(X S , Y S )} and the unlabeled target domain as D T = {X T }, where X S is the set of all source images, Y S is the set of all source masks (ground truth labels) associated with X S , and X T is the set of target images. The goal is to utilize the labeled source domain and unlabeled target domain to train a segmentation network to annotate the target images, without performing any manual labeling of the target images. Fig. 2 depicts our unsupervised domain adaptation framework for circuit annotation, consisting of 4 main steps including training of image translation network, histogram-gated image translation, training of segmentation network, and circuit annotation of target images. We now delineate each component of our framework in the following sections.

A. Train Image Translation Network
We adopt the CycleGAN framework [21] for image translation from the source to target domain. The goal is to obtain an image translation network that can transform the source images into the style of the target images. To achieve this, a pair of encoder-decoder networks (G S→T , G T →S ) are trained to transform images from source to target domain and target to source domain respectively. Both networks are trained on the source and target images X S and X T in an unsupervised manner with the cycle consistency loss L cyc given in where E represents the mean value computed across the training samples.

B. Histogram-gated Image Translation
Image translation is performed by G S→T to transform the source images into the style of the target images, obtaining the transformed images X T given by (2). X T should retain the same semantic content (i.e., metal lines should have the same location) as the source images X S , while having a similar visual appearance to the target domain.
The transformed images that have a smaller domain gap to the actual target images are then selected with histogrambased data curation. The histogram distribution of all the target images are first computed and averaged to obtain the mean histogram profile. Next, a Kolmogorov-Smirnov [26] statistical test was performed on the histogram distribution of each transformed image against the average histogram distribution of the target dataset. The p-values obtained are used as a similarity measure between the transformed images and target images. The transformed images are then curated by selecting the top N % of images for the subsequent training of a segmentation network, and we set the value of N to 70 in our experiments.

C. Train Segmentation Network
The transformed images X T are paired with the source masks Y S to train a segmentation network F . Our unsupervised domain adaptation framework is architecture agnostic and different segmentation network architectures can be used. For our metal line circuit annotation task, the pixel-wise binary cross entropy loss given in (3) is utilized to optimize the network parameters.
where F represents the segmentation network.

D. Annotation of Target Images
The trained segmentation network is finally applied for the annotation of the target images X T . This produces the predicted target masks which are the annotation results Y T , as given in (4). Error correction can be performed on the predicted target masks, and the subsequent steps of circuit extraction can be carried out.

IV. EXPERIMENTS
We have evaluated our proposed framework in comparison with several reported techniques for domain adaptation. In another setting, we also establish an upper bound benchmark through a fully supervised method for additional comparison. The pixel-wise segmentation accuracy (SA) and Intersectionover-Union (IoU) was evaluated and utilized as the comparison metric across models. In the following sections, we describe the dataset and implementation details, and then present the experimental results.

A. Dataset
In our experiments, we utilize 4 datasets from different ICs or different layers, as summarized in Table I. For each dataset, there are around 1,500 total images of dimension 128×128 pixels, and we utilize a train test split of 80:20. The Device-1 Metal 2 (M2) layer is designated as the source dataset while the 3 other datasets from different ICs or different layers are designated as the target datasets. The pixel-wise ground truth labels were prepared using the semi-automated labeling method from [14].
There are 3 distinct evaluation scenarios in our experiments, including source only, unsupervised domain adaptation, and  [20], FDA [24], SUIT [25], and CycleGAN [21]) and our proposed HGIT. For the unsupervised domain adaptation scenario, the source training images are adapted to the target domain, and then paired with the source training masks for training a segmentation network. The trained segmentation network is then applied to the respective set of target testing images for evaluation, and this is repeated for the 3 different target datasets. Lastly, the fully supervised scenario is implemented as an upper bound benchmark. In this scenario, a segmentation network is trained on the target training images and masks, and the trained segmentation network is applied to the respective set of target testing images for evaluation.

B. Implementation Details
All experiments in this paper were implemented with the PyTorch [27] framework on a single NVIDIA A5000 GPU 1 . We now describe the implementation details for each of the reported domain adaptation techniques. For histogram matching, the histogram statistics of the source training images were transformed to the average histogram profile of the target training images. For FDA, we utilized the publicly available implementation 2 and transform each of the source images to a randomly sampled target image to be used for training. For CycleGAN, a transformation network was trained on the source training images and target training images using the publicly available implementation 3 . The source training images were then translated with the transformation network into the style of the target domain. The transformed images (in the style of the target domain) were then utilized to train  a segmentation network with the source masks as the ground truth labels. For the SUIT technique, training of a transformation and segmentation network was performed in a single stage using the source training images, source masks and target training images as inputs. The trained segmentation network was utilized for evaluation on the target testing dataset. For our proposed HGIT, image translation was performed on the source training images, and the top 70% of transformed images were selected for further training based on the statistical similarity of histogram distribution to the average target histogram. The selected transformed images were then utilized to train a segmentation network with the source mask as ground truth labels.

C. Evaluation Metrics
We utilize two popular metrics for evaluation and comparison in our experiments, namely the pixel-wise segmentation accuracy (SA) and Intersection-over-Union (IoU) [28]. Circuit annotation is a single class, pixel-wise classification of metal lines. We first define several key terms: metrics across the 3 datasets are presented for an overall comparison. Our proposed HGIT has achieved the highest performance in comparison to all the reported techniques. When averaged across the 3 datasets, we have achieved an improvement of 7.08% and 8.76% in the pixel-wise segmentation accuracy and IoU respectively, as compared to the second best reported technique (CycleGAN). Furthermore, our method has achieved a reasonably close performance to the upper bound benchmark for the Device-1 M1 set (less than 2% difference) and the Device-3 M3 set (less than 4% difference). For the Device-2 M6 dataset, all the reported techniques have achieved a significant improvement as compared to the baseline method (Source Only), but the absolute segmentation performance is far from the upper bound benchmark. This is because the Device-2 M6 images have a much lower pixel intensity (darker in appearance) and a lower contrast between circuit structures as compared to the source dataset, which results in a larger domain gap between the two datasets. Fig. 3 depicts the segmentation results of the reported domain adaptation methods and our proposed technique when applied to a sample from each of the 3 target domains. From Fig. 3, we can see that that our HGIT could perform the metal line annotations on each of the sample target images without incorrect breakage or joining of metal lines, and has achieved the best segmentation performance as compared to the other reported techniques.

E. Study on Histogram-gating and Image Translation
The objective of image translation is to transform the images from the source domain into a transformed image that is similar to the target domain. A zoomed out sample of each target domain is shown on the left of Fig. 4. Our proposed HGIT performs image translation with CycleGAN on the source images to the target domain, and two examples of such transformed images are depicted in the middle of Fig.  4. Out of the two transformed images, the 'Good' column is visually similar to the target image, and also contains some circuit structures such as metal lines for segmentation model training. However, CycleGAN could produce images that are not optimal for training, as depicted in the 'Poor' column in Fig. 4.
Image translation with GANs generally produce realistic transformed images that are highly similar to the target domain, but there could still be failure cases. This could be a result of insufficient circuit structures as seen in the poor transformed images in Fig. 4 for target domain (a) and (c) where the majority of the transformed image is the background or metal line only. Another failure case can be seen in Fig. 4(b) whereby the metal line regions in the transformed images were abnormally brightened, which could be due to the stochastic nature of GAN training. This demonstrates the importance of curating the transformed images before utilizing them for training a segmentation network in an unsupervised domain adaptation framework.
The histogram statistics of the averaged target domain are also presented, along with the histogram statistics of the two transformed images. We can observe that the poorly transformed images have a significant difference in the histogram distribution as compared to the good transformed images. In the histogram-based data curation step (See earlier Section III-B for more details), we curate the optimal transformed images for training a segmentation network, and the poor transformed images exemplified in Fig. 4 were successfully removed by our proposed HGIT.
V. CONCLUSION AND FUTURE WORK In this paper, we have proposed HGIT, an unsupervised domain adaptation framework for delayered IC image analysis. We have demonstrated its effectiveness as a broad method that can avoid labor intensive manual data labeling in circuit annotation. HGIT performs GAN-based image translation to transform the source images to be similar to the target images, and we curate the good translation results for further training based on histogram statistics. We have evaluated our proposed HGIT in comparison with four reported domain adaptation techniques on three different target datasets obtained from different ICs. Our method has achieved the best performance out of all the reported techniques, and it is also reasonably close to the fully supervised benchmark. Our HGIT and unsupervised domain adaptation methods in general are promising for greatly reducing the amount of manual effort in practical applications of delayered IC image analysis.
In a future work, it would be valuable to evaluate a larger number of IC datasets with different image distributions, and study the interactions between different types of source and target datasets.