Kohaku is a cute dragon girl.

TIPO

By kblueleaf on Oct 6, 2024
Image post

TIPO: Text to Image with text presampling for Prompt Optimization

Tech Report: https://kblueleaf.net/document/TIPO-tech-report.pdf

image/png

Introduction

In this project, we introduce “TIPO” (Text to Image with text presampling for Prompt Optimization), an innovative framework designed to significantly enhance the quality and usability of Text-to-Image (T2I) generative models. TIPO utilizes the Large Language Models (LLMs) to perform “Text Presampling” within the inference pipeline of text-to-image generative modeling. By refining and extending user input prompts, TIPO enables generative models to produce superior results with minimal user effort, making T2I systems more accessible and effective for a wider range of users.

Usage

Use updated version of DTG extension (renamed to z-tipo-extension), current version of z-tipo-extension support stable-diffusion-webui, stable-diffusion-webui-forge and ComfyUI. SD-Next haven’t been tested. https://github.com/KohakuBlueleaf/z-tipo-extension

Model arch and Training

This model is LLaMA arch with 200M parameters, the training data is combined version of Danbooru2023, GBC10M and Coyo-HD-11M.<br> The total token seen is around 40B tokens.<br> For more information please refer to the tech report and following table.

TIPO-200MTIPO-500M
ArchLLaMALLaMA
Max ctx length10241024
Batch Size20483584
Training datasetDanbooru, GBC10M, 5epoch
Danbooru, GBC10M, Coyo11M, 3epoch
Danbooru, GBC10M, Coyo11M, 5epoch
Real Token Seen*40B token30B token
Training HardwareRTX 3090 x 4H100 x 8
Training Time420 hour`100 hour`
URLKBlueLeaf/TIPO-200M · Hugging FaceKBlueLeaf/TIPO-500M · Hugging Face

*: We only count “non-padding token” in the token seen, since all the training data have very large length range <br/> : Since the training data is pretty short, it cost more time to reach same token seen than general LLM pretraining.
` As reference, with 4096 as max ctx length and almost all the data have reach that length, you may only need 2days to reach 10B token seen on RTX 3090 x 4 with 200M model.

Evaluation

We have tested TIPO in several metric:

1. Aesthetic Score (Higher is Better)

We compute the Aesthetic Score using the Aesthetic Predictor V2.5. This metric is calculated on the short/truncated long test.

Aesthetic Score Distribution

Figure 1: Aesthetic Score distribution.

2. AI Corrupt Score (Higher is Better)

The AI Corrupt Score is obtained from the AICorruptMetrics in sdeval.

This metric is calculated on the short/truncated long test.

AI Corrupt Score Distribution

Figure 2: AI Corrupt Score distribution.

3. Frechet Dino Distance (FDD) on Scenery Tag Test

We use FDD on the Scenery Tag Test to demonstrate that when input prompts address a smaller distribution, the model struggles to generate images that reflect the true distribution. However, with TIPO, this issue is mitigated.

FDD Model<meta> scenery only<meta> scenery + TIPO
DinoV2 ViT-S0.19170.1786
DinoV2 ViT-B0.20020.1755
DinoV2 ViT-L0.20170.1863
DinoV2 ViT-G0.23590.2096

Table 1: Frechet Dino Distance (FDD) on Scenery Tag Test.

Download Models

TIPO-200M: https://huggingface.co/KBlueLeaf/TIPO-200M
TIPO-500M: https://huggingface.co/KBlueLeaf/TIPO-500M

LICENSE

The Model is released under Kohaku License 1.0<br> You can check the above provided URL or check the LICENSE file in this repo.

Citation

@misc{yeh2024tipo,
  title = {TIPO: Text to Image with text presampling for Prompt Optimization},
  author = {Yeh, Shih-Ying},
  year = {2024},
  month = {10},
  day = {6},
  note = {Technical report available at \url{https://kblueleaf.net/document/TIPO-tech-report.pdf}. 
          Model available at \url{https://huggingface.co/KBlueLeaf/TIPO-500M}. 
          Source code available at \url{https://github.com/KohakuBlueleaf/KGen}},
}
© Copyright 2024 by Kohaku BlueLeaf.
All media on this site, including text, images, and videos, is licensed under CC BY-NC-ND 4.0