在这项工作中,作者展示了一个在图像像素表示上训练的文本条件扩散模型可以用来生成可导出SVG的矢量图形。
<div align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/67b645c8-d67d-41ae-9430-58f7fc00559d.gif" style="width: 100%; height: auto;" alt="VF视频"> <p>VectorFusion渲染过程。(64路径, 72视频, 5千)</p> </div>
创建新的conda环境:
conda create --name vf python=3.10 conda activate vf
安装pytorch和以下库:
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia pip install omegaconf BeautifulSoup4 pip install shapely pip install opencv-python scikit-image matplotlib visdom wandb pip install triton numba pip install numpy scipy timm scikit-fmm einops pip install accelerate transformers safetensors datasets
安装CLIP:
pip install ftfy regex tqdm pip install git+https://github.com/openai/CLIP.git
安装diffusers:
pip install diffusers==0.20.2
安装xformers(需要python=3.10):
conda install xformers -c xformers
安装diffvg:
git clone https://github.com/BachiLi/diffvg.git cd diffvg git submodule update --init --recursive conda install -y -c anaconda cmake conda install -y -c conda-forge ffmpeg pip install svgwrite svgpathtools cssutils torch-tools python setup.py install
docker run --name vectorfusion --gpus all -it --ipc=host ximingxing/svgrender:v1 /bin/bash
提示词: 悉尼歌剧院。<br/> 风格: 图标<br/> 预览:
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/d1e9bb44-0635-4867-b8ed-2ee32f616323.png" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/6b2b6428-c742-4c4d-b914-0ea90f6f533f.svg" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/fa83d213-8126-452e-b123-5d6a4b17202a.svg" style="width: 250px; height: 250px;"> |
|---|---|---|
| (a) 使用Stable Diffusion采样的栅格图像 | (b) 通过LIVE将栅格图像转换为矢量图 | (c) VectorFusion:通过LSDS微调 |
LIVE渲染过程:
| 迭代0 | 迭代500 | 迭代1000 | 迭代1500 | 迭代2500 | 迭代3500 |
|---|---|---|---|---|---|
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/6df609ac-d4b2-449c-b084-1c8bcd1f1479.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/72ab89af-e3d5-4362-86bf-0f93497eb048.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/88616133-5d28-41be-bbf1-680c6305e90f.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/ec93d8f7-e8c7-4475-8eab-74e208c0a035.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/f7d7ec1f-3168-41e5-b1c6-85606a21e195.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/c800dbb1-7c3e-4231-a9b8-8e0a57903842.svg"> |
VectorFusion渲染过程:
| 迭代0 | 迭代100 | 迭代300 | 迭代400 | 迭代700 | 迭代1000 |
|---|---|---|---|---|---|
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/ab85ecec-f0be-4d03-8f1e-ad67c5b6481c.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/a25ab52e-9391-4309-9ce5-bcd6fb19b60e.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/d431806d-23fc-49f9-95ef-17c1bf613ee8.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/e4187912-b1d8-447d-8b31-93bacf8081d4.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/cd88d41a-d39b-4c57-a797-a5764ec32fcf.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/fa83d213-8126-452e-b123-5d6a4b17202a.svg"> |
脚本:
python run_painterly_render.py \ -c vectorfusion.yaml \ -pt "悉尼歌剧院。极简平面2D矢量图标。线性颜色。白色背景。ArtStation流行" \ -save_step 50 \ -update "K=6" \ -respath ./workdir/SydneyOperaHouse \ -d 15486 \ --download
-c 即 --config:配置文件。-save_step:用于保存结果的步长(调用过于频繁会导致时间更长)。-update:用于编辑配置文件的超参数的工具,因此无需创建新的yaml文件。-pt 即 --prompt:文本提示。-respath 即 --results_path:保存结果的文件夹。-d 即 --seed:随机种子。--download:首次运行时自动从huggingface下载模型。可选:
-npt,即 --negative_prompt:负面文本提示。-mv,即 --make_video:制作渲染过程的视频(这将花费更长时间)。-frame_freq,即 --video_frame_freq:保存图像的步数间隔。-framerate,即 --video_frame_rate:控制输出视频的播放速度。提示词: 皮革桌面上的明代花瓶照片。<br/> 风格: 图标<br/> 预览:
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/27681156-a372-4696-a247-1484cff35b3c.png" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/aebcfe59-d1de-44b3-8e4a-708b72659dd9.svg" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/fe88de57-e86e-446a-96bf-274efe67146a.svg" style="width: 250px; height: 250px;"> |
|---|---|---|
| (a) 使用Stable Diffusion采样的栅格图像 | (b) 通过LIVE将栅格图像转换为矢量图 | (c) VectorFusion:通过LSDS微调 |
脚本:
python run_painterly_render.py -c vectorfusion.yaml -pt "皮革桌面上的明代花瓶照片。极简平面2D矢量图标。线性颜色。白色背景。ArtStation流行" -save_step 50 -respath ./workdir/vase -d 683692
提示词: 宇航员形象。<br/> 风格: 图标<br/> 预览:
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/6970dd0a-01e8-4f5c-995c-7774a354c433.png" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/552eec61-bbd6-4799-af92-83de94ad22b4.svg" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/9e42ff3b-4e0a-4149-bf05-d3b556381d97.svg" style="width: 250px; height: 250px;"> |
|---|---|---|
| (a) 使用Stable Diffusion生成的栅格图像样本 | (b) 通过LIVE将栅格图像转换为矢量图 | (c) VectorFusion: 通过LSDS进行微调 |
脚本:
python run_painterly_render.py -c vectorfusion.yaml -pt "宇航员形象。极简平面2D矢量图标。线性配色。白色背景。Artstation热门" -save_step 50 -respath ./workdir/astronaut -d 522178
提示词: 电吉他 <br/> 风格: 像素艺术 <br/> 预览:
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/0f28b561-219b-42d7-8d3f-3fc1b65262ab.png" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/a679203d-3874-4a7e-86d7-ce8cd9f140db.svg" style="width: 250px; height: 250px;"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/c5630585-0b29-409f-80df-950f6f72698b.svg" style="width: 250px; height: 250px;"> |
|---|---|---|
| (a) 使用Stable Diffusion生成的栅格图像样本 | (b) 通过LIVE将栅格图像转换为矢量图 | (c) VectorFusion: 通过LSDS进行微调 |
脚本:
python run_painterly_render.py -c vectorfusion.yaml -pt "电吉他。像素艺术。Artstation热门" -save_step 50 -respath ./workdir/guitar -update "style=pixelart" -d 445997
提示词: 一条喷火龙的水彩画。 <br/> 风格: 素描 <br/> 预览:
| <img src="https://yellow-cdn.veclightyear.com/835a84d5/fdccecbf-f256-4093-bd77-023b5dfc4cea.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/78a75d27-a21a-4997-a92a-e97b115a9282.svg"> | <img src="https://yellow-cdn.veclightyear.com/835a84d5/e7469e5d-5e7a-4b08-aaec-974f4c9569f2.svg"> |
|---|---|---|
| SVG初始化 | VectorFusion微调500步 | VectorFusion微调1500步 |
脚本:
python run_painterly_render.py -c vectorfusion.yaml -pt "一条喷火龙的水彩画。极简2D线条绘画。Artstation热门" -save_step 50 -respath ./workdir/dragon-sketch -update "style=sketch num_segments=5 radius=0.5 sds.num_iter=1500" -d 106764
# 素描风格 CUDA_VISIBLE_DEVICES=0 python run_painterly_render.py -c vectorfusion.yaml -pt "一条喷火龙的水彩画。极简2D线条绘画。Artstation热门" -save_step 50 -respath ./workdir/dragon-sketch -update "style=sketch skip_live=True num_paths=32 num_segments=5 radius=0.5 sds.num_iter=1500" -rdbz CUDA_VISIBLE_DEVICES=0 python run_painterly_render.py -c vectorfusion.yaml -pt "一只猫。极简2D线条绘画。Artstation热门" -save_step 50 -respath ./workdir/cat-sketch -update "style=sketch skip_live=True num_paths=32 num_segments=5 radius=0.5 sds.num_iter=1500" -rdbz
更多示例:
更多脚本:
本项目基于以下仓库构建:
我们衷心感谢这些作者的杰出工作。
如果您在研究中使用了这份代码,请引用以下论文:
@inproceedings{jain2023vectorfusion,
title={Vectorfusion: Text-to-svg by abstracting pixel-based diffusion models},
author={Jain, Ajay and Xie, Amber and Abbeel, Pieter},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={1911--1920},
year={2023}
}
@inproceedings{xing2023diffsketcher,
title={DiffSketcher: Text Guided Vector Sketch Synthesis through Latent Diffusion Models},
author={XiMing Xing and Chuang Wang and Haitao Zhou and Jing Zhang and Qian Yu and Dong Xu},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=CY1xatvEQj}
}
本仓库采用MIT许可证。


免费创建高清无水印Sora视频
Vora是一个免费创建高清无水印Sora视频的AI工具


最适合小白的AI自动化工作流平台
无需编码,轻松生成可复用、可变现的AI自动化工作流

大模型驱动的Excel数据处理工具
基于大模型交互 的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


AI论文写作指导平台
AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。


AI一键生成PPT,就用博思AIPPT!
博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。


AI赋能电商视觉革命,一站式智能商拍平台
潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。


企业专属的AI法律顾问
iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。


稳定高效的流量提升解决方案,助力品牌曝光
稳定高效的流量提升解决方案,助力品牌曝光


最新版Sora2模型免费使用,一键生成无水印视频
最新版Sora2模型免费使用,一键生成无水印视频
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号