Textual Inversion 部署过程

简介

Textual Inversion的官方网址

https://github.com/rinongal/textual_inversion

在这里插入图片描述

首先需要使用conda创建环境

conda env create -f environment.yaml -p /path

​之后激活环境

conda activate your_env

然后将Textual Inversion克隆到本地

git clone https://github.com/rinongal/textual_inversion.git

之后到该目录下

 cd textual_inversion

之后按照官网的readme下载文件

mkdir -p models/ldm/text2img-large/
wget -O models/ldm/text2img-large/model.ckpt https://ommer-lab.com/files/latent-diffusion/nitro/txt2img-f8-large/model.ckpt

理论上现在运行程序即可

python main.py --base configs/latent-diffusion/txt2img-1p4B-finetune.yaml 
               -t 
               --actual_resume /path/to/pretrained/model.ckpt 
               -n <run_name> 
               --gpus 0, 
               --data_root /path/to/directory/with/images
               --init_word <initialization_word>

其中actual_resume就是之前下载的model.ckpt,它的地址在models/ldm/text2img-large/model.ckpt,-n之后随便填,不需要加<>,data_root是图片所在的文件夹,init_word就是对象的单标记粗略描述

程序之后会输出log,在log文件夹里可以看到生成的样品

可能出现的问题

RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

这个的解决方法如下述链接所示:

https://github.com/rinongal/textual_inversion/issues/124


ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’ (/home/jiasun/lun/ldm_env/lib/python3.8/site-packages/torchmetrics/utilities/data.py)

这个的解决方法如下述链接所示:
关于安装 PyTorch-Lightning 的一些问题(GPU版)
其实就是torchmetrics版本问题,使用

pip install torchmetrics==0.5

即可


packaging.version.InvalidVersion: Invalid version: ‘0.10.1,<0.11’

这个的解决方法如下述链接所示:
https://www.cnblogs.com/xiximayou/p/17089246.html
其实就是packaging版本问题

pip install packaging==21.3

就可以解决


ImportError: cannot import name ‘CLIPTokenizer’ from ‘transformers’ (unknown location)

其实就是transformers的版本太低,解决方法:

pip install transformers==4.13.0

AttributeError: module ‘PIL.Image’ has no attribute ‘LINEAR’
pillow库版本过高,解决方法:

pip install Pillow==9.5.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值