Spaces:
Running
on
Zero
Running
on
Zero
Gainward777
commited on
Upload 5 files
Browse files
sd/prompt_helper/helper.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import onnx
|
2 |
+
import onnxruntime as ort
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
VIT_MODEL_DSV3_REPO = "SmilingWolf/wd-vit-tagger-v3"
|
6 |
+
|
7 |
+
|
8 |
+
def preprocess_image(img):
|
9 |
+
bgr_img = np.array(img)[:, :, ::-1].copy()
|
10 |
+
size = max(bgr_img.shape[0:2])
|
11 |
+
pad_x = size - bgr_img.shape[1]
|
12 |
+
pad_y = size - bgr_img.shape[0]
|
13 |
+
pad_l = pad_x // 2
|
14 |
+
pad_t = pad_y // 2
|
15 |
+
|
16 |
+
#add paddings to squaring image
|
17 |
+
np.pad(bgr_img, ((pad_t, pad_y - pad_t), (pad_l, pad_x - pad_l), (0, 0)), mode="constant", constant_values=255)
|
18 |
+
|
19 |
+
#adaptive resize
|
20 |
+
interp = cv2.INTER_AREA if size > IMAGE_SIZE else cv2.INTER_LANCZOS4
|
21 |
+
bgr_img = cv2.resize(bgr_img, (IMAGE_SIZE, IMAGE_SIZE), interpolation=interp)
|
22 |
+
|
23 |
+
bgr_img = bgr_img.astype(np.float32)
|
sd/prompt_helper/model/config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architecture": "vit_base_patch16_224",
|
3 |
+
"num_classes": 10861,
|
4 |
+
"num_features": 768,
|
5 |
+
"global_pool": "avg",
|
6 |
+
"model_args": {
|
7 |
+
"img_size": 448,
|
8 |
+
"class_token": false,
|
9 |
+
"global_pool": "avg",
|
10 |
+
"fc_norm": false,
|
11 |
+
"act_layer": "gelu_tanh"
|
12 |
+
},
|
13 |
+
"pretrained_cfg": {
|
14 |
+
"custom_load": false,
|
15 |
+
"input_size": [
|
16 |
+
3,
|
17 |
+
448,
|
18 |
+
448
|
19 |
+
],
|
20 |
+
"fixed_input_size": false,
|
21 |
+
"interpolation": "bicubic",
|
22 |
+
"crop_pct": 1.0,
|
23 |
+
"crop_mode": "center",
|
24 |
+
"mean": [
|
25 |
+
0.5,
|
26 |
+
0.5,
|
27 |
+
0.5
|
28 |
+
],
|
29 |
+
"std": [
|
30 |
+
0.5,
|
31 |
+
0.5,
|
32 |
+
0.5
|
33 |
+
],
|
34 |
+
"num_classes": 10861,
|
35 |
+
"pool_size": null,
|
36 |
+
"first_conv": null,
|
37 |
+
"classifier": null
|
38 |
+
}
|
39 |
+
}
|
sd/prompt_helper/model/model.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:35f23693620b668f4d53fd3c62bf65e40af739bc52c7eb0fbc49258b58d065b6
|
3 |
+
size 378536310
|
sd/prompt_helper/model/selected_tags.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
sd/prompt_helper/model/sw_jax_cv_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"image_size": 448,
|
3 |
+
"model_name": "vit_base",
|
4 |
+
"model_args": {
|
5 |
+
"patch_size": 16,
|
6 |
+
"num_classes": 10861,
|
7 |
+
"num_layers": 12,
|
8 |
+
"embed_dim": 768,
|
9 |
+
"mlp_dim": 3072,
|
10 |
+
"num_heads": 12,
|
11 |
+
"drop_path_rate": 0.1,
|
12 |
+
"layer_norm_eps": 1e-05
|
13 |
+
}
|
14 |
+
}
|