Home

Awesome

Implementation of the paper DS-Fusion: Artistic Typography via Discriminated and Stylized Diffusion

Link for project page DS-Fusion

DS-Fusion

alt text

PIPELINE

alt text

Setting up basic environment

Use environment.yaml from the official Stable Diffusion project, to set up the environment.

conda env create -f environment.yaml

You will also need to download the checkpoint named "model.ckpt" from Source. For ease, we provide an alternative link Link for the checkpoint file we used in our project from the latent-diffusion official source.

Basic generation

Please run the following script to finetune for a specific style and text. Only single alpha-numeric characters can be accepted. For ease of use, some font data has been generated for quick testing. List of these fonts is in ldm/data/list_fonts.py. If you use the name of one of these fonts, please use them with the --one_font argument. Only capital letters and numbers can be used for this purpose, as only they are available pre generated.

python script_basic.py -s "DRAGON" -t "R" --one_font "False" --font_name "ani" --white_bg "True" --cartoon "True"   --ckpt_path "ckpt/model.ckpt"
python txt2img.py --ddim_eta 1.0 --n_samples 6 --n_iter 1 --ddim_steps 50 --scale 5.0 --H 256 --W 256 --outdir out --ckpt  logs/DRAGON-R/checkpoints/last.ckpt --prompt "DRAGON R"

Custom Font

python script_basic.py -s "DRAGON" -t "R" --custom_font "TlwgTypist-Bold.ttf" --white_bg "True" --cartoon "True"  --ckpt_path "ckpt/model.ckpt"
python txt2img.py --ddim_eta 1.0 --n_samples 6 --n_iter 1 --ddim_steps 50 --scale 5.0 --H 256 --W 256 --outdir out --ckpt  logs/DRAGON-R/checkpoints/last.ckpt --prompt "DRAGON R"

Generating results using pre-trained Generic Use model

A pre-trained model has been trained over all capital letters and numbers, to provide a fast generation. This method was trained using 40 categories (in classes.txt) but has generalized sufficiently to out of training examples. Please download the checkpoint file from Link and place it in ckpt folder. Write prompt as "style style-attributes letter" Please make sure the letter is either a capital letter between A-Z or a number 0-9, otherwise it is unlikely to work well.

python txt2img.py --use_generic "True" --ddim_eta 1.0 --n_samples 6 --n_iter 1 --ddim_steps 50 --scale 5.0 --H 256 --W 256 --outdir out_generic --ckpt  ckpt/ds-fusion-generic.ckpt --prompt "DRAGON R"

Examples of Results

alt text

Acknowledgement

The implementation is based on Stable Diffusion/Latent Diffusion Git-Source. The discriminator structure is referenced from DC-GAN.