Spaces:
Running
Running
Commit
·
ef3544a
1
Parent(s):
e6a87cd
initial commit
Browse files- app.py +32 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from text2tags import TaggerLlama
|
3 |
+
|
4 |
+
model = TaggerLlama()
|
5 |
+
|
6 |
+
|
7 |
+
def predict(caption, max_tokens, temperature, top_k, top_p, repeat_penalty):
|
8 |
+
tags = model.predict_tags(caption, max_tokens=max_tokens, temperature=temperature,
|
9 |
+
top_k=top_k, top_p=top_p, repeat_penalty=repeat_penalty)
|
10 |
+
return ', '.join(tags)
|
11 |
+
|
12 |
+
|
13 |
+
demo = gr.Interface(
|
14 |
+
fn=predict,
|
15 |
+
inputs=[
|
16 |
+
gr.Textbox(label="Caption"),
|
17 |
+
gr.Slider(0, 256, step=16, value=128, label='max_tokens'),
|
18 |
+
gr.Slider(0, 2, step=0.1, value=0.8, label='temperature'),
|
19 |
+
gr.Slider(0, 100, step=5, value=40, label='top_k'),
|
20 |
+
gr.Slider(0, 2, step=0.05, value=0.95, label='top_p'),
|
21 |
+
gr.Slider(0, 5, step=0.1, value=1.1, label='repeat_penalty'),
|
22 |
+
],
|
23 |
+
outputs="text",
|
24 |
+
title="Text2Tags",
|
25 |
+
description="### Enter a caption to extract danbooru tags from it.",
|
26 |
+
examples=[
|
27 |
+
["Minato Aqua from hololive with pink and blue twintails in a blue maid outfit"],
|
28 |
+
],
|
29 |
+
allow_flagging="never"
|
30 |
+
)
|
31 |
+
|
32 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tetext2tags-ooferdoodles
|