Spaces:
Runtime error
Runtime error
chore: add descriptions
Browse files
app.py
CHANGED
@@ -10,6 +10,14 @@ from threading import Thread
|
|
10 |
import gradio as gr
|
11 |
import time
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
MODEL_NAME = "isek-ai/SDPrompt-RetNet-v2-beta"
|
14 |
DEVICE = "cpu"
|
15 |
|
@@ -17,7 +25,7 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
|
17 |
model = AutoModelForCausalLM.from_pretrained(
|
18 |
MODEL_NAME,
|
19 |
torch_dtype=torch.bfloat16,
|
20 |
-
device_map=
|
21 |
trust_remote_code=True,
|
22 |
)
|
23 |
model.config.use_cache = True
|
@@ -107,6 +115,8 @@ COPY_ACTION_JS = """\
|
|
107 |
|
108 |
def demo():
|
109 |
with gr.Blocks() as ui:
|
|
|
|
|
110 |
with gr.Column():
|
111 |
input_text = gr.Textbox(label="Input", value="1girl")
|
112 |
|
@@ -133,9 +143,9 @@ def demo():
|
|
133 |
max_new_length_slider = gr.Slider(
|
134 |
label="Max new length",
|
135 |
minimum=4,
|
136 |
-
maximum=
|
137 |
step=4,
|
138 |
-
value=
|
139 |
)
|
140 |
do_sample_checkbox = gr.Checkbox(
|
141 |
label="Do sample",
|
@@ -177,6 +187,17 @@ def demo():
|
|
177 |
value=6,
|
178 |
)
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
btn.click(
|
181 |
fn=generate,
|
182 |
inputs=[
|
|
|
10 |
import gradio as gr
|
11 |
import time
|
12 |
|
13 |
+
MARKDOWN_DESCRIPTION = """\
|
14 |
+
# SDPrompt-RetNet-v2-beta
|
15 |
+
|
16 |
+
This is a demo of [SDPrompt-RetNet-v2-beta](https://huggingface.co/isek-ai/SDPrompt-RetNet-v2-beta), a pretrained RetNet model trained on [danbooru tags](isek-ai/danbooru-tags-2016-2023) dataset.
|
17 |
+
|
18 |
+
This model can only complete tags after the input text, so you have to start with a tag like `1girl` or `1boy, 1girl`. Also, this model generates tags in alphabetical order, you should place tags in alphabetical order in the input text.
|
19 |
+
"""
|
20 |
+
|
21 |
MODEL_NAME = "isek-ai/SDPrompt-RetNet-v2-beta"
|
22 |
DEVICE = "cpu"
|
23 |
|
|
|
25 |
model = AutoModelForCausalLM.from_pretrained(
|
26 |
MODEL_NAME,
|
27 |
torch_dtype=torch.bfloat16,
|
28 |
+
device_map=DEVICE,
|
29 |
trust_remote_code=True,
|
30 |
)
|
31 |
model.config.use_cache = True
|
|
|
115 |
|
116 |
def demo():
|
117 |
with gr.Blocks() as ui:
|
118 |
+
gr.Markdown(MARKDOWN_DESCRIPTION)
|
119 |
+
|
120 |
with gr.Column():
|
121 |
input_text = gr.Textbox(label="Input", value="1girl")
|
122 |
|
|
|
143 |
max_new_length_slider = gr.Slider(
|
144 |
label="Max new length",
|
145 |
minimum=4,
|
146 |
+
maximum=512,
|
147 |
step=4,
|
148 |
+
value=160,
|
149 |
)
|
150 |
do_sample_checkbox = gr.Checkbox(
|
151 |
label="Do sample",
|
|
|
187 |
value=6,
|
188 |
)
|
189 |
|
190 |
+
gr.Examples(
|
191 |
+
[
|
192 |
+
"1girl, blue hair",
|
193 |
+
"1girl, animal ears",
|
194 |
+
"1girl, detached sleeves",
|
195 |
+
"1boy, 1girl",
|
196 |
+
"1other",
|
197 |
+
],
|
198 |
+
inputs=[input_text],
|
199 |
+
)
|
200 |
+
|
201 |
btn.click(
|
202 |
fn=generate,
|
203 |
inputs=[
|