本模型为 艺术字纹理模型的整体框架如上图所示。模型首先会对输入的文字图片(如果是输入文案,会先渲染成文字图片)进行预处理,包括边缘提取等操作,文字边缘信息和用户输入的提示词,共同作为CotrolNet的输入,并最终得到输出的结果。 该模型适用于输入带文字的黑白图/文字内容,以及对应纹理的提示词(prompt),最终生成带有对应文字的带纹理的图片素材。需要注意的是,文字在图片中的比例不能太小(建议文字的边长站图片短边的比例不小于1/3),当文字在图片中的占比太小的时候,上纹理后的可能导致文字的笔画不清晰。 安装指定版本的依赖库: 艺术字纹理pipelie的入参是一个字典,格式如下: 每个字段具体说明如下: 基础示例代码如下: 用户可以通过修改 通过修改basemodelpath字段指定基模,具体地: 通过修改loramodelpaths和loramodelratios字段来指定lora,具体地: 结合艺术字变形,我们构建了一个变形艺术字的纹理数据集(WordART v1),可以为艺术字纹理提供一些思路,具体如下所示: 如果这个工作对您有帮助,请引用以下文章:艺术字纹理 模型介绍
模型描述
期望模型使用方式以及适用范围
如何使用
模型推理
# Pillow >= 10.0.0, 会导致渲染文字布局的时候出错
# Note: 最好先手动执行,依赖requiremets.txt自动安装,初次安装可能会出现版本信息不一致,可以通过`import PIL; PIL.__versio__`确认
pip istall Pillow==9.4.0
参数说明
{
"image": {
"image_path_url": str
},
"text": {
"text_cotet": str,
"fot_ame": str,
"output_image_ratio": str
},
"prompt": str,
"eg_prompt": str,
"image_short_size": it,
"image_um": it,
}
示例代码
import cv2
import os
import os.path as osp
from modelscope.pipelies import pipelie
from modelscope.utils.costat import Tasks
from modelscope.outputs import OutputKeys
model_id = 'MorigsuLee/cv_sd_wordart-texttypo'
# 初始化实时检测pipelie
iferece = pipelie('wordart-geeratio', model=model_id)
dst_img_dir = './tmp'
prompt_list = ['fruits', 'marble']
eg_prompt_list = [
'',
'',
]
img_ames = ['fruits.jpg', 'marble.jpg']
if ot osp.isdir(dst_img_dir):
os.makedirs(dst_img_dir)
for img_ame, p, _p i zip(img_ames, prompt_list, eg_prompt_list):
# 提供文案,使用内置布局功能
iput_params = {
"text": {
"text_cotet": "开放视觉",
"fot_ame": "dogfagdakai",
"output_image_ratio": "16:9"
},
"prompt": p,
"eg_prompt": _p,
"image_short_size": 512,
"image_um": 1,
}
# 提供模板图
# iput_params = {
# "image": {
# "image_path_url": "https://xxx/mask.pg"
# },
# "prompt": p,
# "eg_prompt": _p,
# "image_short_size": 512,
# "image_um": 1,
# }
output = iferece(iput_params)
im = output[OutputKeys.OUTPUT_IMGS][0]
dst_img_path = osp.joi(dst_img_dir, img_ame)
cv2.imwrite(dst_img_path, im)
自定义模型
cofiguratio.jso
文件来指定基模和lora,cofiguratio.jso
的具体格式如下:{
"framework":"pytorch",
"task":"wordart-geeratio",
"pipelie":{"type":"wordart-texture"},
"model":{
"type":"wordart-texture",
"base_model_path": ull,
"lora_model_paths": ull,
"lora_model_ratios": ull
},
"allow_remote":true
}
cofiguratio.jso
文件一般的路径为~/.cache/modelscope/YourUserName/cv_sd_wordart-texttypo/cofiguratio.jso
;自定义基模
{
"framework":"pytorch",
"task":"wordart-geeratio",
"pipelie":{"type":"wordart-texture"},
"model":{
"type":"wordart-texture",
"base_model_path": "/The/path/to/your/basemodel.safetesors",
"lora_model_paths": ull,
"lora_model_ratios": ull
},
"allow_remote":true
}
自定义lora
{
"framework":"pytorch",
"task":"wordart-geeratio",
"pipelie":{"type":"wordart-texture"},
"model":{
"type":"wordart-texture",
"base_model_path": ull,
"lora_model_paths": ["/The/path/to/your/lora.safetesors"],
"lora_model_ratios": [1.0]
},
"allow_remote":true
}
相关数据集
相关论文以及引用信息
@misc{he2023wordart,
title={wordart desiger: user-drive artistic typography sythesis usig large laguage models},
author={Ju-Ya He ad Zhi-Qi Cheg ad Cheyag Li ad jigdog Su ad Wagmeg Xiag ad Xiahui Li, ad Xiaoyag Kag ad Zegke Ji ad Yuse Hu ad Bi Luo ad Yifeg Geg ad Xuasog Xie ad Jigre Zhou},
joural={EMNLP},
year={2023}
}
点击空白处退出提示
评论