xingxm commited on
Commit
99c0203
·
1 Parent(s): acdfbd8

fix(optimize): use fp16 as default

Browse files
.gitignore CHANGED
@@ -170,4 +170,5 @@ lightning_logs/*
170
  /tmp_select/
171
  /tmp_select/*
172
  /logs/
173
- /logs/*
 
 
170
  /tmp_select/
171
  /tmp_select/*
172
  /logs/
173
+ /logs/*
174
+ _Record.md
Examples.md CHANGED
@@ -161,9 +161,3 @@ expressive eyes. <br/>
161
  ````shell
162
  python svgdreamer.py x=painting "prompt='self portrait of Van Gogh. oil painting. cmyk portrait. multi colored. defiant and beautiful. cmyk. expressive eyes.'" x.num_paths=256 result_path='./logs/VanGogh-Portrait'
163
  ````
164
-
165
- ### Case: planet Saturn
166
-
167
- ```shell
168
- python svgdreamer.py x=iconography-s1 skip_sive=False "prompt='An icon of the planet Saturn. minimal flat 2D vector icon. plain color background. trending on ArtStation.'" token_ind=6 x.sive.bg.num_iter=50 x.sive.fg.num_iter=50 x.vpsd.t_schedule='randint' result_path='./logs/Saturn' multirun=True state.mprec='fp16
169
- ```
 
161
  ````shell
162
  python svgdreamer.py x=painting "prompt='self portrait of Van Gogh. oil painting. cmyk portrait. multi colored. defiant and beautiful. cmyk. expressive eyes.'" x.num_paths=256 result_path='./logs/VanGogh-Portrait'
163
  ````
 
 
 
 
 
 
README.md CHANGED
@@ -1,7 +1,11 @@
1
  # SVGDreamer: Text Guided SVG Generation with Diffusion Model
2
 
 
 
3
  [![CVPR 2024](https://img.shields.io/badge/CVPR%202024-Paper-4169E1?style=for-the-badge&logo=arxiv&logoColor=white)](https://arxiv.org/abs/2312.16476) [![arXiv](https://img.shields.io/badge/arXiv-2312.16476-8A2BE2?style=for-the-badge&logo=arxiv&logoColor=white)](https://arxiv.org/abs/2312.16476) [![Project Website](https://img.shields.io/badge/Website-Project%20Page-4682B4?style=for-the-badge&logo=github&logoColor=white)](https://ximinng.github.io/SVGDreamer-project/) [![English Blog](https://img.shields.io/badge/Blog-English-00CED1?style=for-the-badge&logo=huggingface&logoColor=white)](https://huggingface.co/blog/xingxm/svgdreamer) [![中文博客](https://img.shields.io/badge/博客-中文-1E90FF?style=for-the-badge&logo=zhihu&logoColor=white)](https://zhuanlan.zhihu.com/p/687525994)
4
 
 
 
5
  This repository contains the official implementation of our CVPR 2024 paper, "SVGDreamer: Text-Guided SVG Generation
6
  with Diffusion Model." The method leverages a diffusion-based approach to produce high-quality SVGs guided by text
7
  prompts.
@@ -60,7 +64,7 @@ If you prefer manual setup, download the model from Hugging Face:
60
 
61
  The model will be stored at:
62
 
63
- 📁 Default Path: `/home/user/.cache/huggingface/hub/models--stabilityai--stable-diffusion-2-1-base`
64
 
65
  ## 🔥 Quickstart: synthesize **6** SVGs at once
66
 
@@ -255,7 +259,7 @@ We gratefully thank the authors for their wonderful works.
255
  If you use this code for your research, please cite the following work:
256
 
257
  ```
258
- @InProceedings{svgdreamer_xing_2023,
259
  author = {Xing, Ximing and Zhou, Haitao and Wang, Chuang and Zhang, Jing and Xu, Dong and Yu, Qian},
260
  title = {SVGDreamer: Text Guided SVG Generation with Diffusion Model},
261
  booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
 
1
  # SVGDreamer: Text Guided SVG Generation with Diffusion Model
2
 
3
+ <div align="center" style="line-height: 1;">
4
+
5
  [![CVPR 2024](https://img.shields.io/badge/CVPR%202024-Paper-4169E1?style=for-the-badge&logo=arxiv&logoColor=white)](https://arxiv.org/abs/2312.16476) [![arXiv](https://img.shields.io/badge/arXiv-2312.16476-8A2BE2?style=for-the-badge&logo=arxiv&logoColor=white)](https://arxiv.org/abs/2312.16476) [![Project Website](https://img.shields.io/badge/Website-Project%20Page-4682B4?style=for-the-badge&logo=github&logoColor=white)](https://ximinng.github.io/SVGDreamer-project/) [![English Blog](https://img.shields.io/badge/Blog-English-00CED1?style=for-the-badge&logo=huggingface&logoColor=white)](https://huggingface.co/blog/xingxm/svgdreamer) [![中文博客](https://img.shields.io/badge/博客-中文-1E90FF?style=for-the-badge&logo=zhihu&logoColor=white)](https://zhuanlan.zhihu.com/p/687525994)
6
 
7
+ </div>
8
+
9
  This repository contains the official implementation of our CVPR 2024 paper, "SVGDreamer: Text-Guided SVG Generation
10
  with Diffusion Model." The method leverages a diffusion-based approach to produce high-quality SVGs guided by text
11
  prompts.
 
64
 
65
  The model will be stored at:
66
 
67
+ 📁 Default Path: `~/.cache/huggingface/hub/models--stabilityai--stable-diffusion-2-1-base`
68
 
69
  ## 🔥 Quickstart: synthesize **6** SVGs at once
70
 
 
259
  If you use this code for your research, please cite the following work:
260
 
261
  ```
262
+ @InProceedings{xing2024svgdreamer,
263
  author = {Xing, Ximing and Zhou, Haitao and Wang, Chuang and Zhang, Jing and Xu, Dong and Yu, Qian},
264
  title = {SVGDreamer: Text Guided SVG Generation with Diffusion Model},
265
  booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
conf/config.yaml CHANGED
@@ -11,7 +11,7 @@ skip_sive: True # optimize from scratch without SIVE init
11
  # Accelerate config
12
  state:
13
  cpu: False # use cpu
14
- mprec: 'no' # mixed precision, choices: 'no', 'fp16', 'bf16'
15
 
16
  # Diffusers config
17
  diffuser:
 
11
  # Accelerate config
12
  state:
13
  cpu: False # use cpu
14
+ mprec: 'fp16' # mixed precision, choices: 'no', 'fp16', 'bf16'
15
 
16
  # Diffusers config
17
  diffuser:
svgdreamer/painter/VPSD_pipeline.py CHANGED
@@ -11,8 +11,8 @@ import torch.nn.functional as F
11
  from torchvision import transforms
12
  from diffusers import StableDiffusionPipeline, UNet2DConditionModel
13
  from diffusers import DDIMScheduler
14
- from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import (
15
- rescale_noise_cfg, StableDiffusionPipelineOutput)
16
  from diffusers.models.attention_processor import LoRAAttnProcessor
17
  from diffusers.loaders import AttnProcsLayers
18
 
 
11
  from torchvision import transforms
12
  from diffusers import StableDiffusionPipeline, UNet2DConditionModel
13
  from diffusers import DDIMScheduler
14
+ from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import rescale_noise_cfg, \
15
+ StableDiffusionPipelineOutput
16
  from diffusers.models.attention_processor import LoRAAttnProcessor
17
  from diffusers.loaders import AttnProcsLayers
18
 
svgdreamer/painter/painter_params.py CHANGED
@@ -320,7 +320,7 @@ class Painter(DiffVGState):
320
  select_path_ids_by_opc = get_keys_below_threshold(opacity_record_, opacity_threshold)
321
 
322
  if len(select_path_ids_by_opc) > 0:
323
- print("-> opacity_record: ", [f"{k}: {v:.3f}" for k, v in opacity_record_.items()])
324
  print("select_path_ids_by_opc: ", select_path_ids_by_opc)
325
  else:
326
  stats_np = np.array(list(opacity_record_.values()))
@@ -335,7 +335,7 @@ class Painter(DiffVGState):
335
  select_path_ids_by_area.append(shape.id)
336
 
337
  if len(select_path_ids_by_area) > 0:
338
- print("-> area_records: ", ['%.2f' % i for i in area_records])
339
  print("select_path_ids_by_area: ", select_path_ids_by_area)
340
  else:
341
  stats_np = np.array(area_records)
@@ -349,7 +349,7 @@ class Painter(DiffVGState):
349
  select_path_ids_by_opc = get_keys_below_threshold(opacity_record_, opacity_threshold)
350
 
351
  if len(select_path_ids_by_opc) > 0:
352
- print("-> opacity_record: ", [f"{k}: {v:.3f}" for k, v in opacity_record_.items()])
353
  print("select_path_ids_by_opc: ", select_path_ids_by_opc)
354
  else:
355
  stats_np = np.array(list(opacity_record_.values()))
 
320
  select_path_ids_by_opc = get_keys_below_threshold(opacity_record_, opacity_threshold)
321
 
322
  if len(select_path_ids_by_opc) > 0:
323
+ # print("-> opacity_record: ", [f"{k}: {v:.3f}" for k, v in opacity_record_.items()])
324
  print("select_path_ids_by_opc: ", select_path_ids_by_opc)
325
  else:
326
  stats_np = np.array(list(opacity_record_.values()))
 
335
  select_path_ids_by_area.append(shape.id)
336
 
337
  if len(select_path_ids_by_area) > 0:
338
+ # print("-> area_records: ", ['%.2f' % i for i in area_records])
339
  print("select_path_ids_by_area: ", select_path_ids_by_area)
340
  else:
341
  stats_np = np.array(area_records)
 
349
  select_path_ids_by_opc = get_keys_below_threshold(opacity_record_, opacity_threshold)
350
 
351
  if len(select_path_ids_by_opc) > 0:
352
+ # print("-> opacity_record: ", [f"{k}: {v:.3f}" for k, v in opacity_record_.items()])
353
  print("select_path_ids_by_opc: ", select_path_ids_by_opc)
354
  else:
355
  stats_np = np.array(list(opacity_record_.values()))