使用Lora技术进行Dreambooth训练【抢先体验版】

本文介绍了使用PaddleNLP等工具进行模型训练与推理的流程。先安装paddlenlp等依赖,再分别用dreambooth lora和文生图lora方式训练,设置参数并保存权重。之后可启动visualdl查看训练出图,最后加载训练好的文件,通过相关代码进行推理生成图像。

☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

使用lora技术进行dreambooth训练【抢先体验版】 - 创想鸟

1. 安装依赖

运行下面的按钮安装依赖,为了确保安装成功,安装完毕请重启内核!(注意:这里只需要运行一次!)In [1]

!pip install -U paddlenlp ppdiffusers safetensors --user

       

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleRequirement already satisfied: paddlenlp in ./.data/webide/pip/lib/python3.7/site-packages (2.5.1)Requirement already satisfied: ppdiffusers in ./.data/webide/pip/lib/python3.7/site-packages (0.11.0)Requirement already satisfied: safetensors in ./.data/webide/pip/lib/python3.7/site-packages (0.2.8)Requirement already satisfied: paddlefsl in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.1.0)Requirement already satisfied: sentencepiece in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.1.96)Requirement already satisfied: huggingface-hub>=0.11.1 in ./.data/webide/pip/lib/python3.7/site-packages (from paddlenlp) (0.12.0)Requirement already satisfied: seqeval in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.2.2)Requirement already satisfied: fastapi in ./.data/webide/pip/lib/python3.7/site-packages (from paddlenlp) (0.91.0)Requirement already satisfied: typer in ./.data/webide/pip/lib/python3.7/site-packages (from paddlenlp) (0.7.0)Requirement already satisfied: multiprocess<=0.70.12.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.70.11.1)Requirement already satisfied: jieba in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.42.1)Requirement already satisfied: Flask-Babel=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (2.7.0)Requirement already satisfied: paddle2onnx in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.0.0)Requirement already satisfied: colorama in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.4.4)Requirement already satisfied: visualdl in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (2.4.0)Requirement already satisfied: uvicorn in ./.data/webide/pip/lib/python3.7/site-packages (from paddlenlp) (0.20.0)Requirement already satisfied: tqdm in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (4.64.1)Requirement already satisfied: dill=5.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (5.1.2)Requirement already satisfied: numpy>=1.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (1.19.5)Requirement already satisfied: pyarrow>=6.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (10.0.0)Requirement already satisfied: fsspec[http]>=2021.11.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (2022.11.0)Requirement already satisfied: requests>=2.19.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (2.24.0)Requirement already satisfied: xxhash in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (3.1.0)Requirement already satisfied: importlib-metadata in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (4.2.0)Requirement already satisfied: packaging in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (21.3)Requirement already satisfied: aiohttp in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (3.8.3)Requirement already satisfied: responses=2.0.0->paddlenlp) (0.18.0)Requirement already satisfied: pandas in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (1.1.5)Requirement already satisfied: Jinja2>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babelpaddlenlp) (3.0.0)Requirement already satisfied: pytz in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babelpaddlenlp) (2019.3)Requirement already satisfied: Babel>=2.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babelpaddlenlp) (2.8.0)Requirement already satisfied: Flask in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babelpaddlenlp) (1.1.1)Requirement already satisfied: filelock in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from huggingface-hub>=0.11.1->paddlenlp) (3.0.12)Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from huggingface-hub>=0.11.1->paddlenlp) (4.3.0)Requirement already satisfied: starlette=0.24.0 in ./.data/webide/pip/lib/python3.7/site-packages (from fastapi->paddlenlp) (0.24.0)Requirement already satisfied: pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,=1.6.2 in ./.data/webide/pip/lib/python3.7/site-packages (from fastapi->paddlenlp) (1.10.4)Requirement already satisfied: wcwidth>=0.2.5 in ./.data/webide/pip/lib/python3.7/site-packages (from ftfy->ppdiffusers) (0.2.6)Requirement already satisfied: pygments=2.6.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from rich->paddlenlp) (2.13.0)Requirement already satisfied: commonmark=0.9.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from rich->paddlenlp) (0.9.1)Requirement already satisfied: scikit-learn>=0.21.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from seqeval->paddlenlp) (0.24.2)Requirement already satisfied: click=7.1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from typer->paddlenlp) (8.0.4)Requirement already satisfied: h21>=0.8 in ./.data/webide/pip/lib/python3.7/site-packages (from uvicorn->paddlenlp) (0.14.0)Requirement already satisfied: matplotlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (2.2.3)Requirement already satisfied: six>=1.14.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (1.16.0)Requirement already satisfied: protobuf>=3.11.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (3.20.0)Requirement already satisfied: bce-python-sdk in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (0.8.53)Requirement already satisfied: Werkzeug>=0.15 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->Flask-Babelpaddlenlp) (0.16.0)Requirement already satisfied: itsdangerous>=0.24 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->Flask-Babelpaddlenlp) (1.1.0)Requirement already satisfied: attrs>=17.3.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (22.1.0)Requirement already satisfied: aiosignal>=1.1.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.2.0)Requirement already satisfied: multidict=4.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (6.0.2)Requirement already satisfied: async-timeout=4.0.0a3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (4.0.2)Requirement already satisfied: asynctest==0.13.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (0.13.0)Requirement already satisfied: frozenlist>=1.1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.3.0)Requirement already satisfied: yarl=1.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.7.2)Requirement already satisfied: charset-normalizer=2.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (2.1.1)Requirement already satisfied: MarkupSafe>=2.0.0rc2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Jinja2>=2.5->Flask-Babelpaddlenlp) (2.0.1)Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from packaging->datasets>=2.0.0->paddlenlp) (3.0.9)Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (2019.9.11)Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (1.25.11)Requirement already satisfied: chardet=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (3.0.4)Requirement already satisfied: idna=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (2.8)Requirement already satisfied: scipy>=0.19.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (1.6.3)Requirement already satisfied: joblib>=0.11 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (0.14.1)Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (2.1.0)Requirement already satisfied: anyio=3.4.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from starlette=0.24.0->fastapi->paddlenlp) (3.6.1)Requirement already satisfied: future>=0.6.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl->paddlenlp) (0.18.0)Requirement already satisfied: pycryptodome>=3.8.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl->paddlenlp) (3.9.9)Requirement already satisfied: zipp>=0.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from importlib-metadata->datasets>=2.0.0->paddlenlp) (3.8.1)Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (1.1.0)Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (2.8.2)Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (0.10.0)Requirement already satisfied: sniffio>=1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from anyio=3.4.0->starlette=0.24.0->fastapi->paddlenlp) (1.3.0)Requirement already satisfied: setuptools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib->visualdl->paddlenlp) (56.2.0)[notice] A new release of pip available: 22.1.2 -> 23.0.1[notice] To update, run: pip install --upgrade pip

       

