PaddleNLP ppdiffusers 自動生成兔了個兔海報
更新時間:2023年01月18日 14:49:35 作者:Livingbody
這篇文章主要為大家介紹了PaddleNLP ppdiffusers 自動生成兔了個兔海報示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
歡歡喜喜辭舊歲 ??????
辭舊迎新之際,來 AI Studio 一起 #歡喜迎兔年# !分享不同新年風俗,共享一段快樂時光!??????
p>下面就開始我們的海報之旅??????
下載PaddleNLP??????
from IPython.display import clear_output %cd ~ !git clone -b develop https://github.com/PaddlePaddle/PaddleNLP.git clear_output() # 清理很長的內容
安裝PaddleNLP??????
%cd ~/PaddleNLP !pip install -e ./ clear_output() # 清理很長的內容 print('安裝完畢, 請重啟內核')
安裝完畢, 請重啟內核
重啟notebook??????
安裝ppdiffusers??????
%cd ~/PaddleNLP/ppdiffusers/ !pip install -r ~/PaddleNLP/ppdiffusers/requirements.txt clear_output() # 清理很長的內容 print('安裝完畢, 請重啟內核')
安裝完畢, 請重啟內核
diffusion文圖生成??????
選定diffusion模型??????
下面推薦了部分二次元模型,想要了解更多的模型可以 點開這里的鏈接!
ppdiffusers支持的模型名稱 | huggingface對應的模型地址 | Tips備注 |
---|---|---|
Linaqruf/anything-v3.0 (推薦?。?/td> | huggingface.co/Linaqruf/an… | 二次元模型! |
hakurei/waifu-diffusion-v1-3 (推薦?。?/td> | huggingface.co/hakurei/wai… | Waifu v1-3的模型,主要適合畫二次元圖像?。▽Ρ葀1-2更好?。?/td> |
MoososCap/NOVEL-MODEL (推薦!) | huggingface.co/MoososCap/N… | 二次元模型! |
Baitian/momocha (推薦!) | 無 | 二次元模型! |
Baitian/momoco (推薦?。?/td> | 無 | 二次元模型! |
hequanshaguo/monoko-e (推薦?。?/td> | 無 | 二次元模型! |
%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.images)) image = images.images[0] image.save("/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()
以上就是PaddleNLP ppdiffusers 自動生成兔了個兔海報的詳細內容,更多關于PaddleNLP ppdiffusers生成海報的資料請關注腳本之家其它相關文章!
相關文章
python輸入整條數(shù)據(jù)分割存入數(shù)組的方法
今天小編就為大家分享一篇python輸入整條數(shù)據(jù)分割存入數(shù)組的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-11-11python處理multipart/form-data的請求方法
今天小編就為大家分享一篇python處理multipart/form-data的請求方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12python列表倒序的幾種方法(切片、reverse()、reversed())
本文主要介紹了python列表倒序的幾種方法(切片、reverse()、reversed()),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-08-08