Upload 6 files
Browse files- README.md +2 -1
- app.py +20 -5
- gitignore +1 -0
- power.jpg +0 -0
- requirements.txt +1 -1
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: WaifuDiffusion
|
3 |
emoji: π¬
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
@@ -7,6 +7,7 @@ sdk: gradio
|
|
7 |
sdk_version: 4.20.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
# Configuration
|
|
|
1 |
---
|
2 |
+
title: WaifuDiffusion v1.4 Tags
|
3 |
emoji: π¬
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
|
|
7 |
sdk_version: 4.20.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
duplicated_from: SmilingWolf/wd-v1-4-tags
|
11 |
---
|
12 |
|
13 |
# Configuration
|
app.py
CHANGED
@@ -8,8 +8,15 @@ import onnxruntime as rt
|
|
8 |
import pandas as pd
|
9 |
from PIL import Image
|
10 |
|
|
|
|
|
11 |
TITLE = "WaifuDiffusion Tagger"
|
|
|
12 |
DESCRIPTION = """
|
|
|
|
|
|
|
|
|
13 |
Demo for the WaifuDiffusion tagger models
|
14 |
|
15 |
Example image by [γ»γβββ](https://www.pixiv.net/en/users/43565085)
|
@@ -68,9 +75,9 @@ def parse_args() -> argparse.Namespace:
|
|
68 |
|
69 |
def load_labels(dataframe) -> list[str]:
|
70 |
name_series = dataframe["name"]
|
71 |
-
name_series = name_series.map(
|
72 |
-
|
73 |
-
)
|
74 |
tag_names = name_series.tolist()
|
75 |
|
76 |
rating_indexes = list(np.where(dataframe["category"] == 9)[0])
|
@@ -213,11 +220,17 @@ class Predictor:
|
|
213 |
reverse=True,
|
214 |
)
|
215 |
sorted_general_strings = [x[0] for x in sorted_general_strings]
|
|
|
|
|
|
|
216 |
sorted_general_strings = (
|
217 |
", ".join(sorted_general_strings).replace("(", "\(").replace(")", "\)")
|
218 |
)
|
|
|
|
|
|
|
219 |
|
220 |
-
return sorted_general_strings, rating, character_res, general_res
|
221 |
|
222 |
|
223 |
def main():
|
@@ -294,12 +307,14 @@ def main():
|
|
294 |
submit = gr.Button(value="Submit", variant="primary", size="lg")
|
295 |
with gr.Column(variant="panel"):
|
296 |
sorted_general_strings = gr.Textbox(label="Output (string)")
|
|
|
297 |
rating = gr.Label(label="Rating")
|
298 |
character_res = gr.Label(label="Output (characters)")
|
299 |
general_res = gr.Label(label="Output (tags)")
|
300 |
clear.add(
|
301 |
[
|
302 |
sorted_general_strings,
|
|
|
303 |
rating,
|
304 |
character_res,
|
305 |
general_res,
|
@@ -316,7 +331,7 @@ def main():
|
|
316 |
character_thresh,
|
317 |
character_mcut_enabled,
|
318 |
],
|
319 |
-
outputs=[sorted_general_strings, rating, character_res, general_res],
|
320 |
)
|
321 |
|
322 |
gr.Examples(
|
|
|
8 |
import pandas as pd
|
9 |
from PIL import Image
|
10 |
|
11 |
+
|
12 |
+
|
13 |
TITLE = "WaifuDiffusion Tagger"
|
14 |
+
|
15 |
DESCRIPTION = """
|
16 |
+
This is an edited version of SmilingWolf's wd-1.4 taggs, which I have modified so that you don't have to remove the commas when you label an image for a booru website
|
17 |
+
|
18 |
+
https://huggingface.co/spaces/SmilingWolf/wd-v1-4-tags
|
19 |
+
|
20 |
Demo for the WaifuDiffusion tagger models
|
21 |
|
22 |
Example image by [γ»γβββ](https://www.pixiv.net/en/users/43565085)
|
|
|
75 |
|
76 |
def load_labels(dataframe) -> list[str]:
|
77 |
name_series = dataframe["name"]
|
78 |
+
# name_series = name_series.map(
|
79 |
+
# lambda x: x.replace("_", " ") if x not in kaomojis else x
|
80 |
+
# )
|
81 |
tag_names = name_series.tolist()
|
82 |
|
83 |
rating_indexes = list(np.where(dataframe["category"] == 9)[0])
|
|
|
220 |
reverse=True,
|
221 |
)
|
222 |
sorted_general_strings = [x[0] for x in sorted_general_strings]
|
223 |
+
sorted_booru_strings = (
|
224 |
+
" ".join(sorted_general_strings)
|
225 |
+
)
|
226 |
sorted_general_strings = (
|
227 |
", ".join(sorted_general_strings).replace("(", "\(").replace(")", "\)")
|
228 |
)
|
229 |
+
# sorted_general_strings = sorted_general_strings.map(
|
230 |
+
# lambda x: x.replace("_", " ") if x not in kaomojis else x
|
231 |
+
# )
|
232 |
|
233 |
+
return sorted_general_strings, sorted_booru_strings, rating, character_res, general_res
|
234 |
|
235 |
|
236 |
def main():
|
|
|
307 |
submit = gr.Button(value="Submit", variant="primary", size="lg")
|
308 |
with gr.Column(variant="panel"):
|
309 |
sorted_general_strings = gr.Textbox(label="Output (string)")
|
310 |
+
sorted_booru_strings = gr.Textbox(label="Output (Booru)")
|
311 |
rating = gr.Label(label="Rating")
|
312 |
character_res = gr.Label(label="Output (characters)")
|
313 |
general_res = gr.Label(label="Output (tags)")
|
314 |
clear.add(
|
315 |
[
|
316 |
sorted_general_strings,
|
317 |
+
sorted_booru_strings,
|
318 |
rating,
|
319 |
character_res,
|
320 |
general_res,
|
|
|
331 |
character_thresh,
|
332 |
character_mcut_enabled,
|
333 |
],
|
334 |
+
outputs=[sorted_general_strings,sorted_booru_strings, rating, character_res, general_res],
|
335 |
)
|
336 |
|
337 |
gr.Examples(
|
gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
images
|
power.jpg
CHANGED
![]() |
![]() |
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
pillow>=9.0.0
|
2 |
onnxruntime>=1.12.0
|
3 |
-
huggingface-hub
|
|
|
1 |
pillow>=9.0.0
|
2 |
onnxruntime>=1.12.0
|
3 |
+
huggingface-hub
|