输入一张图,生成相似图
输入示例:
输出示例:
可通过参数调整输出图像与输入图像的相似度。
基于开源SD模型,修改生成引导条件,并在开源数据集laion-5B的部分数据上训练而来,模型结构如下:
安装独立repo库
pip install git+https://github.com/lllcho/image_variation.git
或者网络较慢时,使用如下命令安装:
pip install git+https://gitee.com/lllcho/image_variation.git
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
from PIL import Image
from image_variation import modelscope_warpper
model = 'damo/cv_image_variation_sd'
pipe = pipeline('image_variation_task', model=model, device='gpu',auto_collate=False)
out=pipe('https://vision-poster.oss-cn-shanghai.aliyuncs.com/lllcho.lc/data/test_data/sunset-landscape-sky-colorful-preview.jpg')
imgs=out[OutputKeys.OUTPUT_IMGS]
imgs[0].save(f'result.jpg')
pipeline调用时还支持以下可调参数:
num_inference_steps
: int, 默认为20guidance_scale
:float, 默认5.0num_images_per_prompt
:默认为1,每次调用返回几张图,可根据显存大小调整seed
:默认为None,int类型,取值范围[0, 2^32-1]height
::默认值512width
:默认值512noise_level
: int,默认值为0, 取值范围[0,999],表示像输入图像中加入噪声,值越大噪声越多,生成结果与输入图像的相似度越低完整参数调用示例:
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
from PIL import Image
from image_variation import modelscope_warpper
model = 'damo/cv_image_variation_sd'
pipe = pipeline('image_variation_task', model=model, device='gpu',auto_collate=False)
out=pipe('https://vision-poster.oss-cn-shanghai.aliyuncs.com/lllcho.lc/data/test_data/sunset-landscape-sky-colorful-preview.jpg',
num_inference_steps=20,
num_images_per_prompt=2,
guidance_scale=7.0,
height=512,
width=512,
seed=None,
noise_level=500
)