2. 准备要训练的图片

在这里我们已经在dogs文件夹准备好了如下所示的5张图片。使用Lora技术进行Dreambooth训练【抢先体验版】 - 创想鸟            

3. 开始训练

参数解释:

pretrained_model_name_or_path :想要训练的模型名称,例如:”runwayml/stable-diffusion-v1-5″,更多模型可参考 paddlenlp 文档instance_data_dir:想要训练的图片地址。instance_prompt:训练的prompt文本。resolution:训练时图像的大小,建议为512。train_batch_size:训练时候使用的batch_size,可不修改。gradient_accumulation_steps:梯度累积的步数,可不修改。checkpointing_steps:每隔多少步保存模型。learning_rate:训练使用的学习率。report_to:我们将训练过程中出的图片导出到visudl工具中。lr_scheduler:学习率衰减策略,可以是:”linear”, “constant”, “cosine”,”cosine_with_restarts”等。lr_warmup_steps:学习率衰减前,warmup到最大学习率所需要的步数。max_train_steps:最多训练多少步。validation_prompt:训练的过程中我们会评估训练的怎么样,因此我们需要设置评估使用的prompt文本。validation_epochs:每隔多少个epoch评估模型,我们可以查看训练的进度条,知道当前到了第几个epoch。validation_guidance_scale:评估过程中的CFG引导值,默认为5.0.seed:随机种子,设置后可以复现训练结果。lora_rank:lora 的 rank值,默认为128,与开源的版本保持一致。use_lion:表示是否使用lion优化器,如果我们不想使用lion的话需要把 –use_lion True 表示使用 –use_lion False 表示不使用。lora_weight_or_path:我们需要加载的lora权重,当前支持:pt,ckpt,safetensors,和pdparams这些格式,可直接加载这里的lora权重 https://civitai.com/models。

注意:

会保存2种格式的权重,一个是paddle的,一个是safetensors的,可以使用 https://github.com/bmaltais/kohya_ss 这个人的加载。

