Update README.md
Browse files
README.md
CHANGED
@@ -5,6 +5,7 @@ base_model: SmilingWolf/wd-swinv2-tagger-v3
|
|
5 |
inference: false
|
6 |
tags:
|
7 |
- wd-tagger
|
|
|
8 |
---
|
9 |
|
10 |
# WD SwinV2 Tagger v3 with 🤗 transformers
|
@@ -13,6 +14,14 @@ Converted from [SmilingWolf/wd-swinv2-tagger-v3](https://huggingface.co/SmilingW
|
|
13 |
|
14 |
## Example
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
### Pipeline
|
17 |
|
18 |
```py
|
@@ -30,18 +39,10 @@ print(pipe("sample.webp", top_k=15))
|
|
30 |
# {'label': 'dress', 'score': 0.9539461135864258},
|
31 |
# {'label': 'hat', 'score': 0.9511678218841553},
|
32 |
# {'label': 'outdoors', 'score': 0.9438753128051758},
|
33 |
-
#
|
34 |
-
# {'label': 'sitting', 'score': 0.9178725481033325},
|
35 |
-
# {'label': 'looking up', 'score': 0.9122412800788879},
|
36 |
-
# {'label': 'short hair', 'score': 0.8630313873291016},
|
37 |
-
# {'label': 'cloud', 'score': 0.8609118461608887},
|
38 |
-
# {'label': 'brown hair', 'score': 0.7723952531814575},
|
39 |
-
# {'label': 'short sleeves', 'score': 0.7649227380752563},
|
40 |
-
# {'label': 'day', 'score': 0.7641971111297607},
|
41 |
-
# {'label': 'rating:general', 'score': 0.7605368494987488},
|
42 |
-
# {'label': 'white dress', 'score': 0.7596388459205627}]
|
43 |
```
|
44 |
|
|
|
45 |
### AutoModel
|
46 |
|
47 |
|
@@ -81,22 +82,40 @@ print(results) # rating tags and character tags are also included
|
|
81 |
# 'dress': tensor(0.9539),
|
82 |
# 'hat': tensor(0.9512),
|
83 |
# 'outdoors': tensor(0.9439),
|
84 |
-
# 'sky': tensor(0.9196),
|
85 |
-
# 'sitting': tensor(0.9179),
|
86 |
-
# 'looking up': tensor(0.9122),
|
87 |
-
# 'short hair': tensor(0.8630),
|
88 |
-
# 'cloud': tensor(0.8609),
|
89 |
-
# 'brown hair': tensor(0.7724),
|
90 |
-
# 'short sleeves': tensor(0.7649),
|
91 |
-
# 'day': tensor(0.7642),
|
92 |
-
# 'rating:general': tensor(0.7605),
|
93 |
# ...
|
94 |
```
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
## Labels
|
97 |
|
98 |
All of rating tags have prefix `rating:` and character tags have prefix `character:`.
|
99 |
|
100 |
- Rating tags: `rating:general`, `rating:sensitive`, ...
|
101 |
-
- Character tags: `character:frieren`, `character:hatsune miku`, ...
|
102 |
-
|
|
|
5 |
inference: false
|
6 |
tags:
|
7 |
- wd-tagger
|
8 |
+
- optimum
|
9 |
---
|
10 |
|
11 |
# WD SwinV2 Tagger v3 with 🤗 transformers
|
|
|
14 |
|
15 |
## Example
|
16 |
|
17 |
+
[](https://colab.research.google.com/gist/p1atdev/d420d9fcd5c8ea66d9e10918fc330741/wd-swinv2-tagger-v3-hf-pipe.ipynb)
|
18 |
+
|
19 |
+
### Installation
|
20 |
+
|
21 |
+
```bash
|
22 |
+
pip install optimum[onnxruntime] transformers
|
23 |
+
```
|
24 |
+
|
25 |
### Pipeline
|
26 |
|
27 |
```py
|
|
|
39 |
# {'label': 'dress', 'score': 0.9539461135864258},
|
40 |
# {'label': 'hat', 'score': 0.9511678218841553},
|
41 |
# {'label': 'outdoors', 'score': 0.9438753128051758},
|
42 |
+
# ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
```
|
44 |
|
45 |
+
|
46 |
### AutoModel
|
47 |
|
48 |
|
|
|
82 |
# 'dress': tensor(0.9539),
|
83 |
# 'hat': tensor(0.9512),
|
84 |
# 'outdoors': tensor(0.9439),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
# ...
|
86 |
```
|
87 |
|
88 |
+
### Accelerate with 🤗 Optimum
|
89 |
+
|
90 |
+
Maybe about 30% faster and about 50% light weight model size than transformers version.
|
91 |
+
|
92 |
+
```bash
|
93 |
+
pip install optimum[onnxruntime]
|
94 |
+
```
|
95 |
+
|
96 |
+
```diff
|
97 |
+
-from transformers import pipeline
|
98 |
+
+from optimum.pipelines import pipeline
|
99 |
+
|
100 |
+
pipe = pipeline(
|
101 |
+
"image-classification",
|
102 |
+
model="p1atdev/wd-swinv2-tagger-v3-hf",
|
103 |
+
trust_remote_code=True,
|
104 |
+
)
|
105 |
+
|
106 |
+
print(pipe("sample.webp", top_k=15))
|
107 |
+
#[{'label': '1girl', 'score': 0.9973934888839722},
|
108 |
+
# {'label': 'solo', 'score': 0.9719744324684143},
|
109 |
+
# {'label': 'dress', 'score': 0.9539461135864258},
|
110 |
+
# {'label': 'hat', 'score': 0.9511678218841553},
|
111 |
+
# {'label': 'outdoors', 'score': 0.9438753128051758},
|
112 |
+
# ...
|
113 |
+
```
|
114 |
+
|
115 |
+
|
116 |
## Labels
|
117 |
|
118 |
All of rating tags have prefix `rating:` and character tags have prefix `character:`.
|
119 |
|
120 |
- Rating tags: `rating:general`, `rating:sensitive`, ...
|
121 |
+
- Character tags: `character:frieren`, `character:hatsune miku`, ...
|
|