# TopoSinGAN: Learning a Topology-Aware Generative Model from a Single Image
## 2 Materials and Methods
### Evaluation  
#### 2.2.1 Node Topology Clustering (NTC)  
GAN evaluation metrics focusing on the topological structure of the synthetic images are rare. Conventionally, pretrained CNN-based models [36] are used to evaluate the quality of images generated by GANs. Inception score (IS) [37] and Frechet Inception Distance (FID) [38] are common methods of this type. IS calculates the Kullback-Leibler  
Figure 3: The architecture of the developed loss function. Figure 2: (**a**) The eight 3 \(\times\) 3 convolution kernels employed in the topology enhancer loss. Dark pixels represent 1 s and 0 s otherwise. (**b**) The convolution kernels’ performance for topology loss. The output of the kernel convolution (highlighted points) is overlaid on the input tensor for better visualization. divergence between the conditional and marginal class distributions across the generated data. Likewise, FID uses an Inception network pre-trained on ImageNet to map images into a feature space [39]. These models are biased toward the Inception model's feature space, while the topological properties are not guaranteed to be preserved in the feature space [32]. Therefore, recent evaluation metrics have been developed to focus more on the topological structure of the generated images to provide a more reliable quantitative description of the model performance [23; 32]. These metrics are mostly based on topological data analysis (TDA), which generally uses persistent homology (PH) to measure the similarity of the distribution of persistence diagrams for real and generated images. However, while PH-based metrics focusing on topology can provide reliable evaluations, they have limitations. These metrics are typically based on the birth and death of holes and simplices at different scales, forming the final barcodes. Consequently, the formation of these barcodes is influenced not only by topological relationships but also by geometric properties such as shape and size [40; 41]. In the context of GANs, the inherent stochasticity produces diverse images, which may include both geometric and topological variations. Moreover, TDA- and PH-based evaluation methods, such as Betti number error, are not well-suited for assessing models like ours, which consider the presence of a terminal node as a topological \"error\". TDA primarily focuses on features such as connected components and holes without explicitly accounting for terminal nodes, which we consider critical in evaluating topological accuracy. Therefore, relying solely on TDA-based metrics may not fully capture the quality and variability of the generated images. In this paper, we propose Node Topology Clustering (NTC), a novel topology-aware metric to evaluate the performance of GAN models focusing on topology and structural integrity. The NTC calculation begins with converting the input binary mask into an undirected graph. In this graph, nodes represent critical points such as terminals and junctions, and edges represent the connections between these points using straight lines. Nodes with a degree of one, referred to as terminals, are of particular interest because they indicate points of disconnectivity within the graph. Using these terminal nodes, we define a new measure called Terminal Distance (TD), which captures the distance from each node to its nearest terminal (Figure 4). **Definition 1** (Terminal Distance (TD)). : _The Terminal Distance (TD) quantifies the geodesic distance [42] in a graph, derived from a binary image mask, between each node and its nearest terminal node. Let \(G\) be an undirected graph constructed from a binary mask \(M\), where nodes represent critical points such as terminals and junctions.