在这项工作中,作者展示了一个在图像像素表示上训练的文本条件扩散模型可以用来生成可导出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许可证。
一站式AI创作平台
提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作
AI办公助手,复杂任务高效处理
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!
AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。
AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写 、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
全能AI智能助手,随时解答生活与工作的多样问 题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音 频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理 解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号