Paint-by-Example 项目使用教程

Paint-by-Example 项目使用教程

Paint-by-Example Paint by Example: Exemplar-based Image Editing with Diffusion Models Paint-by-Example 项目地址: https://gitcode.com/gh_mirrors/pa/Paint-by-Example

1. 项目目录结构及介绍

Paint-by-Example/
├── configs/
│   ├── v1.yaml
│   └── ...
├── examples/
│   ├── image/
│   ├── mask/
│   └── reference/
├── ldm/
│   ├── models/
│   ├── modules/
│   └── ...
├── scripts/
│   ├── inference.py
│   ├── read_bbox.py
│   └── ...
├── test_bench/
│   ├── test_set_GT/
│   └── ...
├── LICENSE
├── README.md
├── environment.yaml
├── inference_test_bench.sh
├── main.py
├── setup.py
├── test.sh
└── train.sh

目录结构介绍

  • configs/: 包含项目的配置文件,如 v1.yaml
  • examples/: 包含示例图像、掩码和参考图像。
  • ldm/: 包含扩散模型的核心代码,如模型定义、模块等。
  • scripts/: 包含用于推理、数据准备等的脚本。
  • test_bench/: 包含测试基准数据集。
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的介绍文档。
  • environment.yaml: 项目的依赖环境配置文件。
  • inference_test_bench.sh: 用于推理测试的脚本。
  • main.py: 项目的主启动文件。
  • setup.py: 项目的安装脚本。
  • test.sh: 用于测试的脚本。
  • train.sh: 用于训练的脚本。

2. 项目启动文件介绍

main.py

main.py 是项目的启动文件,用于训练新的模型。可以通过以下命令启动训练:

python -u main.py \
  --logdir models/Paint-by-Example \
  --pretrained_model pretrained_models/sd-v1-4-modified-9channel.ckpt \
  --base configs/v1.yaml \
  --scale_lr False

inference.py

inference.py 是用于推理的脚本,可以通过以下命令进行推理:

python scripts/inference.py \
  --plms \
  --outdir results \
  --config configs/v1.yaml \
  --ckpt checkpoints/model.ckpt \
  --image_path examples/image/example_1.png \
  --mask_path examples/mask/example_1.png \
  --reference_path examples/reference/example_1.jpg \
  --seed 321 \
  --scale 5

3. 项目的配置文件介绍

environment.yaml

environment.yaml 是项目的依赖环境配置文件,可以通过以下命令创建并激活环境:

conda env create -f environment.yaml
conda activate Paint-by-Example

configs/v1.yaml

configs/v1.yaml 是项目的配置文件,包含了训练和推理的参数设置。例如:

# 示例配置文件内容
model:
  name: "Paint-by-Example"
  version: "v1"
  batch_size: 16
  learning_rate: 0.0001
  epochs: 40

通过这些配置文件,可以灵活地调整项目的训练和推理参数。

Paint-by-Example Paint by Example: Exemplar-based Image Editing with Diffusion Models Paint-by-Example 项目地址: https://gitcode.com/gh_mirrors/pa/Paint-by-Example

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

解释这些参数optional arguments: -h, --help show this help message and exit --host HOST --port PORT --config-installer Open config web page, mainly for windows installer (default: False) --load-installer-config Load all cmd args from installer config file (default: False) --installer-config INSTALLER_CONFIG Config file for windows installer (default: None) --model {lama,ldm,zits,mat,fcf,sd1.5,cv2,manga,sd2,paint_by_example,instruct_pix2pix} --no-half Using full precision model. If your generate result is always black or green, use this argument. (sd/paint_by_exmaple) (default: False) --cpu-offload Offloads all models to CPU, significantly reducing vRAM usage. (sd/paint_by_example) (default: False) --disable-nsfw Disable NSFW checker. (sd/paint_by_example) (default: False) --sd-cpu-textencoder Run Stable Diffusion text encoder model on CPU to save GPU memory. (default: False) --local-files-only Use local files only, not connect to Hugging Face server. (sd/paint_by_example) (default: False) --enable-xformers Enable xFormers optimizations. Requires xformers package has been installed. See: https://github.com/facebookresearch/xformers (sd/paint_by_example) (default: False) --device {cuda,cpu,mps} --gui Launch Lama Cleaner as desktop app (default: False) --no-gui-auto-close Prevent backend auto close after the GUI window closed. (default: False) --gui-size GUI_SIZE GUI_SIZE Set window size for GUI (default: [1600, 1000]) --input INPUT If input is image, it will be loaded by default. If input is directory, you can browse and select image in file manager. (default: None) --output-dir OUTPUT_DIR Result images will be saved to output directory automatically without confirmation. (default: None) --model-dir MODEL_DIR Model download directory (by setting XDG_CACHE_HOME environment variable), by default model downloaded to ~/.cache (default: /Users/cwq/.cache) --disable-model-switch Disable model switch in frontend (default: False)
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李华蓓Garret

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值