SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Recently, there have been various attempts at defining domain-specific scores [30-32] as well as generic scores for evaluating the quality of synthetic images. Examples include the FID score which is based on a distributional distance between real and synthetic images [33]. Other examples for sample-level evaluation metrics include the precision and recall metrics [21] which check if synthetic data resides in the support of the real data distribution. However, these scores do not encode clinical domain knowledge, which is critical for identifying failures in generating clinically meaningful images. Traditional scores of medical image quality include signal- and contrast-to-noise ratio [34-36], mean structural similarity [37]. These scores are typically applied to real images and cannot be repurposed to judge the generative capacity of a synthetic data model in a meaningful way. The lack of an automated score for detecting clinically implausible synthetic medical images is a key motivation for our work. We believe that the most reliable way to assess the quality of a synthetic image is to have it evaluated by an expert pathologist. From this perspective, the reward model  $\Gamma$  in Section 2.2 can be thought of as a data-driven score for image quality trained using pathologist evaluations.
Learning from human feedback. The success of many modern generative models can be attributed in part to finetuning using feedback solicited from human annotators. The utilization of human feedback in model finetuning is very common in natural language processing applications, particularly in finetuning of large language models (LLMs). Examples for applications were human feedback was applied include translation [38], web question-answering [39] and instruction tuning [40-42]. The key idea in these applications is that by asking a human annotator to rate different responses from the same model, one can use such annotations to finetune the model to align with human preference. Similar ideas have been applied to align computer vision models with human preferences [20, 43-46]. In the context of our application, the goal is to align the outputs of a generative model with the preferences of pathologists, which are naturally aligned with clinical domain knowledge. Our finetuning objective builds on the recent work in [20] and [45], which use human feedback to align text-prompts with generated images using a reward-weighted likelihood score.
In this Section, we conduct a series of experiments to evaluate the utility of pathologist feedback in improving the quality of synthetic medical images. In the next Subsection, we start by providing a detailed description of the single-cell bone marrow image dataset used in our experiments.
4.1 Bone marrow cells dataset
In all experiments, we used a dataset of hematopathologist consensus-annotated single-cell images extracted from bone marrow aspirate (BMA) whole slide images. The images were obtained from the
Morphological cell type	Code	Real data	Synthetic data	Pathologist feedback
Training	Testing	Plausible	Implausible
Mast Cell	B1	128	32	213	72	141
Basophil	B2	128	32	214	29	185
Immature Eosinophil	E1	128	32	213	49	164
Mature Eosinophil	E4	128	32	224	53	171
Pronormoblast	ER1	128	32	256	97	159
Basophilic Normoblast	ER2	128	32	256	49	207
Polychromatophilic Normoblast	ER3	128	32	256	129	127
Orthochromic Normoblast	ER4	128	32	256	118	138
Polychromatophilic Erythrocyte	ER5	128	32	256	141	115
Mature Erythrocyte	ER6	128	32	256	120	136
Myeloid Blast	M1	128	32	256	138	118
Promyelocyte	M2	128	32	256	107	149
Myelocyte	M3	128	32	256	131	125
Metamyelocyte	M4	128	32	256	88	168
Mature Neutrophil	M5	128	32	256	80	176
Monocyte	MO2	128	32	256	83	173
Table 2: Breakdown of bone marrow image patches by morphological cell type and pathologist feedback.
clinical archives of an academic medical center. The dataset comprised 2,048 images, with the images evenly distributed across 16 morphological classes (cell types), with 160 images per class (Table 2). These classes encompass varied cell types found in a standard bone marrow differential. The dataset covers the complete maturation spectrum of Erythroid and Neutrophil cells, from Proerythroblast to mature Erythrocyte and from Myeloid blast to mature Neutrophils, respectively. The dataset also differentiates mature Eosinophils with segmented nuclei from immature Eosinophils and features Monocytes, Basophils, and Mast cells. Bone marrow cell counting and differentiating between various cell types is a complex task that poses challenges even for experienced hematologists. Hence, we expect pathologist feedback to significantly improve the quality of bone marrow image synthesis.
4.2 Synthetic data generation and pathologist feedback collection
We used a conditional diffusion model trained on real images  $(64\times 64$  pixels in size) to generate synthetic image patches. Training was conducted using 128 images per cell type, with 32 images per cell type held out for testing and evaluating all performance metrics. For the reward model  $\Gamma (x,c)$ , we used a ResNeXt-50 model [47] pre-trained on a cell type classification task to obtain embeddings for individual images, and then concatenated the embeddings with one-hot encoded identifiers of image class (cell type) as inputs to a feed-forward neural network that predicts clinical plausibility. Further details on model architectures and selected hyper-parameters are provided in the Appendix.
We collected feedback from an expert pathologist on 3,936 synthetic images generated from the diffusion model. The pathologist identified most of these images as implausible—the rate of implausible images was as high as  $85\%$  for some cell types (e.g., Basophil cells, see Table 2). After training the reward model using pathologist feedback, we finetune the diffusion model as described in Section 2.
Expert evaluation of synthetic data quality. To evaluate the impact of pathologist feedback on the generated synthetic data, we created two synthetic datasets: a sample from the diffusion model (before finetuning with pathologist feedback) and a sample from the finetuned version of the model after incorporating the pathologist feedback. Each dataset comprised 400 images (25 images per cell type). An expert pathologist was asked to evaluate the two samples and label each image as plausible or implausible (in a manner similar to the feedback collection process).
Table 3 lists the fraction of clinically plausible images per cell type for the two synthetic datasets (before and after finetuning using the pathologist feedback) as evaluated by an expert hematopathologist. As we can see, the pathologist feedback leads to a significant boost in the quality of synthetic images across all cell types, increasing the average rate of clinical plausibility from 0.21 to 0.75. Note that in this experiment, the human evaluator emulates the reward function  $\Gamma(x, c)$ . Hence, the improved performance of the finetuned model indicates success in learning the pathologist preferences.
Evaluating synthetic data using fidelity & diversity scores. In addition to expert evaluation, we also evaluated the two synthetic datasets generated in the previous experiment using standard metrics for evaluating generative models. We considered the Precision, Recall and Coverage metrics [21, 22].
% Clinically plausible
No feedback	Path. feedback
B1	0.40	0.92
B2	0.16	1.00
E1	0.12	0.80
E4	0.24	0.52
ER1	0.44	0.96
ER2	0.28	0.64
ER3	0.24	0.68
ER4	0.20	0.84
ER5	0.20	0.76
ER6	0.20	0.96
M1	0.20	0.84
M2	0.20	0.64
M3	0.08	0.56
M4	0.20	0.84
M5	0.08	0.68
MO2	0.12	0.40
Table 3: Expert evaluation of synthetic data.
Training data	Precision	Recall	Coverage
Synthetic (no feedback)	68.06	52.00	56.98
Synthetic (auto, feedback)	74.80	43.90	61.33
Synthetic (with feedback)	81.01	56.74	84.57
Table 4: Evaluation of synthetic data using fidelity and diversity metrics.
Training data	F1	Accuracy	Precision	Recall
Synthetic (no feedback)	60.33	95.17	61.33	65.56
Synthetic (auto. feedback)	63.47	95.58	64.64	65.68
Synthetic (with feedback, Ds)	71.80	96.41	71.29	74.51
Synthetic (with feedback, D1)	75.80	96.95	75.59	76.51
Real	79.03	97.39	79.10	79.47
Table 5: Accuracy of classifiers trained on real and synthetic data.
Precision measures the fraction of synthetic samples that resides in the support of the real data distribution and is used to measure fidelity. Recall and Coverage measure the "diversity" of synthetic samples, i.e., the fraction of real images that are represented in the output of a generative model. In addition to the two synthetic datasets (with and without feedback) generated in the previous experiment, we also evaluated a third synthetic dataset finetuned using the automatic feedback (classifier-guidance) approach described in Section 2.5. The results in Table 4 show that pathologist feedback improves the quality of synthetic data compared to the two baselines across all metrics under consideration. Interestingly, we see that feedback not improves fidelity of synthetic images, but it also improves the diversity of samples, which was not one the criteria considered in the pathologist feedback.
Downstream modeling with synthetic data. Morphology-based classification of cells is a key step in the diagnosis of hematologic malignancies. We evaluated the utility of synthetic medical images in training a cell-type classification model. In this experiment, we train a ResNext-50 model to classify the 16 cell types using real data, synthetic data from the pretrained model with no feedback, and synthetic data from the model finetuned with pathologist feedback. To ensure a fair comparison, we created synthetic datasets consisting of 128 images per cell type, matching the size of the real data. The classification accuracy of all models was then tested on the held-out real dataset, containing 32 images per cell type. Results are shown in Table 5. Unsurprisingly, the model trained on real data demonstrated superior performance across all accuracy metrics, exhibiting a significant gap compared to the model trained on synthetic data without human feedback. However, incorporating pathologist feedback helped narrow this gap and improved the quality of synthetic data to the point where the resulting classifiers only slightly underperformed compared to the one trained on real data.
To evaluate the marginal value of human feedback, we also considered two ablated versions of our synthetic data generation process. These included a synthetic dataset generated using automatic feedback (Section 2.5) as well as a reward model trained using the pathologist feedback on synthetic data only (i.e., dataset  $\mathcal{D}_s^\Gamma$ ) without real data augmentation (Section 2.2). The results in Table 5 show that automatic feedback only marginally improves performance, which aligns with the results in Table 4. Real data augmentation (i.e., finetuning on  $\mathcal{D}_s^\Gamma + \mathcal{D}_r^\Gamma$ ) slightly improves classification accuracy, but most of the performance gains are achieved by finetuning on the pathologist-labeled dataset  $\mathcal{D}_s^\Gamma$ .
Impact of the number of feedback points. How much human feedback is necessary to align the generative model with the preferences of pathologists? In Figure 4, we analyze the effect of different amounts of pathologist-labeled synthetic images on training the reward model. We explore four scenarios:  $0\%$ ,  $10\%$ ,  $50\%$ , and  $100\%$  of the 3,936 synthetic images labeled by the pathologist. For each scenario, we fine-tune the pretrained model using a reward model trained with the corresponding fraction of synthetic images. We then repeat the cell classification experiment to evaluate the accuracy of the classifiers trained using synthetic data generated in these four scenarios. Figure 4(a) shows that as the number of pathologist-labeled synthetic images increases, all accuracy metrics increase to improve over the pretrained model performance and become closer to the accuracy of training on real data. Additionally, we see that even a modest amount of feedback (e.g.,  $10\%$  of pathologist-labeled synthetic images) can have a significant impact on performance. Figure 4(b) also show the qualitative improvement in the quality of synthetic images as the amount of human feedback increases.
Incorporating new clinical concepts using pathologist feedback. Finally, we evaluate the feedback-driven generation approach outlined in Section 2.4. Here, our goal is not only to leverage pathologist
(a) Accuracy improvement with feedback
(b) Qualitative improvement in synthetic data quality with human feedback
(c) Feedback-driven generation of cell sub-types
Figure 4: Quantitative and qualitative impact of pathologist feedback on synthetic images. (a) Accuracy of cell-types classifiers trained on synthetic data with varying amounts of pathologist feedback. (b) Visual inspection of random synthetic samples from diffusion models finetuned with with varying amounts of pathologist feedback. (c) Feedback-driven conditional generation of new (segmented and band) subtypes of Neutrophil cells.
feedback for rating the plausibility of synthetic images, but also to harness their expertise in providing additional annotations that can enable the conditional diffusion model to generate more refined categories of bone marrow image patches, e.g., abnormal cell types that develop from preexisting normal cell types. Hence, refining the generative model to synthesize new cell subtypes can help continuously update the model to capture new pathological cells and build downstream diagnostic models.
In this experiment, we focus on finetuning the model to distinguish between band Neutrophils and segmented Neutrophils (Figure 5(c)). These two sub-categories are often lumped together in bone marrow cell typing, as was the case in our dataset (see Table 2). However, in many clinical settings, differentiating between the two subtypes is essential. For instance, a high percentage of band Neutrophils can indicate an acute infection, inflammation, or other pathological conditions. We collected pathologist annotations of band and segmented Neutrophils, and trained a subtype classifier to augment the plausibility reward as described in Section 2.4. The finetuned model was able to condition on the new classes and generate plausible samples of the two Neutrophil subtypes (Figure 5(c)), while retaining the classification accuracy with respect to the new classes (See Appendix for detailed results).
Synthetic data generation holds great potential for facilitating the sharing of clinical data and enriching rare diseases datasets. However, existing generative models and evaluation metrics lack the ability to incorporate clinical knowledge. Consequently, they often fall short in producing clinically plausible and valuable images. This paper introduces a pathologist-in-the-loop framework for generating clinically plausible synthetic medical images. Our framework involves finetuning a pretrained generative model through feedback provided by pathologists, thereby aligning the synthetic data generation process with clinical expertise. Through the evaluation of synthetic bone marrow patches by expert hematopathologists, leveraging thousands of feedback points, we demonstrate that human input significantly enhances the quality of synthetic images. These results underscore the importance of incorporating human feedback in clinical applications, particularly when generative models encounter challenges in capturing nuanced domain knowledge solely from raw data.
A.1 Exploratory analysis of generative models
To select the generative model underlying our pathologist-in-the-loop framework, we conducted an exploratory analysis for the performance of various models, including conditional GANs, a conditional diffusion model, and a latent diffusion model [1]. Following an evaluation of these models, we selected the conditional diffusion model as our baseline for incorporating human feedback. The decision to choose the conditional diffusion model as our baseline was based on the fact that it outperformed the other baselines when pretrained on the bone marrow image patches. The rationale for selecting the best performing model in the pre-training phase is that the marginal value of pathologist feedback is best assessed when incorporated into a model that already performs well without feedback.
We found that the conditional GAN model did not converge to a reliable set of parameters and was therefore deemed unfit as a base model in our framework. The latent diffusion model demonstrated the ability to generate visually appealing cell images, but a majority of these images did not correspond to the intended class labels. (See Table A.1 and Figure A.1 for a quantitative and qualitative comparison of all baseline generative models.) In addition to these generative baselines, we also finetuned the Stable Diffusion model on our dataset, but the resulting images displayed an artistic style that could not be identified by expert as realistic bone marrow slides.
Table A.1: Performance comparison for baseline generative models in the cell classification task.
Training Data	Test Data	AUC	F1	Precision	Recall
Conditional diffusion model	Real	0.929482	0.567672	0.604237	0.604146
Conditional GAN model	Real	0.413551	0.003225	0.002186	0.015804
Conditional Latent diffusion model	Real	0.566388	0.008565	0.048372	0.051456
Figure A.1: Representative samples from different baseline models
A.2 Dataset details, image acquisition and annotation
Our dataset was created from pathology slides for bone marrow aspirate. All slides were randomly selected from the clinical service based on normal morphology and adequate specimen. The slides were stained using a version of the Fisherbrand modified Wright-Giemsa Stain Pack. The quality of images varied across slides, reflecting variations in stain intensity, slide preparation, and slide age.
Cell types included in our analysis. The 16 image classes listed in Table 2 cover most cell types included in a standard bone marrow differential. A very broad spectrum of Erythroid and Neutrophil maturation was included, from Proerythroblast to mature Erythrocyte, and from Myeloid blast to Neutrophil. Eosinophils were separated into mature Eosinophils with segmented nuclei and immature Eosinophils. In addition, the set included Monocytes, Basophils and Mast cells. We extracted 128 images per class for training and 32 image per class for evaluating performance metrics.
Pathologist annotation and criteria for clinical plausibility. Clinicians consider various aspects when annotating the (real) bone marrow cell images, and these aspects also underlie the criteria for evaluating the plausibility of synthetic images (Table 1). These criteria include (1) Cell size: Cells can be classified based on their size, ranging from small to large. (2) Nucleus shape and size: The shape and size of a cell nucleus can provide valuable information about the cell type. For instance, band
Neutrophils have a horseshoe-shaped nucleus, while segmented Neutrophils have a multi-lobed nucleus. (3) Nucleus-to-cytoplasm ratio: The proportion of the cell occupied by the nucleus compared to the cytoplasm vary across cell types. Immature cells usually have a larger nucleus-to-cytoplasm ratio, while mature cells have a smaller ratio. (4) Chromatin pattern: The appearance of chromatin (DNA and proteins) within the nucleus can offer clues to the cell type. For example, Lymphocytes typically have dense, clumped chromatin, while Myeloid cells have a more diffuse, fine chromatin pattern. (5) Cytoplasm color and consistency: The color and texture of a cell cytoplasm can be indicative of its type. Erythroid cells have a deeply Basophilic (blue) cytoplasm, while Myeloid cells have a lighter, Eosinophilic (pink) cytoplasm. (6) Granules: The presence, size, number, and color of granules within the cytoplasm can help identify cell types. Neutrophils have small, pale granules, Eosinophils have large, orange-pink granules, and Basophils have large, dark purple granules.
A.3 Model architecture
Diffusion model. We used conditional diffusion [48] as our baseline generative model. Our fine-tuning pipeline is based on public repository (https://github.com/openai/improved-diffusion.git). The model was fine-tuned using the Adam optimizer [49]. The model is trained in half-precision on  $2 \times 24$  GB NVIDIA GPUs, with a per-GPU batch size of 16, resulting in a toal batch size of 32. We used a learning rate of 104, and an exponential moving average over parameters with a rate of 0.9999.
Classification model. To evaluate the utility of synthetic data in downstream tasks, we trained a classification model to classify cell types in synthetic data and tested its performance in real data. We implemented this classifier using the ResNeXt-50 architecture, which have been shown to display good performance in classifying bone marrow cells in [50]. (ResNeXt is a convolutional neural network architecture, which combines elements of of VGG, ResNet and Inception models.) The network was initialized using weights from ImageNet dataset and then trained using our dataset.
Reward model. The reward model  $\Gamma(x, c)$  takes the image and its cell type as input, and issues a plausibility scores that predicts whether a pathologist would label the image as clinically plausible. The reward model was constructed as a feed-forward neural network that operates on the cell type as well as the embedding feature of images extracted from the ResNext network structure.
B Performance Metrics for Generative Models
We implemented the evaluation scores for generative models in Section 4.3 based on publicly released repository (https://github.com/clovaai/generative-evaluation-prdc). The precision and recall scores, originally introduced in [21], are formally defined as:
$$
\text {P r e c i s i o n} = \frac {1}{M} \sum_ {j = 1} ^ {M} 1 _ {\left\{Y _ {j} \in \operatorname {M a n i f o l d} \left(X _ {1}, \dots , X _ {N}\right) \right\}}, \text {R e c a l l} = \frac {1}{N} \sum_ {j = 1} ^ {N} 1 _ {\left\{X _ {j} \in \operatorname {M a n i f o l d} \left(Y _ {1}, \dots , Y _ {M}\right) \right\}},
$$
where the manifold is the defined as  $\mathrm{Manifold}(X_1,\dots ,X_N)\coloneqq \bigcup_{i = 1}^{N}B(X_i,\mathrm{NND}_k(X_i))$ , with  $B(x,r)$  being a Euclidean ball around the point  $x$  with radius  $r$  and  $\mathrm{NND}_k(X_i)$  is the distance to the  $k - th$  nearest neighbour. The coverage metric is defined as follows:
$$
\text {C o v e r a g e} = \frac {1}{N} \sum_ {i = 1} ^ {N} 1 _ {\left\{\exists j \text {s . t .} Y _ {j} \in B \left(X _ {i}, \mathrm {N N D} _ {k} \left(X _ {i}\right)\right) \right\}}.
$$
In the definitions above,  $\{X_{i}\}_{i}$  denotes the real sample and  $\{Y_j\}_j$  denotes the synthetic sample. The precision metric evaluates the fraction of synthetic samples that reside in the real data manifold, whereas the recall and coverage metrics evaluate the fraction of real samples that are represented in the synthetic sample. Precision can be though of as an automated score for clinical plausibility.
C Incorporating New Clinical Concepts using Pathologist Feedback
In Section 4.3, we discussed the use of human feedback to provide additional annotations that can enable the conditional diffusion model to generate more refined categories of bone marrow image patches. In this experiment, we finetuned the model to distinguish between band Neutrophils and
segmented Neutrophils (Figure 5(c)). These two sub-categories are often lumped together in bone marrow cell typing, as was the case in our dataset (see Table 2). However, in many clinical settings, differentiating between the two subtypes is essential. For instance, a high percentage of band Neutrophils can indicate an acute infection, inflammation, or other pathological conditions. We collected pathologist annotations of band and segmented Neutrophils, and trained a subtype classifier to augment the plausibility reward as described in Section 2.4. The finetuned model was able to condition on the new classes and generate plausible samples of the two Neutrophil subtypes (Figure 5(c)), while retaining the classification accuracy with respect to the new classes as shown in Table C.2.