dreambooth lora

In [6]

!python train_dreambooth_lora.py   --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5"    --instance_data_dir="./dogs"   --output_dir="./dream_booth_lora_outputs"   --instance_prompt="a photo of sks dog"   --resolution=512   --train_batch_size=1   --gradient_accumulation_steps=1   --checkpointing_steps=100   --learning_rate=1e-4   --report_to="visualdl"   --lr_scheduler="constant"   --lr_warmup_steps=0   --max_train_steps=500   --lora_rank=128   --validation_prompt="A photo of sks dog in a bucket"   --validation_epochs=25   --validation_guidance_scale=5.0   --use_lion False   --seed=0

       

[2023-02-23 10:13:09,015] [ WARNING] - You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.W0223 10:13:09.018703 11490 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 11.2, Runtime API Version: 11.2W0223 10:13:09.022612 11490 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.Train Steps:  20%|███████████████████████▌                                                                                              | 100/500 [01:12<03:04,  2.16it/s, epoch=0019, step_loss=0.0413]Saved lora weights to ./dream_booth_lora_outputs/checkpoint-100Train Steps:  40%|███████████████████████████████████████████████▌                                                                       | 200/500 [02:25<02:19,  2.15it/s, epoch=0039, step_loss=0.446]Saved lora weights to ./dream_booth_lora_outputs/checkpoint-200Train Steps:  60%|██████████████████████████████████████████████████████████████████████▏                                              | 300/500 [03:37<01:33,  2.13it/s, epoch=0059, step_loss=0.00273]Saved lora weights to ./dream_booth_lora_outputs/checkpoint-300Train Steps:  80%|███████████████████████████████████████████████████████████████████████████████████████████████▏                       | 400/500 [04:53<00:47,  2.11it/s, epoch=0079, step_loss=0.275]Saved lora weights to ./dream_booth_lora_outputs/checkpoint-400Train Steps: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500/500 [05:44<00:00,  2.14it/s, epoch=0099, step_loss=0.00985]Saved lora weights to ./dream_booth_lora_outputs/checkpoint-500Saved final lora weights to ./dream_booth_lora_outputsTrain Steps: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500/500 [05:48<00:00,  1.43it/s, epoch=0099, step_loss=0.00985]

       

文生图 lora

–train_data_dir 这个需要放图文对的文件夹,里面是图片和txt。

Gnomic智能体平台 Gnomic智能体平台

国内首家无需魔法免费无限制使用的ChatGPT4.0,网站内设置了大量智能体供大家免费使用,还有五款语言大模型供大家免费使用~

Gnomic智能体平台 47 查看详情 Gnomic智能体平台

–image_format 表示 train_data_dir 文件夹内的图片格式,比如png,jpg,jpeg

–use_lion Fasle 表示不使用lion优化器。

In [3]

!python train_text_to_image_lora.py   --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5"    --output_dir="./text_to_image_lora_outputs3"   --train_data_dir="mishanwu"   --image_format="png"   --resolution=512   --train_batch_size=1   --gradient_accumulation_steps=1   --checkpointing_steps=500   --learning_rate=6e-5   --report_to="visualdl"   --lr_scheduler="cosine_with_restarts"   --lr_warmup_steps=0   --max_train_steps=1000   --lora_rank=128   --validation_prompt="1girl, solo, black_background, looking_at_viewer, parted_lips, tears, brown_eyes"   --validation_epochs=1   --validation_guidance_scale=5.0   --use_lion False   --seed=0

       

