CoolFace
Datasetpublic

premfrd123/NSFW-T2I

Introduction (Version 1) About 38k image-text pairs(10k from LAION and 28k from nsfw_detect), and captions are generated by LLaVA-NeXT with prompt "Describe the photo in detail (attributes of person)". The "txt" column shown in the dataset viewer is originated from LAION, not the captions yielded by LLaVA-NeXT. Caption Codes pretrained = "lmms-lab/llama3-llava-next-8b" model_name = "llava_llama3" device = "cuda:2" device_map = "auto" tokenizer, model… See the full description on the dataset page: https://huggingface.co/datasets/premfrd123/NSFW-T2I.

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes6downloads
Dataset Card

Introduction (Version 1)

About 38k image-text pairs(10k from LAION and 28k from nsfw_detect), and captions are generated by LLaVA-NeXT with prompt "Describe the photo in detail (attributes of person)".

The "txt" column shown in the dataset viewer is originated from LAION, not the captions yielded by LLaVA-NeXT.

Caption Codes

python
pretrained = "lmms-lab/llama3-llava-next-8b"
model_name = "llava_llama3"
device = "cuda:2"
device_map = "auto"
tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map)
...
image = Image.open(img_path)
image_tensor = process_images([image], image_processor, model.config)
image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]

conv_template = "llava_llama_3" # Make sure you use correct chat template for different models
question = DEFAULT_IMAGE_TOKEN + "\nDescribe the photo in detail (attributes of person)"
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], question)
conv.append_message(conv.roles[1], None)
prompt_question = conv.get_prompt()

input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
image_sizes = [image.size]

cont = model.generate(
    input_ids,
    images=image_tensor,
    image_sizes=image_sizes,
    do_sample=False,
    temperature=0,
    max_new_tokens=256,
)
text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)