释放双眼,带上耳机,听听看~!
兔了个兔创意投稿大赛详情公布,文章介绍了PaddleNLP和PPDiffusers深度学习模型的应用,包括图片生成和海报合成。
我正在参加「兔了个兔」创意投稿大赛,详情请看:点开这里的链接!
ppdiffusers支持的模型名称 | huggingface对应的模型地址 | Tips备注 |
---|---|---|
Linaqruf/anything-v3.0 (推荐!) | huggingface.co/Linaqruf/an… | 二次元模型! |
hakurei/waifu-diffusion-v1-3 (推荐!) | huggingface.co/hakurei/wai… | Waifu v1-3的模型,主要适合画二次元图像!(对比v1-2更好!) |
MoososCap/NOVEL-MODEL (推荐!) | huggingface.co/MoososCap/N… | 二次元模型! |
Baitian/momocha (推荐!) | 无 | 二次元模型! |
Baitian/momoco (推荐!) | 无 | 二次元模型! |
hequanshaguo/monoko-e (推荐!) | 无 | 二次元模型! |
%cd ~/PaddleNLP/ppdiffusers
/home/aistudio/PaddleNLP/ppdiffusers
import paddle
from ppdiffusers import StableDiffusionPipeline
# 加载模型
pipe = StableDiffusionPipeline.from_pretrained("Linaqruf/anything-v3.0")
🧨🧨🧨图片生成🐰🐰🐰
# prompt: 戴眼镜坐在电脑边敲代码穿唐装的兔子, 可爱,大眼睛,高清毛绒
prompt = "rabbit wear glasses beside the computer is writting code in Tang costume for the Spring Festival is cute, big-eyed, high-definition plush"
images = pipe(prompt, guidance_scale=7.5, height=768, width=768)
print(len(images.jpg>0]
image.save("https://b2.7b2.com/home/aistudio/0.png")
🧨🧨🧨海报合成🐰🐰🐰
%cd ~
import cv2
def merge():
back_img_path = '底图.png'
# 加载底图模板
back_img = cv2.imread(back_img_path, cv2.IMREAD_UNCHANGED) # 捕获图像1
print('底图尺寸: ', back_img.shape)
# 加载生成图
fore_img = cv2.imread('0.png', cv2.IMREAD_UNCHANGED)
fore_img = cv2.resize(fore_img, (600, 600))
rows, cols, channels = fore_img.shape
print('生成图尺寸: ', fore_img.shape)
dx, dy = 75, 390
print('dx + rows, dy + cols', dx + rows, dy + cols)
print(back_img[dy:dy + cols, dx:dx + rows].shape)
# 合并
back_img[dy:dy + cols, dx:dx + rows] = fore_img
merge_img_path = '海报.png'
# 保存
cv2.imwrite(merge_img_path, back_img)
return merge_img_path
merge()
/home/aistudio
底图尺寸: (1334, 750, 3)
生成图尺寸: (600, 600, 3)
dx + rows, dy + cols 675 990
(600, 600, 3)
'海报.png'
🧨🧨🧨查看海报🐰🐰🐰
import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
img = cv2.imread("海报.png", -1)#读取的是bgr格式
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img)
plt.show()
本网站的内容主要来自互联网上的各种资源,仅供参考和信息分享之用,不代表本网站拥有相关版权或知识产权。如您认为内容侵犯您的权益,请联系我们,我们将尽快采取行动,包括删除或更正。