| | --- |
| | license: apache-2.0 |
| | task_categories: |
| | - text-to-image |
| | tags: |
| | - synthetic |
| | - images |
| | - black-and-white |
| | - b&w |
| | size_categories: |
| | - 1K<n<10K |
| | viewer: false |
| | --- |
| | |
| | # Contents |
| | 1. [BoWI](#bowi): Summary on the dataset |
| | 2. [Example Images](#example-images): Preview images |
| | 3. [Tags](#tags): All tags used to generate T2I-prompts |
| | 4. [Usage](#usage): How to use this dataset |
| | 1. [Download Data](#1-download-data) |
| | 2. [Load Tags-Image Pairs](#2-load-tags-image-pairs) |
| |
|
| | ## BoWI |
| | _Black or White Illustrations (BoWI)_ is a dataset consisting of 8,192 tags-image pairs. |
| | Images are generated using [Tongyi-MAI/Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo) at 256x512 with recommended inference parameters. |
| | Prompts passed to the model are generated using all possible tag-combinations from tags specified [below](#tags). |
| | Output images are then finalized by quantizing them into absolute black or absolute white: `ImageOps.grayscale(image).convert('1', dither=Image.NONE)`. |
| |
|
| | ## Example Images |
| |  |
| |
|
| | ## Tags |
| | ```python |
| | TAGS = { |
| | "gender": [ "female", "male" ], |
| | "clothing_style": [ "office", "casual", "chic", "retro", "artsy", "minimal", "bohemian", "edgy" ], |
| | "environment": [ "beach", "city", "living room", "bedroom", "kitchen", "restaurant", "library", "classroom" ], |
| | "holding": [ "nothing", "water bottle", "chocolate bar", "phone", "wallet", "cup of coffee", "book", "pen" ], |
| | "vibe": [ "happy", "sad", "angry", "none", "casual", "professional", "annoyed", "curious" ] |
| | } |
| | ``` |
| | Usually resulting in a final prompt (= a prompt passed to the model) like: |
| | ``` |
| | other: finished high/best quality sketch, illustration, B&W, grayscale, very sharp edges, extremely high contrast, black hair, black eyes, no/without text, pixel perfect, simple background |
| | gender: male |
| | clothing style: office |
| | environment: city |
| | holding: nothing |
| | vibe: none |
| | ``` |
| | Finding images given tags is simple: |
| | ``` |
| | total_clothing_style = 8 |
| | total_environment = 8 |
| | total_holding = 8 |
| | total_vibe = 8 |
| | |
| | # Example: (gender), (clothing_style), (environment), (holding), (vibe) |
| | # male, office, library, nothing, professional |
| | gender = 1 # male is value 1 of the gender key |
| | clothing_style = 0 # office is value 0 of the clothing key |
| | environment = 6 # library is value 6 of the environment key |
| | holding = 0 # nothing is value 0 of the holding key |
| | vibe = 5 # professional is value 5 of the vibe key |
| | |
| | index = 0 |
| | index += gender * total_clothing_style * total_environment * total_holding * total_vibe |
| | index += clothing_style * total_environment * total_holding * total_vibe |
| | index += environment * total_holding * total_vibe |
| | index += holding * total_vibe |
| | index += vibe |
| | # You can now use index to find {index}.png in the folder you stored the images in |
| | ``` |
| |
|
| | ## Usage |
| | ### 1. Download Data |
| | Obviously, to use the dataset, you need to download it. Download [tags.json](https://huggingface.co/datasets/hamzah0asadullah/BoWI/resolve/main/tags.json) and [images.zip](https://huggingface.co/datasets/hamzah0asadullah/BoWI/resolve/main/images.zip) to a folder where you have access to these files. |
| | Finalize this step by unzipping `images.zip`, creating a folder named `images` with 8,192 PNG-encoded images inside. You can delete `images.zip` afterwards. |
| |
|
| | ### 2. Load Tags-Image Pairs |
| | After download the data, you can load it in any reasonable programming/scripting language you want. Here's an example using Python: |
| | ```python |
| | from json import loads # standard library |
| | from os import listdir # standard library |
| | |
| | IMAGE_FOLDER = "./images/" |
| | EXAMPLE_INDEX = 1234 |
| | |
| | BoWI = { "tags": loads(open("tags.json", "r").read().replace("'", "\"")), "images": [open(IMAGE_FOLDER+p, "rb").read() for p in listdir(IMAGE_FOLDER)] } |
| | |
| | open(f"{EXAMPLE_INDEX}.png", "wb").write(BoWI["images"][EXAMPLE_INDEX]) |
| | print(f"Tags for the {EXAMPLE_INDEX}th index (saved the image to {EXAMPLE_INDEX}.png): {BoWI['tags'][EXAMPLE_INDEX]}") |
| | ``` |