--- license: apache-2.0 dataset_info: features: - name: image dtype: image - name: prompt dtype: string - name: word_scores dtype: string - name: alignment_score_norm dtype: float32 - name: coherence_score_norm dtype: float32 - name: style_score_norm dtype: float32 - name: alignment_heatmap sequence: sequence: float16 - name: coherence_heatmap sequence: sequence: float16 - name: alignment_score dtype: float32 - name: coherence_score dtype: float32 - name: style_score dtype: float32 splits: - name: train num_bytes: 25257389633.104 num_examples: 13024 download_size: 17856619960 dataset_size: 25257389633.104 configs: - config_name: default data_files: - split: train path: data/train-* task_categories: - text-to-image - text-classification - image-classification - image-to-text - image-segmentation language: - en tags: - t2i - preferences - human - flux - midjourney - imagen - dalle - heatmap - coherence - alignment - style - plausiblity pretty_name: Rich Human Feedback for Text to Image Models size_categories: - 1M Rapidata Logo Building upon Google's research [Rich Human Feedback for Text-to-Image Generation](https://arxiv.org/abs/2312.10240) we have collected over 1.5 million responses from 152'684 individual humans using Rapidata via the [Python API](https://docs.rapidata.ai/). Collection took roughly 5 days. If you get value from this dataset and would like to see more in the future, please consider liking it. # Overview We asked humans to evaluate AI-generated images in style, coherence and prompt alignment. For images that contained flaws, participants were asked to identify specific problematic areas. Additionally, for all images, participants identified words from the prompts that were not accurately represented in the generated images. If you want to replicate the annotation setup, the steps are outlined at the [bottom](#replicating-the-annotation-setup). This dataset and the annotation process is described in further detail in our blog post [Beyond Image Preferences](https://huggingface.co/blog/RapidataAI/beyond-image-preferences). # Usage Examples Accessing this data is easy with the Huggingface `dataset` library. For quick demos or previews, we recommend setting `streaming=True` as downloading the whole dataset can take a while. ```python from datasets import load_dataset ds = load_dataset("Rapidata/text-2-image-Rich-Human-Feedback", split="train", streaming=True) ``` As an example, below we show how to replicate the figures below.
Click to expand Select Words example The methods below can be used to produce figures similar to the ones shownn below. Note however that the figures below were created using `matplotlib`, however we opt to use `opencv` here as it makes calculating the text spacing much easier. **Methods** ```python from PIL import Image from datasets import load_dataset import cv2 import numpy as np def get_colors(words): colors = [] for item in words: intensity = item / max(words) value = np.uint8((1 - intensity) * 255) color = tuple(map(int, cv2.applyColorMap(np.array([[value]]), cv2.COLORMAP_AUTUMN)[0][0])) colors.append(color) return colors def get_wrapped_text(text_color_pairs, font, font_scale, thickness, word_spacing, max_width): wrapped_text_color_pairs, current_line, line_width = [], [], 0 for text, color in text_color_pairs: text_size = cv2.getTextSize(text, font, font_scale, thickness)[0] if line_width + text_size[0] > max_width: wrapped_text_color_pairs.append(current_line) current_line, line_width = [], 0 current_line.append((text, color, text_size)) line_width += text_size[0] + word_spacing wrapped_text_color_pairs.append(current_line) return wrapped_text_color_pairs def add_multicolor_text(input, text_color_pairs, font_scale=1, thickness=2, word_spacing=20): image = cv2.cvtColor(np.array(input), cv2.COLOR_RGB2BGR) image_height, image_width, _ = image.shape font = cv2.FONT_HERSHEY_SIMPLEX wrapped_text = get_wrapped_text(text_color_pairs, font, font_scale, thickness, word_spacing, int(image_width*0.95)) position = (int(0.025*image_width), int(word_spacing*2)) overlay = image.copy() cv2.rectangle(overlay, (0, 0), (image_width, int((len(wrapped_text)+1)*word_spacing*2)), (100,100,100), -1) out_img = cv2.addWeighted(overlay, 0.75, image, 0.25, 0) for idx, text_line in enumerate(wrapped_text): current_x, current_y = position[0], position[1] + int(idx*word_spacing*2) for text, color, text_size in text_line: cv2.putText(out_img, text, (current_x, current_y), font, font_scale, color, thickness) current_x += text_size[0] + word_spacing return Image.fromarray(cv2.cvtColor(out_img, cv2.COLOR_BGR2RGB)) ``` **Create figures** ```python ds_words = ds.select_columns(["image","prompt", "word_scores"]) for example in ds_words.take(5): image = example["image"] prompt = example["prompt"] word_scores = [s[1] for s in eval(example["word_scores"])] words = [s[0] for s in eval(example["word_scores"])] colors = get_colors(word_scores) display(add_multicolor_text(image, list(zip(words, colors)), font_scale=1, thickness=2, word_spacing=20)) ```
Click to expand Heatmap example **Methods** ```python import cv2 import numpy as np from PIL import Image def overlay_heatmap(image, heatmap, alpha=0.3): cv2_image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) heatmap_normalized = ((heatmap - heatmap.min()) / (heatmap.max() - heatmap.min())) heatmap_normalized = np.uint8(255 * (heatmap_normalized)) heatmap_colored = cv2.applyColorMap(heatmap_normalized, cv2.COLORMAP_HOT) overlaid_image = cv2.addWeighted(cv2_image, 1 - alpha, heatmap_colored, alpha, 0) return Image.fromarray(cv2.cvtColor(overlaid_image, cv2.COLOR_BGR2RGB)) ``` **Create figures** ```python ds_heatmap = ds.select_columns(["image","prompt", "alignment_heatmap"]) for example in ds_heatmap.take(5): image = example["image"] heatmap = example["alignment_heatmap"] if heatmap: display(overlay_heatmap(image, np.asarray(heatmap))) ```

# Data Summary ## Word Scores Users identified words from the prompts that were NOT accurately depicted in the generated images. Higher word scores indicate poorer representation in the image. Participants also had the option to select "[No_mistakes]" for prompts where all elements were accurately depicted. ### Examples Results: | | | |---|---| | | | ## Coherence The coherence score measures whether the generated image is logically consistent and free from artifacts or visual glitches. Without seeing the original prompt, users were asked: "Look closely, does this image have weird errors, like senseless or malformed objects, incomprehensible details, or visual glitches?" Each image received at least 21 responses indicating the level of coherence on a scale of 1-5, which were then averaged to produce the final scores where 5 indicates the highest coherence. Images scoring below 3.8 in coherence were further evaluated, with participants marking specific errors in the image. ### Example Results: | | | |---|---| | | | ## Alignment The alignment score quantifies how well an image matches its prompt. Users were asked: "How well does the image match the description?". Again, each image received at least 21 responses indicating the level of alignment on a scale of 1-5 (5 being the highest), which were then averaged. For images with an alignment score below 3.2, additional users were asked to highlight areas where the image did not align with the prompt. These responses were then compiled into a heatmap. As mentioned in the google paper, aligment is harder to annotate consistently, if e.g. an object is missing, it is unclear to the annotators what they need to highlight. ### Example Results:
Prompt: Three cats and one dog sitting on the grass.
Three cats and one dog
Prompt: A brown toilet with a white wooden seat.
Brown toilet
Prompt: Photograph of a pale Asian woman, wearing an oriental costume, sitting in a luxurious white chair. Her head is floating off the chair, with the chin on the table and chin on her knees, her chin on her knees. Closeup
Asian woman in costume
Prompt: A tennis racket underneath a traffic light.
Racket under traffic light
## Style The style score reflects how visually appealing participants found each image, independent of the prompt. Users were asked: "How much do you like the way this image looks?" Each image received 21 responses grading on a scale of 1-5, which were then averaged. In contrast to other prefrence collection methods, such as the huggingface image arena, the preferences were collected from humans from around the world (156 different countries) from all walks of life, creating a more representative score. # About Rapidata Rapidata's technology makes collecting human feedback at scale faster and more accessible than ever before. Visit [rapidata.ai](https://www.rapidata.ai/) to learn more about how we're revolutionizing human feedback collection for AI development. # Other Datasets We run a benchmark of the major image generation models, the results can be found on our [website](https://www.rapidata.ai/leaderboard/image-models). We rank the models according to their coherence/plausiblity, their aligment with the given prompt and style prefernce. The underlying 2M+ annotations can be found here: - Link to the [Coherence dataset](https://huggingface.co/datasets/Rapidata/Flux_SD3_MJ_Dalle_Human_Coherence_Dataset) - Link to the [Text-2-Image Alignment dataset](https://huggingface.co/datasets/Rapidata/Flux_SD3_MJ_Dalle_Human_Alignment_Dataset) - Link to the [Preference dataset](https://huggingface.co/datasets/Rapidata/700k_Human_Preference_Dataset_FLUX_SD3_MJ_DALLE3) We have also started to run a [video generation benchmark](https://www.rapidata.ai/leaderboard/video-models), it is still a work in progress and currently only covers 2 models. They are also analysed in coherence/plausiblity, alignment and style preference. # Replicating the Annotation Setup For researchers interested in producing their own rich preference dataset, you can directly use the Rapidata API through python. The code snippets below show how to replicate the modalities used in the dataset. Additional information is available through the [documentation](https://docs.rapidata.ai/)
Creating the Rapidata Client and Downloading the Dataset First install the rapidata package, then create the RapidataClient() this will be used create and launch the annotation setup ```bash pip install rapidata ``` ```python from rapidata import RapidataClient, LabelingSelection, ValidationSelection client = RapidataClient() ``` As example data we will just use images from the dataset. Make sure to set `streaming=True` as downloading the whole dataset might take a significant amount of time. ```python from datasets import load_dataset ds = load_dataset("Rapidata/text-2-image-Rich-Human-Feedback", split="train", streaming=True) ds = ds.select_columns(["image","prompt"]) ``` Since we use streaming, we can extract the prompts and download the images we need like this: ```python import os tmp_folder = "demo_images" # make folder if it doesn't exist if not os.path.exists(tmp_folder): os.makedirs(tmp_folder) prompts = [] image_paths = [] for i, row in enumerate(ds.take(10)): prompts.append(row["prompt"]) # save image to disk save_path = os.path.join(tmp_folder, f"{i}.jpg") row["image"].save(save_path) image_paths.append(save_path) ```
Likert Scale Alignment Score To launch a likert scale annotation order, we make use of the classification annotation modality. Below we show the setup for the alignment criteria. The structure is the same for style and coherence, however arguments have to be adjusted of course. I.e. different instructions, options and validation set. ```python # Alignment Example instruction = "How well does the image match the description?" answer_options = [ "1: Not at all", "2: A little", "3: Moderately", "4: Very well", "5: Perfectly" ] order = client.order.create_classification_order( name="Alignment Example", instruction=instruction, answer_options=answer_options, datapoints=image_paths, contexts=prompts, # for alignment, prompts are required as context for the annotators. responses_per_datapoint=10, selections=[ValidationSelection("676199a5ef7af86285630ea6"), LabelingSelection(1)] # here we use a pre-defined validation set. See https://docs.rapidata.ai/improve_order_quality/ for details ) order.run() # This starts the order. Follow the printed link to see progress. ```
Alignment Heatmap To produce heatmaps, we use the locate annotation modality. Below is the setup used for creating the alignment heatmaps. ```python # alignment heatmap # Note that the selected images may not actually have severely misaligned elements, but this is just for demonstration purposes. order = client.order.create_locate_order( name="Alignment Heatmap Example", instruction="What part of the image does not match with the description? Tap to select.", datapoints=image_paths, contexts=prompts, # for alignment, prompts are required as context for the annotators. responses_per_datapoint=10, selections=[ValidationSelection("67689e58026456ec851f51f8"), LabelingSelection(1)] # here we use a pre-defined validation set for alignment. See https://docs.rapidata.ai/improve_order_quality/ for details ) order.run() # This starts the order. Follow the printed link to see progress. ```
Select Misaligned Words To launch the annotation setup for selection of misaligned words, we used the following setup ```python # Select words example from rapidata import LanguageFilter select_words_prompts = [p + " [No_Mistake]" for p in prompts] order = client.order.create_select_words_order( name="Select Words Example", instruction = "The image is based on the text below. Select mistakes, i.e., words that are not aligned with the image.", datapoints=image_paths, sentences=select_words_prompts, responses_per_datapoint=10, filters=[LanguageFilter(["en"])], # here we add a filter to ensure only english speaking annotators are selected selections=[ValidationSelection("6761a86eef7af86285630ea8"), LabelingSelection(1)] # here we use a pre-defined validation set. See https://docs.rapidata.ai/improve_order_quality/ for details ) order.run() ```