[2023-02-23 11:11:34,386] [ WARNING] - You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.W0223 11:11:34.389356  7327 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 11.2, Runtime API Version: 11.2W0223 11:11:34.392953  7327 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.Resolving data files: 100%|████████████████| 581/581 [00:00<00:00, 50722.06it/s]Using custom data configuration default-4fb24e511b7f6118Downloading and preparing dataset imagefolder/default to /home/aistudio/.cache/huggingface/datasets/imagefolder/default-4fb24e511b7f6118/0.0.0/37fbb85cc714a338bea574ac6c7d0b5be5aff46c1862c1989b20e0771199e93f...Downloading data files #0:   0%|                        | 0/19 [00:00<?, ?obj/s]Downloading data files #3:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #1:   0%|                        | 0/19 [00:00<?, ?obj/s]Downloading data files #7:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #6:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #4:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #0: 100%|█████████████| 19/19 [00:00<00:00, 3045.97obj/s]Downloading data files #3: 100%|█████████████| 18/18 [00:00<00:00, 2919.24obj/s]Downloading data files #10:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #11:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #1: 100%|█████████████| 19/19 [00:00<00:00, 2589.92obj/s]Downloading data files #4: 100%|█████████████| 18/18 [00:00<00:00, 4414.54obj/s]Downloading data files #7: 100%|█████████████| 18/18 [00:00<00:00, 2468.45obj/s]Downloading data files #6: 100%|█████████████| 18/18 [00:00<00:00, 2742.57obj/s]Downloading data files #2: 100%|█████████████| 19/19 [00:00<00:00, 3250.74obj/s]Downloading data files #12:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #13:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #8:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #10: 100%|████████████| 18/18 [00:00<00:00, 2681.49obj/s]Downloading data files #11: 100%|████████████| 18/18 [00:00<00:00, 2829.21obj/s]Downloading data files #15: 100%|████████████| 18/18 [00:00<00:00, 5331.37obj/s]Downloading data files #5: 100%|█████████████| 18/18 [00:00<00:00, 2877.96obj/s]Downloading data files #13: 100%|████████████| 18/18 [00:00<00:00, 7175.88obj/s]Downloading data files #14: 100%|████████████| 18/18 [00:00<00:00, 9971.93obj/s]Downloading data files #8: 100%|█████████████| 18/18 [00:00<00:00, 6747.47obj/s]Downloading data files #12: 100%|████████████| 18/18 [00:00<00:00, 4458.07obj/s]Downloading data files #9: 100%|█████████████| 18/18 [00:00<00:00, 2966.27obj/s]Downloading data files #2:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #3:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #2: 100%|█████████████| 18/18 [00:00<00:00, 8158.36obj/s]Downloading data files #0:   0%|                        | 0/19 [00:00<?, ?obj/s]Downloading data files #4: 100%|█████████████| 18/18 [00:00<00:00, 7530.17obj/s]Downloading data files #3: 100%|█████████████| 18/18 [00:00<00:00, 5302.16obj/s]Downloading data files #0: 100%|█████████████| 19/19 [00:00<00:00, 8757.34obj/s]Downloading data files #8:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #9:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #7:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #1:   0%|                        | 0/19 [00:00<?, ?obj/s]Downloading data files #5: 100%|█████████████| 18/18 [00:00<00:00, 4015.18obj/s]Downloading data files #6:   0%|                        | 0/18 [00:00<?, ?obj/s]Downloading data files #8: 100%|█████████████| 18/18 [00:00<00:00, 4227.42obj/s]Downloading data files #7: 100%|█████████████| 18/18 [00:00<00:00, 4900.21obj/s]Downloading data files #6: 100%|█████████████| 18/18 [00:00<00:00, 9804.87obj/s]Downloading data files #11: 100%|████████████| 18/18 [00:00<00:00, 4705.36obj/s]Downloading data files #9: 100%|█████████████| 18/18 [00:00<00:00, 3152.95obj/s]Downloading data files #10: 100%|████████████| 18/18 [00:00<00:00, 6718.65obj/s]Downloading data files #1: 100%|█████████████| 19/19 [00:00<00:00, 3689.60obj/s]Downloading data files #15:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #13:   0%|                       | 0/18 [00:00<?, ?obj/s]Downloading data files #12: 100%|████████████| 18/18 [00:00<00:00, 6109.20obj/s]Downloading data files #15: 100%|███████████| 18/18 [00:00<00:00, 11363.26obj/s]Downloading data files #13: 100%|███████████| 18/18 [00:00<00:00, 13148.29obj/s]Downloading data files #14: 100%|███████████| 18/18 [00:00<00:00, 16183.81obj/s]Extracting data files #0:   0%|                         | 0/19 [00:00<?, ?obj/s]Extracting data files #3:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #2:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #1:   0%|                         | 0/19 [00:00<?, ?obj/s]Extracting data files #7:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #9:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #5:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #6:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #10:   0%|                        | 0/18 [00:00<?, ?obj/s]Extracting data files #8:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #4:   0%|                         | 0/18 [00:00<?, ?obj/s]Extracting data files #11:   0%|                        | 0/18 [00:00<?, ?obj/s]Extracting data files #12:   0%|                        | 0/18 [00:00<?, ?obj/s]Extracting data files #13:   0%|                        | 0/18 [00:00<?, ?obj/s]Extracting data files #15:   0%|                        | 0/18 [00:00<?, ?obj/s]Extracting data files #3: 100%|██████████████| 18/18 [00:00<00:00, 1565.14obj/s]Extracting data files #0: 100%|██████████████| 19/19 [00:00<00:00, 1405.75obj/s]Extracting data files #2: 100%|██████████████| 18/18 [00:00<00:00, 1560.64obj/s]Extracting data files #1: 100%|██████████████| 19/19 [00:00<00:00, 1753.47obj/s]Extracting data files #7: 100%|██████████████| 18/18 [00:00<00:00, 1907.66obj/s]Extracting data files #9: 100%|██████████████| 18/18 [00:00<00:00, 1972.81obj/s]Extracting data files #5: 100%|██████████████| 18/18 [00:00<00:00, 2031.58obj/s]Extracting data files #6: 100%|██████████████| 18/18 [00:00<00:00, 2102.00obj/s]Extracting data files #8: 100%|██████████████| 18/18 [00:00<00:00, 2238.62obj/s]Extracting data files #12: 100%|█████████████| 18/18 [00:00<00:00, 2500.58obj/s]Extracting data files #10: 100%|█████████████| 18/18 [00:00<00:00, 1698.37obj/s]Extracting data files #13: 100%|█████████████| 18/18 [00:00<00:00, 2295.87obj/s]Extracting data files #4: 100%|██████████████| 18/18 [00:00<00:00, 1713.79obj/s]Extracting data files #11: 100%|█████████████| 18/18 [00:00<00:00, 1759.56obj/s]Extracting data files #15: 100%|█████████████| 18/18 [00:00<00:00, 2079.59obj/s]Extracting data files #14: 100%|█████████████| 18/18 [00:00<00:00, 1828.07obj/s]Dataset imagefolder downloaded and prepared to /home/aistudio/.cache/huggingface/datasets/imagefolder/default-4fb24e511b7f6118/0.0.0/37fbb85cc714a338bea574ac6c7d0b5be5aff46c1862c1989b20e0771199e93f. Subsequent calls will reuse this data.100%|████████████████████████████████████████████| 1/1 [00:00<00:00, 256.14it/s]Train Steps:  29%|▎| 290/1000 [02:14<05:22,  2.20it/s, epoch=0000, step_loss=0.1You have disabled the safety checker for  by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. PaddleNLP team, diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .Train Steps:  50%|▌| 500/1000 [04:16<03:54,  2.13it/s, epoch=0001, step_loss=0.0Saved lora weights to ./text_to_image_lora_outputs3/checkpoint-500Train Steps:  58%|▌| 580/1000 [04:55<03:09,  2.22it/s, epoch=0001, step_loss=0.2You have disabled the safety checker for  by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. PaddleNLP team, diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .Train Steps:  87%|▊| 870/1000 [07:40<00:58,  2.22it/s, epoch=0002, step_loss=0.0You have disabled the safety checker for  by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. PaddleNLP team, diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .Train Steps: 100%|█| 1000/1000 [09:10<00:00,  1.25it/s, epoch=0003, step_loss=0.Saved lora weights to ./text_to_image_lora_outputs3/checkpoint-1000You have disabled the safety checker for  by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. PaddleNLP team, diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .Saved final lora weights to ./text_to_image_lora_outputs3Train Steps: 100%|█| 1000/1000 [09:44<00:00,  1.71it/s, epoch=0003, step_loss=0.

       

