Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disco diffusion ernievil vitb16 #3118

Merged

Conversation

JunnYu
Copy link
Member

@JunnYu JunnYu commented Aug 23, 2022

PR types

New features

PR changes

Models

Description

  • 添加ErnieViL模型及使用该模型+disco diffusion生成图像。
  • 该PR依赖上一下CLIP的PR。
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "5"

from paddlenlp.transformers import ErnieViLForImageGeneration, ErnieViLTokenizer

# Initialize the model and tokenizer
model_name_or_path = 'disco_diffusion_ernie_vil-2.0-base-zh'
model = ErnieViLForImageGeneration.from_pretrained(model_name_or_path)
tokenizer = ErnieViLTokenizer.from_pretrained(model_name_or_path)
model.eval()

# Prepare the model inputs.
text_prompt = "孤舟蓑笠翁,独钓寒江雪,油画"
style = None
artist = None
text_prompt = model.preprocess_text_prompt(text_prompt)
tokenized_inputs = tokenizer(text_prompt, return_tensors="pd", padding="max_length", max_length=64)

images = model.generate(**tokenized_inputs)
images[0].save("figure.png")

孤舟蓑笠翁,独钓寒江雪,油画
image
在宁静的风景中画了一幅美丽的建筑画,由齐白石所作
image
两个黄鹂鸣翠柳,一行白鹭上青天
image
该文件里面包含了中英文的dd内容。
test_ernie_vil_clip_dd.tar.gz

rainyfly
rainyfly previously approved these changes Aug 24, 2022
Copy link

@rainyfly rainyfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for diffusion_generate process.

Copy link
Contributor

@guoshengCS guoshengCS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@guoshengCS guoshengCS merged commit 8fde089 into PaddlePaddle:develop Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants