Spaces:
Runtime error
Runtime error
Kohaku-Blueleaf
commited on
Commit
Β·
84b9ae2
1
Parent(s):
1b4fd22
use neutral naming
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TIPO DEMO
|
| 3 |
emoji: π
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
app.py
CHANGED
|
@@ -6,7 +6,7 @@ try:
|
|
| 6 |
import kgen
|
| 7 |
except:
|
| 8 |
GH_TOKEN = os.getenv("GITHUB_TOKEN")
|
| 9 |
-
git_url = f"https://{GH_TOKEN}@github.com/KohakuBlueleaf/
|
| 10 |
|
| 11 |
## call pip install
|
| 12 |
os.system(f"pip install git+{git_url}")
|
|
@@ -25,7 +25,7 @@ else:
|
|
| 25 |
from spaces import GPU
|
| 26 |
|
| 27 |
import kgen.models as models
|
| 28 |
-
import kgen.executor.
|
| 29 |
from kgen.formatter import seperate_tags, apply_format
|
| 30 |
from kgen.generate import generate
|
| 31 |
|
|
@@ -36,7 +36,7 @@ from meta import DEFAULT_NEGATIVE_PROMPT, DEFAULT_FORMAT
|
|
| 36 |
sdxl_pipe = load_model()
|
| 37 |
|
| 38 |
models.load_model(
|
| 39 |
-
"Amber-River/
|
| 40 |
device="cuda",
|
| 41 |
subfolder="500M-epoch3",
|
| 42 |
)
|
|
@@ -101,7 +101,7 @@ def generate(
|
|
| 101 |
escape_brackets,
|
| 102 |
):
|
| 103 |
default_format = DEFAULT_FORMAT[output_format]
|
| 104 |
-
|
| 105 |
generation_setting = {
|
| 106 |
"seed": seed,
|
| 107 |
"temperature": temp,
|
|
@@ -119,14 +119,14 @@ def generate(
|
|
| 119 |
if escape_brackets:
|
| 120 |
input_prompt = re.sub(r"([()\[\]])", r"\\\1", input_prompt)
|
| 121 |
|
| 122 |
-
meta, operations, general, nl_prompt =
|
| 123 |
seperate_tags(tags.split(",")),
|
| 124 |
nl_prompt,
|
| 125 |
tag_length_target=target_length,
|
| 126 |
generate_extra_nl_prompt="<|generated|>" in default_format or not nl_prompt,
|
| 127 |
)
|
| 128 |
t0 = time()
|
| 129 |
-
for result, timing in
|
| 130 |
meta, operations, general, nl_prompt, **generation_setting
|
| 131 |
):
|
| 132 |
result = apply_format(result, default_format)
|
|
@@ -183,11 +183,11 @@ if __name__ == "__main__":
|
|
| 183 |
with gr.Accordion("Introduction and Instructions", open=False):
|
| 184 |
gr.Markdown(
|
| 185 |
"""
|
| 186 |
-
##
|
| 187 |
**The model for demo is 500M version with 4epoch training (25B token seen)**
|
| 188 |
|
| 189 |
### What is this
|
| 190 |
-
|
| 191 |
<br>It can work on both Danbooru tags and Natural Language. Which means you can use it on almost all the existed T2I models.
|
| 192 |
<br>You can take it as "pro max" version of [DTG](https://huggingface.co/KBlueLeaf/DanTagGen-delta-rev2)
|
| 193 |
|
|
@@ -196,7 +196,7 @@ TITPOP is a tool to extend, generate, refine the input prompt for T2I models.
|
|
| 196 |
2. Enter your NL Prompt(optional): put the desired natural language prompt into "Natural Language Prompt" box
|
| 197 |
3. Enter your black list(optional): put the desired black list into "black list" box
|
| 198 |
4. Adjust the settings: length, temp, top_p, min_p, top_k, seed ...
|
| 199 |
-
4. Click "
|
| 200 |
5. If you like the result, click "Generate Image From Result" button
|
| 201 |
* You will see 2 generated images, left one is based on your prompt, right one is based on refined prompt
|
| 202 |
* The backend is diffusers, there are no weighting mechanism, so Escape Brackets is default to False
|
|
@@ -208,7 +208,7 @@ TITPOP is a tool to extend, generate, refine the input prompt for T2I models.
|
|
| 208 |
4. Once the project/research are done, I will open source all these models/codes with Apache2 license.
|
| 209 |
|
| 210 |
### Notification
|
| 211 |
-
**
|
| 212 |
<br>The generated image is come from [Kohaku-XL-Zeta](https://huggingface.co/KBlueLeaf/Kohaku-XL-Zeta) model**
|
| 213 |
"""
|
| 214 |
)
|
|
@@ -285,7 +285,7 @@ TITPOP is a tool to extend, generate, refine the input prompt for T2I models.
|
|
| 285 |
escape_brackets = gr.Checkbox(
|
| 286 |
label="Escape Brackets", value=False
|
| 287 |
)
|
| 288 |
-
submit = gr.Button("
|
| 289 |
with gr.Accordion("Speed statstics", open=False):
|
| 290 |
cost_time = gr.Markdown()
|
| 291 |
with gr.Column(scale=5):
|
|
|
|
| 6 |
import kgen
|
| 7 |
except:
|
| 8 |
GH_TOKEN = os.getenv("GITHUB_TOKEN")
|
| 9 |
+
git_url = f"https://{GH_TOKEN}@github.com/KohakuBlueleaf/TIPO-KGen@tipo"
|
| 10 |
|
| 11 |
## call pip install
|
| 12 |
os.system(f"pip install git+{git_url}")
|
|
|
|
| 25 |
from spaces import GPU
|
| 26 |
|
| 27 |
import kgen.models as models
|
| 28 |
+
import kgen.executor.tipo as tipo
|
| 29 |
from kgen.formatter import seperate_tags, apply_format
|
| 30 |
from kgen.generate import generate
|
| 31 |
|
|
|
|
| 36 |
sdxl_pipe = load_model()
|
| 37 |
|
| 38 |
models.load_model(
|
| 39 |
+
"Amber-River/tipo",
|
| 40 |
device="cuda",
|
| 41 |
subfolder="500M-epoch3",
|
| 42 |
)
|
|
|
|
| 101 |
escape_brackets,
|
| 102 |
):
|
| 103 |
default_format = DEFAULT_FORMAT[output_format]
|
| 104 |
+
tipo.BAN_TAGS = [t.strip() for t in black_list.split(",") if t.strip()]
|
| 105 |
generation_setting = {
|
| 106 |
"seed": seed,
|
| 107 |
"temperature": temp,
|
|
|
|
| 119 |
if escape_brackets:
|
| 120 |
input_prompt = re.sub(r"([()\[\]])", r"\\\1", input_prompt)
|
| 121 |
|
| 122 |
+
meta, operations, general, nl_prompt = tipo.parse_tipo_request(
|
| 123 |
seperate_tags(tags.split(",")),
|
| 124 |
nl_prompt,
|
| 125 |
tag_length_target=target_length,
|
| 126 |
generate_extra_nl_prompt="<|generated|>" in default_format or not nl_prompt,
|
| 127 |
)
|
| 128 |
t0 = time()
|
| 129 |
+
for result, timing in tipo.tipo_runner_generator(
|
| 130 |
meta, operations, general, nl_prompt, **generation_setting
|
| 131 |
):
|
| 132 |
result = apply_format(result, default_format)
|
|
|
|
| 183 |
with gr.Accordion("Introduction and Instructions", open=False):
|
| 184 |
gr.Markdown(
|
| 185 |
"""
|
| 186 |
+
## TIPO Demo
|
| 187 |
**The model for demo is 500M version with 4epoch training (25B token seen)**
|
| 188 |
|
| 189 |
### What is this
|
| 190 |
+
TIPO is a tool to extend, generate, refine the input prompt for T2I models.
|
| 191 |
<br>It can work on both Danbooru tags and Natural Language. Which means you can use it on almost all the existed T2I models.
|
| 192 |
<br>You can take it as "pro max" version of [DTG](https://huggingface.co/KBlueLeaf/DanTagGen-delta-rev2)
|
| 193 |
|
|
|
|
| 196 |
2. Enter your NL Prompt(optional): put the desired natural language prompt into "Natural Language Prompt" box
|
| 197 |
3. Enter your black list(optional): put the desired black list into "black list" box
|
| 198 |
4. Adjust the settings: length, temp, top_p, min_p, top_k, seed ...
|
| 199 |
+
4. Click "TIPO" button: you will see refined prompt on "result" box
|
| 200 |
5. If you like the result, click "Generate Image From Result" button
|
| 201 |
* You will see 2 generated images, left one is based on your prompt, right one is based on refined prompt
|
| 202 |
* The backend is diffusers, there are no weighting mechanism, so Escape Brackets is default to False
|
|
|
|
| 208 |
4. Once the project/research are done, I will open source all these models/codes with Apache2 license.
|
| 209 |
|
| 210 |
### Notification
|
| 211 |
+
**TIPO is NOT a T2I model. It is Prompt Gen, or, Text-to-Text model.
|
| 212 |
<br>The generated image is come from [Kohaku-XL-Zeta](https://huggingface.co/KBlueLeaf/Kohaku-XL-Zeta) model**
|
| 213 |
"""
|
| 214 |
)
|
|
|
|
| 285 |
escape_brackets = gr.Checkbox(
|
| 286 |
label="Escape Brackets", value=False
|
| 287 |
)
|
| 288 |
+
submit = gr.Button("TIPO!", variant="primary")
|
| 289 |
with gr.Accordion("Speed statstics", open=False):
|
| 290 |
cost_time = gr.Markdown()
|
| 291 |
with gr.Column(scale=5):
|