diffusers-parti-prompts/muse256
收藏Hugging Face2023-09-14 更新2024-03-04 收录
下载链接:
https://hf-mirror.com/datasets/diffusers-parti-prompts/muse256
下载链接
链接失效反馈官方服务:
资源简介:
```python
from PIL import Image
import torch
from muse import PipelineMuse, MaskGiTUViT
from datasets import Dataset, Features
from datasets import Image as ImageFeature
from datasets import Value, load_dataset
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = PipelineMuse.from_pretrained(
transformer_path="valhalla/research-run",
text_encoder_path="openMUSE/clip-vit-large-patch14-text-enc",
vae_path="openMUSE/vqgan-f16-8192-laion",
).to(device)
# pipe.transformer = MaskGiTUViT.from_pretrained("valhalla/research-run-finetuned-journeydb", revision="06bcd6ab6580a2ed3275ddfc17f463b8574457da", subfolder="ema_model").to(device)
pipe.transformer = MaskGiTUViT.from_pretrained("valhalla/muse-research-run", subfolder="ema_model").to(device)
pipe.tokenizer.pad_token_id = 49407
if device == "cuda":
pipe.transformer.enable_xformers_memory_efficient_attention()
pipe.text_encoder.to(torch.float16)
pipe.transformer.to(torch.float16)
import PIL
def main():
print("Loading dataset...")
parti_prompts = load_dataset("nateraw/parti-prompts", split="train")
print("Loading pipeline...")
seed = 0
device = "cuda"
torch.manual_seed(0)
ckpt_id = "openMUSE/muse-256"
scale = 10
print("Running inference...")
main_dict = {}
for i in range(len(parti_prompts)):
sample = parti_prompts[i]
prompt = sample["Prompt"]
image = pipe(
prompt,
timesteps=16,
negative_text=None,
guidance_scale=scale,
temperature=(2, 0),
orig_size=(256, 256),
crop_coords=(0, 0),
aesthetic_score=6,
use_fp16=device == "cuda",
transformer_seq_len=256,
use_tqdm=False,
)[0]
image = image.resize((256, 256), resample=PIL.Image.Resampling.LANCZOS)
img_path = f"/home/patrick/muse_images/muse_256_{i}.png"
image.save(img_path)
main_dict.update(
{
prompt: {
"img_path": img_path,
"Category": sample["Category"],
"Challenge": sample["Challenge"],
"Note": sample["Note"],
"model_name": ckpt_id,
"seed": seed,
}
}
)
def generation_fn():
for prompt in main_dict:
prompt_entry = main_dict[prompt]
yield {
"Prompt": prompt,
"Category": prompt_entry["Category"],
"Challenge": prompt_entry["Challenge"],
"Note": prompt_entry["Note"],
"images": {"path": prompt_entry["img_path"]},
"model_name": prompt_entry["model_name"],
"seed": prompt_entry["seed"],
}
print("Preparing HF dataset...")
ds = Dataset.from_generator(
generation_fn,
features=Features(
Prompt=Value("string"),
Category=Value("string"),
Challenge=Value("string"),
Note=Value("string"),
images=ImageFeature(),
model_name=Value("string"),
seed=Value("int64"),
),
)
ds_id = "diffusers-parti-prompts/muse256"
ds.push_to_hub(ds_id)
if __name__ == "__main__":
main()
```
The dataset consists of a series of prompts, each corresponding to an image generation task. The dataset fields include Prompt, Category, Challenge, Note, etc. The generated images and their related information are saved and pushed to the `diffusers-parti-prompts/muse256` dataset on HuggingFace Hub.
提供机构:
diffusers-parti-prompts
原始信息汇总
数据集概述
数据集名称
diffusers-parti-prompts/muse256
数据集内容
- Prompt: 字符串类型,描述生成的图像的提示信息。
- Category: 字符串类型,描述提示所属的类别。
- Challenge: 字符串类型,描述提示所涉及的挑战。
- Note: 字符串类型,描述提示的备注信息。
- images: 图像类型,包含生成的图像路径。
- model_name: 字符串类型,描述生成图像所使用的模型名称。
- seed: 整数类型,描述生成图像所使用的随机种子。
数据集生成过程
- 使用
nateraw/parti-prompts数据集作为输入,提取其中的提示信息。 - 通过
PipelineMuse模型生成图像,并将生成的图像保存到指定路径。 - 将生成的图像及其相关信息构建成一个新的数据集,并上传到 Hugging Face 数据集平台。
模型信息
- PipelineMuse: 使用预训练模型
valhalla/muse-research-run和openMUSE/clip-vit-large-patch14-text-enc进行图像生成。 - MaskGiTUViT: 使用预训练模型
valhalla/muse-research-run进行图像生成。 - VAE: 使用预训练模型
openMUSE/vqgan-f16-8192-laion进行图像生成。
硬件要求
- 使用 CUDA 设备进行图像生成,支持使用
xformers进行内存高效注意力计算。



