功能概述
基于扩散模型的图像特征抽取,可用于做特征点匹配。
Project Page | Paper | Colab Demo
环境准备
安装独立repo库
pip install git+https://github.com/junjiehe96/modelscope_dift.git
运行代码
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
from modelscope_dift import ms_wrapper
model = 'damo/cv_stable-diffusion-v2_image-feature'
pipe = pipeline('feature_extraction', model=model, device='gpu', auto_collate=False, model_revision='v1.0.2')
out1 = pipe('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/face_recognition_1.png', img_size=0,
t=261, up_ft_index=1, prompt='a photo of a girl', ensemble_size=4, seed=0)[OutputKeys.OUTPUT] # 1*C*H*W
print(out1)
参数说明
img_size
: 在输入扩散模型之前调整图像的宽度和高度。 如果设置为 0,则不会执行调整大小操作,因此它将坚持原始图像大小。 默认设置为 [768, 768]。 如果遇到内存问题,您可以减少此值。t
: 扩散的时间步长,范围[0, 1000]中选择,必须是整数。 对于语义对应,默认 t=261。up_ft_index
: 用于提取特征图的 U-Net 上采样块的索引,从 [0, 1, 2, 3] 中选择。 upftindex=1 默认情况下语义对应。prompt
: 扩散模型中使用的提示。ensemble_size
: 每批中用于获取特征的重复图像的数量。 默认情况下 ensemble_size=8。 如果遇到内存问题,您可以减小该值。seed
: 随机种子,默认为None
引用
如果你觉得这个模型对你有所帮助,请考虑引用下面的相关论文:
@article{tang2023emergent,
title={Emergent Correspondence from Image Diffusion},
author={Tang, Luming and Jia, Menglin and Wang, Qianqian and Phoo, Cheng Perng and Hariharan, Bharath},
journal={arXiv preprint arXiv:2306.03881},
year={2023}
}
Clone with HTTP
git clone https://www.modelscope.cn/damo/cv_stable-diffusion-v2_image-feature.git
评论