4. 启动visualdl程序,查看我们训练过程中出图情况

使用Lora技术进行Dreambooth训练【抢先体验版】 - 创想鸟使用Lora技术进行Dreambooth训练【抢先体验版】 - 创想鸟        

5. 加载训练好的文件进行推理

In [1]

import lora_helperfrom allinone import StableDiffusionPipelineAllinOnefrom ppdiffusers import DPMSolverMultistepSchedulerimport paddle# 基础模型,需要是paddle版本的权重,未来会加更多的权重pretrained_model_name_or_path = "runwayml/stable-diffusion-v1-5"# 我们加载safetensor版本的权重lora_outputs_path = "9070.safetensors"# 加载之前的模型pipe = StableDiffusionPipelineAllinOne.from_pretrained(pretrained_model_name_or_path, safety_checker=None)pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)# 加载lora权重from IPython.display import clear_output, displayclear_output()pipe.apply_lora(lora_outputs_path)

       

|---------------当前的rank是 128!|---------------当前的alpha是 128.0!Loading lora_weights successfully!

       In [5]

import lora_helperfrom allinone import StableDiffusionPipelineAllinOnefrom ppdiffusers import DPMSolverMultistepSchedulerprompt               = "A photo of sks dog in a bucket"negative_prompt      = ""guidance_scale       = 8num_inference_steps  = 25height               = 512width                = 512img = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=guidance_scale, height=height, width=width, num_inference_steps=num_inference_steps).images[0]display(img)display(img.argument)

       

  0%|          | 0/25 [00:00<?, ?it/s]

               


               

