Learnable Regions 项目安装与配置指南

Learnable Regions 项目安装与配置指南

Learnable_Regions Official implementation of the work "Text-Driven Image Editing via Learnable Regions" (CVPR 2024) Learnable_Regions 项目地址: https://gitcode.com/gh_mirrors/le/Learnable_Regions

1. 项目基础介绍

"Learnable Regions" 是一个开源项目,它通过文本驱动的图像编辑技术,允许用户使用文本提示对图像进行区域编辑,而无需用户提供掩码或草图。该项目旨在提供一种简单而灵活的图像编辑方法,与当前的图像生成模型兼容,并能处理包含多个对象、复杂句子或长段落的复杂提示。该项目主要使用 Python 编程语言。

2. 项目使用的关键技术和框架

该项目利用了以下关键技术和框架:

  • 预训练的文本到图像模型:用于理解和生成与文本提示相对应的图像内容。
  • 边界框生成器:用于识别与文本提示相匹配的编辑区域。
  • PyTorch:一个开源的机器学习库,用于项目的深度学习模型训练和推理。
  • Stable Diffusion:一种用于图像修复和编辑的扩散模型。

3. 项目安装和配置的准备工作

在开始安装之前,请确保您的系统满足以下要求:

  • Python 3.9
  • conda (用于环境管理)
  • Git (用于克隆项目仓库)

详细安装步骤

  1. 克隆项目仓库

    打开终端(或命令提示符),执行以下命令以克隆项目仓库:

    git clone https://github.com/yuanze-lin/Learnable_Regions.git
    
  2. 创建虚拟环境并安装依赖

    进入项目目录,创建一个名为 LearnableRegion 的虚拟环境,并安装所需的 Python 包:

    cd Learnable_Regions
    conda create -n LearnableRegion python==3.9 -y
    source activate LearnableRegion
    pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
    conda env update --file environment.yaml
    

    请确保在执行上述命令时,您的系统已安装了 conda。

  3. 开始编辑图像

    根据您的需求,选择以下命令之一来编辑图像:

    • 编辑单个图像

      torchrun --nnodes=1 --nproc_per_node=1 train.py \
      --image_file_path images/1.png \
      --image_caption 'trees' \
      --editing_prompt 'a big tree with many flowers in the center' \
      --diffusion_model_path 'stabilityai/stable-diffusion-2-inpainting' \
      --output_dir output/ \
      --draw_box \
      --lr 5e-3 \
      --max_window_size 15 \
      --per_image_iteration 10 \
      --epochs 1 \
      --num_workers 8 \
      --seed 42 \
      --pin_mem \
      --point_number 9 \
      --batch_size 1 \
      --save_path checkpoints/
      
    • 编辑多个图像

      torchrun --nnodes=1 --nproc_per_node=2 train.py \
      --image_dir_path images/ \
      --output_dir output/ \
      --json_file images.json \
      --diffusion_model_path 'stabilityai/stable-diffusion-2-inpainting' \
      --draw_box \
      --lr 5e-3 \
      --max_window_size 15 \
      --per_image_iteration 10 \
      --epochs 1 \
      --num_workers 8 \
      --seed 42 \
      --pin_mem \
      --point_number 9 \
      --batch_size 1 \
      --save_path checkpoints/
      

    请根据您的具体情况调整命令中的参数。

以上步骤将帮助您成功安装和配置 "Learnable Regions" 项目,并开始图像编辑工作。

Learnable_Regions Official implementation of the work "Text-Driven Image Editing via Learnable Regions" (CVPR 2024) Learnable_Regions 项目地址: https://gitcode.com/gh_mirrors/le/Learnable_Regions

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

方苹奕

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

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

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

打赏作者

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

抵扣说明:

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

余额充值