PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
11.99k stars 2.92k forks source link

[Question]: stable-diffusion-v1-5 #3588

Closed zcswdt closed 1 year ago

zcswdt commented 1 year ago

请提出你的问题

请问这个模型是如何下载呢?我去了diffusion官网,是下载如下的模型吗?如果不是,该zen'm怎么下载呢? image

JunnYu commented 1 year ago

你好,你是需要下载原版模型吗?还是要下载paddle版本的模型? 如果是当前paddle版本的话,目前还没有统一的下载方式。 你可以在机器上

from ppdiffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe.save_pretrained("你需要保存的文件夹地址")
zcswdt commented 1 year ago
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")

您好,运行你这个代码,还是下载不了这个模型,我环境配置都没问题,请问怎么解决呢?或者是方便发给我一份模型吗?谢谢你。 image

JunnYu commented 1 year ago

windwos环境下"/"可能跟linux不太一样,所以有问题,

image

你好,我大约知道是什么问题了,我给你个脚本吧,可以下载

zcswdt commented 1 year ago

windwos环境下"/"可能跟linux不太一样,所以有问题, image 你好,我大约知道是什么问题了,我给你个脚本吧,可以下载

我邮箱jhsignal@126.com

谢谢谢谢!脚本可以发给我邮箱吗?jhsignal@126.com

JunnYu commented 1 year ago
from paddlenlp.utils.downloader import get_path_from_url
def download(model_name, cache_dir):
    file = [
     'model_index.json',
     'tokenizer/vocab.json',
     'tokenizer/special_tokens_map.json',
     'tokenizer/merges.txt',
     'tokenizer/tokenizer_config.json',
     'tokenizer/added_tokens.json',
     'text_encoder/model_config.json',
     'text_encoder/model_state.pdparams',
     'unet/model_state.pdparams',
     'unet/config.json',
     'feature_extractor/preprocessor_config.json',
     'safety_checker/model_config.json',
     'safety_checker/model_state.pdparams',
     'scheduler/scheduler_config.json',
     'vae/model_state.pdparams',
     'vae/config.json']
    base_url = "https://bj.bcebos.com/paddlenlp/models/community/"
    for f in file:
        url = base_url + model_name + "/" + f
        suffix = f.split("/")[0]
        new_cache_dir = cache_dir + "/" + suffix if suffix!='model_index.json' else cache_dir
        get_path_from_url(url, new_cache_dir)

# 输入你的想要下载的模型名称
model_name = "runwayml/stable-diffusion-v1-5"
# 保存的路径
cache_dir = "./stable-diffusion-v1-5"
download(model_name, cache_dir)
zcswdt commented 1 year ago
from paddlenlp.utils.downloader import get_path_from_url
def download(model_name, cache_dir):
    file = [
     'model_index.json',
     'tokenizer/vocab.json',
     'tokenizer/special_tokens_map.json',
     'tokenizer/merges.txt',
     'tokenizer/tokenizer_config.json',
     'tokenizer/added_tokens.json',
     'text_encoder/model_config.json',
     'text_encoder/model_state.pdparams',
     'unet/model_state.pdparams',
     'unet/config.json',
     'feature_extractor/preprocessor_config.json',
     'safety_checker/model_config.json',
     'safety_checker/model_state.pdparams',
     'scheduler/scheduler_config.json',
     'vae/model_state.pdparams',
     'vae/config.json']
    base_url = "https://bj.bcebos.com/paddlenlp/models/community/"
    for f in file:
        url = base_url + model_name + "/" + f
        suffix = f.split("/")[0]
        new_cache_dir = cache_dir + "/" + suffix if suffix!='model_index.json' else cache_dir
        get_path_from_url(url, new_cache_dir)

# 输入你的想要下载的模型名称
model_name = "runwayml/stable-diffusion-v1-5"
# 保存的路径
cache_dir = "./stable-diffusion-v1-5"
download(model_name, cache_dir)

您好,我下载玩模型了,加载模型的这个函数,pipe = StableDiffusionPipeline.from_pretrained("路径"),这“路径”是替换模型的路径吗?

zcswdt commented 1 year ago
from paddlenlp.utils.downloader import get_path_from_url
# 输入你的想要下载的模型名称
model_name = "runwayml/stable-diffusion-v1-5"
# 保存的路径
cache_dir = "./stable-diffusion-v1-5"
download(model_name, cache_dir)

您好,我下载玩模型了,加载模型的这个函数,pipe = StableDiffusionPipeline.from_pretrained("路径"),这“路径”是替换模型的路径吗?

JunnYu commented 1 year ago

是的,替换成cache_dir = "./stable-diffusion-v1-5",这个路径,当然你也可以改名字

zcswdt commented 1 year ago

是的,替换成cache_dir = "./stable-diffusion-v1-5",这个路径,当然你也可以改名字

好的,那谢谢你了!可以加个V吗?如果可以,可以给V发到我邮箱,jhsignal@126.com,我加你,谢谢了!

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。