SD文字创意变形

我要开发同款
匿名用户2024年07月31日
29阅读
所属分类aipytorch、word-as-image、stable diffusion、text-to-SVG、semantic typography
开源地址https://modelscope.cn/models/feitianwa/cv_sd_WordAsImage
授权协议CC-BY-NC-4.0

作品详情

Word-As-Image 文字创意变形

word-as-image模型主要目的是根据输入的创意进行中英文字母的语义变形,最后输出相应的SVG图,更多详细信息可点击word-as-image

模型描述

创意变形字示例

上图为对应不同的字体及创意下的文字变形效果图,其中具体字母的变化均是通过算法自动完成。

算法框图

算法具体的流程框图如上所示。

期望模型使用方式以及适用范围

该模型适用于中英文创意字变形场景,参与变形的字母可以是一个或多个字。

如何使用模型

  • 输入需要变形的字母、文字、字体、期望达到的创意效果、以及迭代次数,按下列代码范例进行模型推理,输出变形之后的字母及文字。
  • 其中需要变形的字母以及创意为必须输入项,其余三个有系统默认值。

运行环境准备(依赖及安装)

  1. conda环境以及依赖库安装:
conda create --name word python=3.8.15
conda activate word
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
conda install -y numpy scikit-image
conda install -y -c anaconda cmake
conda install -y -c conda-forge ffmpeg
pip install svgwrite svgpathtools cssutils numba torch-tools scikit-fmm easydict visdom freetype-py shapely
pip install opencv-python==4.5.4.60  
pip install kornia==0.6.8
pip install wandb
pip install shapely
  1. 安装diffusers:
pip install diffusers==0.8
pip install transformers scipy ftfy accelerate
  1. 安装diffvg:
git clone https://github.com/BachiLi/diffvg.git
cd diffvg
git submodule update --init --recursive
python setup.py install

代码范例

from modelscope.pipelines import pipeline
gamma =1 

input = {"semantic_concept":"cat","word":"CAT","letter":"C","font_name":"STHUPO","num_steps":500}
inference = pipeline('my-WordAsImage-task', model="feitianwa/cv_sd_WordAsImage")
result_letter, result_word = inference(input)
result_word = result_word.detach().cpu()
pydiffvg.imwrite(result_letter, "result_letter.png", gamma=gamma)
pydiffvg.imwrite(result_word, "result_word.png", gamma=gamma)

模型局限性以及可能的偏差

  • 建议在有GPU的机器上进行测试,由于硬件精度影响,CPU上的结果会和GPU上的结果略有差异。

相关论文以及引用信息

本模型主要参考论文如下:

@misc{iluz2023wordasimage,
      title={Word-As-Image for Semantic Typography}, 
      author={Shir Iluz and Yael Vinker and Amir Hertz and Daniel Berio and Daniel Cohen-Or and Ariel Shamir},
      year={2023},
      eprint={2303.01818},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Clone with HTTP

 git clone https://www.modelscope.cn/feitianwa/cv_sd_WordAsImage.git
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论