文件最后提交记录最后更新时间
add license and change directore 2 年前
add license and change directore 2 年前
add license and change directore 2 年前
编码规范修改及无效代码删除 2 年前
!5959 [built-in][PyTorch][sd-scripts-xl]fix fairscale sharded_ddp Merge pull request !5959 from 肖雅敏/master 2 年前
!4749 【自研】【PyTorch】【StableDiffusion-2.1_for_PyTorch】readme及启动脚本问题修正 * bug fix readme 2 年前
add license and change directore 2 年前
add license and change directore 2 年前
文档整改,gitee->gitcode Co-authored-by: Lighters_c<zyh13227@163.com> # message auto-generated for no-merge-commit merge: !7469 merge ffffix into master 文档整改,gitee->gitcode Created-by: addsubmuldiv Commit-by: Lighters_c Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!74695 个月前
add license and change directore 2 年前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!4818 [自研][PyTorch][StableDiffusion-2.1 for PyTorch] readme修改,requirements修改依赖包版本 * [自研][PyTorch][StableDiffusion-2.1 for PyTorch] readme修改,requirements修改依赖包版本 2 年前
删除冲突代码 2 年前
README.md

StableDiffusion-2.1 for PyTorch

概述

简述

StableDiffusion 是 StabilityAI公司于2022年提出的图片生成的预训练模型,论文和代码均已开源,下游任务包括文生图、图生图、图片压缩等等

  • 参考实现:

    url=https://github.com/Stability-AI/stablediffusion 
    commit_id=535d370de05c0e55a6bcbdd32933e549e125b946
    
  • 适配昇腾 AI 处理器的实现:

    url=https://gitcode.com/ascend/ModelZoo-PyTorch.git
    code_path=PyTorch/built-in/diffusion/stablediffusion-2.1
    

准备环境

准备环境

  • 当前模型支持的 PyTorch 版本和已知三方库依赖如下表所示。

    表 1 版本支持表

    Torch_Version 三方库依赖版本
    PyTorch 1.11 torchvision==0.12.0; transformers==4.19.2
    PyTorch 2.1 torchvision==0.16.0; transformers==4.19.2
    PyTorch 2.2 torchvision==0.17.0; transformers==4.19.2
    PyTorch 2.3 torchvision==0.18.1; transformers==4.19.2
    PyTorch 2.4 torchvision==0.19.0; transformers==4.19.2
  • 环境准备指导。

    请参考《Pytorch框架训练环境准备》。

  • 安装依赖。

    在模型源码包根目录下执行命令,安装模型对应PyTorch版本需要的依赖。

    
    pip install -r requirements.txt
    

图像生成任务推理

  • 下载预训练的ckpt文件

  • 先source环境变量:

    source ./test/env_npu.sh
    
  • 执行图像生成脚本:

 python scripts/txt2img.py \
        --prompt "a professional photograph of an astronaut riding a horse" \
        --ckpt /xxx/xxx.ckpt \
        --config configs/stable-diffusion/v2-inference-v.yaml \
        --H 768 \
        --W 768 \
        --device_id 4 \
        --precision full \
        --bf16 \
        --n_samples 1 \
        --n_iter 1 \
        --dpm \
        --steps 15 

# 或者使用shell脚本启动:
bash ./test/run_infer_full_1p.sh  #单卡推理,请将脚本里的ckpt权重路径更换成实际的路径

# 注:生成的图像在outputs目录下 
  • 参数说明如下:
--ckpt_path #模型文件目录,需要指定到具体的ckpt文件

--n_samples #每次生成图片的batch数

--n_iter #每个prompt生成的图片数,每个prompt生成的图片总数为:(n_samples * n_iter)

--devive #除`cpu`外,默认为`cuda`

--device_id #运行的设备ID

公网地址说明

代码涉及公网地址参考 public_address_statement.md

版本说明

变更

FAQ

  1. 该模型当前只支持在线推理,不支持训练。

  2. requests.exceptions.SSLError:HttpSConnectionPool(host='huggingface.co', port=443)错误

    可以修改当前环境的requests包下的sessions.py文件的684行,增加kwargs["verify"] = False,一般路径在conda_path/envs/conda_name/lib/python*/site-packages/requests/sessions.py,查看requests包的所在路径可以通过pip show requests查看