{'prompt': 'A photo of sks dog in a bucket', 'negative_prompt': '', 'height': 512, 'width': 512, 'num_inference_steps': 25, 'guidance_scale': 8, 'num_images_per_prompt': 1, 'eta': 0.0, 'seed': 3574959348, 'latents': None, 'max_embeddings_multiples': 1, 'no_boseos_middle': False, 'skip_parsing': False, 'skip_weighting': False, 'epoch_time': 1676862593.5281246}

               

以上就是使用Lora技术进行Dreambooth训练【抢先体验版】的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/316914.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
Python编程夏令营线上平台推荐 暑期儿童Python专项学习网站官网汇总
上一篇 2025年11月5日 08:08:20
不用下载!曝PS Portal即将支持数字版游戏云端直玩
下一篇 2025年11月5日 08:08:33

相关推荐

  • 荣耀GT 2系列配置曝光:9000mAh电池+165Hz直屏

    荣耀GT 2系列配置曝光:9000mAh电池+165Hz直屏荣耀GT 2系列配置曝光:9000mAh电池+165Hz直屏荣耀GT 2系列配置曝光:9000mAh电池+165Hz直屏荣耀GT 2系列配置曝光:9000mAh电池+165Hz直屏

    10月13日,一位数码博主透露,某款搭载骁龙8系旗舰平台的新机正在规划一款硅基电池,其容量预计将达到约9000mah。这一超大电池容量在当前智能手机市场中极为少见,意味着该机型在续航能力上将拥有显著优势。结合该博主的暗示以及网友的讨论分析,这款新机极有可能是即将发布的荣耀gt 2系列。 荣耀GT P…

    2026年9月22日 用户投稿
    100
  • 一加Pro系列微信收款语音怎么开启?快速设置支付播报的方法

    首先检查微信内“收款小账本”开启语音播报功能,其次确保手机系统给予微信通知权限、关闭勿扰模式、媒体音量正常,并在电池设置中避免微信后台被限制,同时更新微信至最新版本;若需个性化,可通过系统通知渠道单独设置收款通知的声音与优先级,但无法更换播报音色;使用时注意公共场合隐私保护,务必核对屏幕金额以防误报…

    2026年9月22日
    100
  • PHP匿名函数怎么用_PHP匿名函数使用场景分析

    PHP匿名函数是无名函数,可作为回调或赋值给变量,常用在数组处理、事件回调、逻辑封装等场景,支持use引入外部变量及fn短语法,结合bindTo可访问对象私有成员。 PHP匿名函数,也叫闭包函数(Closure),是一种没有名称的函数,通常作为回调使用或赋值给变量。它在实际开发中非常灵活,尤其适合用…

    2026年9月22日
    100
  • 抖音专营店怎么添加直播号?怎么把新开的抖音号添加到专营店里

    随着抖音平台社交属性不断增强,内容生态日益丰富,越来越多电商从业者开始在该平台上开展业务。其中,抖音专营店作为电商布局的重要一环,也吸引了大量商家入驻。那么,如何将直播号加入抖音专营店中,让直播成为店铺引流和销售的新工具呢?接下来的内容将为您详细介绍。 一、为什么要在抖音专营店中添加直播号 提升店铺…

    2026年9月22日
    000
  • 中国联通正式获得开展 eSIM 手机运营服务商用试验的批复

    感谢网友 会弹琴的九号、学士 的线索投递! 10月13日,三大运营商官方微信号相继发布消息,宣告eSIM服务进入新阶段。其中,中国联通于当日上午10:00率先发布推文《抢约!联通eSIM来了!》,动作迅速,展现出强烈的市场积极性;中国移动在傍晚19:29发布《中国移动全面上线eSIM手机办理》;而中…

    2026年9月22日
    200
  • Meeseeks— 美团开源的模型指令遵循能力评测集

    Meeseeks— 美团开源的模型指令遵循能力评测集Meeseeks— 美团开源的模型指令遵循能力评测集Meeseeks— 美团开源的模型指令遵循能力评测集Meeseeks— 美团开源的模型指令遵循能力评测集

    ☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜ AGI-Eval评测社区 AI大模型评测社区 63 查看详情 Meeseeks是什么 meeseeks 是由美团 m17 团队推出的开源大模型评测基准,专注于评估模型在指令遵循方面的能力。该评测…

    2026年9月22日 用户投稿
    200
  • mysql怎么使用全文索引 mysql创建全文索引的配置方法

    mysql怎么使用全文索引 mysql创建全文索引的配置方法mysql怎么使用全文索引 mysql创建全文索引的配置方法mysql怎么使用全文索引 mysql创建全文索引的配置方法mysql怎么使用全文索引 mysql创建全文索引的配置方法

    mysql使用全文索引的核心是让数据库像搜索引擎一样理解并高效检索文本内容。1. 创建全文索引:可在建表时或之后通过alter table语句为char、varchar或text字段添加fulltext索引;2. 使用match against查询:支持自然语言模式(自动过滤停用词并按相关性排序)和…

    2026年9月22日 用户投稿
    100
  • VSCode如何通过调试变量监视列表批量追踪数据变化 VSCode变量监视列表批量追踪的新颖技巧​

    VSCode如何通过调试变量监视列表批量追踪数据变化 VSCode变量监视列表批量追踪的新颖技巧​VSCode如何通过调试变量监视列表批量追踪数据变化 VSCode变量监视列表批量追踪的新颖技巧​VSCode如何通过调试变量监视列表批量追踪数据变化 VSCode变量监视列表批量追踪的新颖技巧​VSCode如何通过调试变量监视列表批量追踪数据变化 VSCode变量监视列表批量追踪的新颖技巧​

    vscode中高效批量追踪数据变化的关键是将监视列表用作表达式求值器,而非仅添加单一变量;2. 可在监视列表中添加复杂对象路径(如user.profile.address.city)、计算表达式(如(a + b) * c)、函数调用(如calculatetotal(items))或条件判断(如myv…

    2026年9月22日 用户投稿
    000
  • 如何设置Linux服务超时参数 systemd服务超时配置

    如何设置Linux服务超时参数 systemd服务超时配置如何设置Linux服务超时参数 systemd服务超时配置如何设置Linux服务超时参数 systemd服务超时配置如何设置Linux服务超时参数 systemd服务超时配置

    systemd服务超时参数调整方法包括:1.使用systemctl show查看timeoutstartsec、timeoutstopsec、timeoutsec字段获取当前配置;2.通过systemctl edit编辑unit文件设置timeoutstartsec、timeoutstopsec或t…

    2026年9月22日 用户投稿
    000
  • 360浏览器如何切换极速模式

    在浏览网页时,想要获得更流畅、更快速的上网体验,许多用户都希望将360浏览器切换至极速模式。那么具体该如何操作呢?以下是几种简单有效的方法。 方法一:通过地址栏图标一键切换 打开360浏览器后,留意地址栏右侧,会看到一个闪电图标和一个书本图标的组合。其中,闪电代表极速模式,书本则代表兼容模式。只需点…

    2026年9月22日
    100
  • c盘清理工具哪个好用_好用的C盘清理工具推荐与使用评测

    推荐C盘清理方案:系统自带工具如磁盘清理、存储感知和手动清%temp%目录安全可靠,适合日常维护;第三方工具CCleaner、金舟Windows优化大师、风云C盘清理大师和全能C盘清理专家提供一键深度清理,操作便捷且误删率低;空间分析工具WizTree、SpaceSniffer和TreeSize可可…

    2026年9月22日
    000
  • mysql安装完如何诊断 mysql慢查询分析与优化方法

    要解决 mysql 慢查询问题,首先要开启慢查询日志,其次使用 mysqldumpslow 分析日志,再通过 explain 查看执行计划,最后根据常见优化建议改进 sql 和索引。具体步骤如下:一、修改配置文件或动态开启慢查询日志,并设置阈值和路径;二、使用 mysqldumpslow 工具分析慢…

    2026年9月22日
    100
  • 主板供电相数对CPU超频稳定性的影响:14相 vs. 20相实测

    20相供电主板在超频下表现更稳,实测显示其VRM温度更低、电压波动更小、性能输出更一致,尤其适合极限超频和高负载场景,而14相供电配合优质用料也能满足主流超频需求,普通用户无需盲目追求高相数。 主板供电相数直接影响CPU在高负载和超频状态下的电压稳定性和温度控制。很多人在选择主板时会看到“14相”或…

    2026年9月22日
    200
  • PHP如何实现视频留言评论_PHP实现视频留言评论功能

    答案:通过数据库设计、前端表单、后端处理和评论展示四步实现PHP视频留言功能。1. 创建comments表存储信息;2. 构建表单提交昵称与评论;3. 用add_comment.php接收并存入数据库;4. 在页面读取并安全输出评论,防止XSS。 要实现视频留言评论功能,PHP可以结合前端页面、数据…

    2026年9月22日
    000
  • Java中如何区分逻辑错误和系统异常

    系统异常是程序运行中由JVM抛出的RuntimeException,如空指针、数组越界,会导致程序中断并打印堆栈;逻辑错误是程序语法正确但结果不符预期,如条件写反、循环次数错误,不会崩溃但行为异常。两者区别在于是否抛出异常、是否中断执行及调试方式不同,需通过防御性编程、单元测试和日志调试加以防范。 …

    2026年9月22日
    000
  • 歧路旅人2兑换码是什么 八方旅人2最新2025兑换码大全

    歧路旅人2最新通用兑换码:qlyrdldbz2025、qdn4xkcndx、qllrdldbz等,可在游戏内商城直接使用,领取剑士黄金武器皮肤、双倍经验加成及1000叶币,奖励丰富限时有效,先到先得。 无限资源畅玩|游戏辅助工具: 2025年最新可用兑换码汇总如下: 1、兑换码: qlyrdldbz…

    2026年9月22日
    000
  • mysql安装后怎么建表 mysql创建数据表的详细步骤

    mysql安装后怎么建表 mysql创建数据表的详细步骤mysql安装后怎么建表 mysql创建数据表的详细步骤mysql安装后怎么建表 mysql创建数据表的详细步骤mysql安装后怎么建表 mysql创建数据表的详细步骤

    安装完 mysql 后,建表的关键在于先创建数据库并选择使用,然后通过 create table 语句定义表结构。1. 创建数据库:使用 create database mydatabase; 创建数据库;2. 使用数据库:通过 use mydatabase; 选择当前操作的数据库;3. 建表语法:…

    2026年9月22日 用户投稿
    200
  • LINUX怎么查看哪个进程占用了某个端口_LINUX端口占用查询方法

    使用ss或lsof命令可快速查看端口占用情况,如sudo ss -tulnp | grep :端口号或sudo lsof -i :端口号,结合PID进一步通过ps或/proc文件系统定位进程详情。 在Linux系统中,查看某个端口被哪个进程占用,常用的方法是使用命令行工具结合网络和进程信息进行查询。…

    2026年9月22日
    000
  • 夸克浏览器电脑网页版访问入口 夸克官网主页链接地址

    夸克浏览器电脑网页版访问入口是https://www.quark.cn/,用户可直接在浏览器地址栏输入该链接访问,其界面采用极简设计并集成智能搜索、网盘服务与跨设备同步等功能。 立即进入“☞☞☞☞☞点击夸克资源网(永久免费)入口☜☜☜☜☜”; 立即进入“☞☞☞☞☞点击夸克浏览器电脑网页版访问入口☜☜…

    2026年9月22日
    500
  • 抖音小店如何运营?普通人开店选品与推广的实用策略

    抖音小店如何运营?普通人开店选品与推广的实用策略抖音小店如何运营?普通人开店选品与推广的实用策略抖音小店如何运营?普通人开店选品与推广的实用策略抖音小店如何运营?普通人开店选品与推广的实用策略

    新手做抖音小店最现实的问题是没钱投广告和没专业团队,解决方法是抓住选品和推广两个核心环节。一、选品要找市场需求高且利润合理的商品,避开竞争激烈或太冷门的品类,结合多平台数据测试;二、前期重点用“商品卡”推广,通过短视频展示产品使用场景并挂链接引流,成本低且适合测试;三、适当尝试直播积累经验,但不依赖…

    2026年9月22日 用户投稿
    400

发表回复

登录后才能评论
关注微信