論文地址
GitHub地址??
論文講解
從開放領(lǐng)域的文本提示中生成和編輯圖像是一項(xiàng)具有挑戰(zhàn)性的任務(wù),到目前為止,需要昂貴的和經(jīng)過專門訓(xùn)練的模型。我們?yōu)檫@兩項(xiàng)任務(wù)展示了一種新的方法,它能夠通過使用多模態(tài)編碼器來指導(dǎo)圖像的生成,從具有顯著語義復(fù)雜性的文本提示中產(chǎn)生高視覺質(zhì)量的圖像,而無需任何訓(xùn)練。我們?cè)诟鞣N任務(wù)上證明了使用CLIP來指導(dǎo)VQGAN產(chǎn)生的視覺質(zhì)量比之前不太靈活的方法如minDALL-E、GLIDE和Open-Edit更高。
?
?代碼復(fù)現(xiàn)
1.創(chuàng)建conda環(huán)境并激活進(jìn)入
conda create --name vqgan python=3.9
conda activate vqgan
2.安裝pytorch
兩種方法:
(1)通過鏡像下載
添加中科大鏡像源:
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
添加鏡像之后,直接利用中科大源進(jìn)行pip下載:
pip3 install torch torchvision torchaudio -i https://pypi.mirrors.ustc.edu.cn/simple/
?(2)vpn下載
掛上vpn后直接運(yùn)行:
注意:我使用的是3090顯卡,所以cuda版本要求11.3以上(建議是11.6)
conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
3.安裝環(huán)境依賴
這里默認(rèn)會(huì)下載一次最新的torch(目前是1.12.1),如果上一步安裝的不是1.12.1可能會(huì)再下載一次torch
pip install ftfy regex tqdm omegaconf pytorch-lightning IPython kornia imageio imageio-ffmpeg einops torch_optimizer setuptools==59.5.0
4.在git上克隆VQGAN-CLIP,cd到VQGAN-CLIP文件夾下再克隆CLIP和VQGAN
git clone 'https://github.com/nerdyrodent/VQGAN-CLIP'
cd VQGAN-CLIP
git clone 'https://github.com/openai/CLIP'
git clone 'https://github.com/CompVis/taming-transformers'
5.運(yùn)行download_models.sh腳本文件下載基于imagnet的VQGAN預(yù)訓(xùn)練模型
(1)先給download_models.sh腳本添加權(quán)限:
chmod u+x download_models.sh
(2)運(yùn)行download_models.sh,下載預(yù)訓(xùn)練模型文章來源:http://www.zghlxwxcb.cn/news/detail-411497.html
./download_models.sh
6.運(yùn)行g(shù)enerate.py文章來源地址http://www.zghlxwxcb.cn/news/detail-411497.html
python generate.py -p "A painting of an apple in a fruit bowl"
到了這里,關(guān)于【GitHub】VQGAN+CLIP代碼從零開始復(fù)現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!