-
Notifications
You must be signed in to change notification settings - Fork 23
/
svgdreamer.py
42 lines (31 loc) · 1.23 KB
/
svgdreamer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
# Author: ximing xing
# Description: the main func of this project.
# Copyright (c) 2023, XiMing Xing.
import os
import sys
from functools import partial
from accelerate.utils import set_seed
import hydra
import omegaconf
sys.path.append(os.path.split(os.path.abspath(os.path.dirname(__file__)))[0])
from svgdreamer.utils import render_batch_wrap, get_seed_range
from svgdreamer.pipelines.SVGDreamer_pipeline import SVGDreamerPipeline
@hydra.main(version_base=None, config_path="conf", config_name='config')
def main(cfg: omegaconf.DictConfig):
"""
The project configuration is stored in './conf/config.yaml'
And style configurations are stored in './conf/x/iconographic.yaml'
"""
# set seed
set_seed(cfg.seed)
seed_range = get_seed_range(cfg.srange) if cfg.multirun else None
# render function
render_batch_fn = partial(render_batch_wrap, cfg=cfg, seed_range=seed_range)
if not cfg.multirun: # generate SVG multiple times
pipe = SVGDreamerPipeline(cfg)
pipe.painterly_rendering(cfg.prompt)
else: # generate many SVG at once
render_batch_fn(pipeline=SVGDreamerPipeline, text_prompt=cfg.prompt, target_file=None)
if __name__ == '__main__':
main()