CoolFace
Modelpublic

Library-Mutsumi/wd14_tagger_embedding_denormalize

sourceHugging Faceopenrailupdated 4mo agoView on Hugging Face
0likes
Model Card

Models of experiment: https://github.com/deepghs/taggerembeddingaligner

python
import numpy as np

from imgutils.tagging import get_wd14_tags, convert_wd14_emb_to_prediction, denormalize_wd14_emb

embedding, (r, g, c) = get_wd14_tags(
    '/my/image.png',
    fmt=('embedding', ('rating', 'general', 'character')),
)
# normal tag results
print('Expected result:')
print(r)
print(g)
print(c)

# normalize embedding
embedding = embedding / np.linalg.norm(embedding)
# bad tag results
br, bg, bc = convert_wd14_emb_to_prediction(embedding)
print('Bad results due to the embedding normalization:')
print(br)
print(bg)
print(bc)

# denormalize this embedding
output = denormalize_wd14_emb(embedding)
print(output.shape)

# should be similar to r, g, c, approx 1e-3 error
rating, general, character = convert_wd14_emb_to_prediction(output)
print('De-normalized result:')
print(rating)
print(general)
print(character)
NameTaggerEmbedding WidthTags CountFLOPSParamsEMB CosineEMB NormPred LossPred MSE
ViTv3mnum2_allViT_v3768108610.000398G0.40M10.17120.0043062.116e-08
ViTv3mnum1_allViT_v3768108610.000709G0.71M10.22460.0043063.991e-08
ConvNextv3mnum2_allConvNext_v31024108610.000708G0.71M10.11260.0045312.061e-08
ConvNextv3mnum1_allConvNext_v31024108610.001260G1.26M10.14730.0045313.539e-08
ViTmnum2allViT76890830.000398G0.40M10.086410.0051993.797e-09
ViTmnum1allViT76890830.000709G0.71M10.17240.0051991.896e-08
ConvNextmnum2allConvNext102490830.000708G0.71M10.057760.0052137.207e-09
ConvNextmnum1allConvNext102490830.001260G1.26M10.071340.0052141.292e-08
ViTLargemnum2_allViT_Large1024108610.000708G0.71M11.4030.0039661.617e-07
ViTLargemnum1_allViT_Large1024108610.001260G1.26M11.6430.0039662.24e-07
SwinV2mnum2allSwinV2102490830.000708G0.71M10.12570.0047263.797e-08
SwinV2mnum1allSwinV2102490830.001260G1.26M10.14970.0047275.487e-08
EVA02Largemnum2_allEVA02_Large1024108610.000708G0.71M11.2680.0059485.466e-08
EVA02Largemnum1_allEVA02_Large1024108610.001260G1.26M11.7130.0059489.518e-08
ConvNextV2mnum2allConvNextV2102490830.000708G0.71M10.090140.0045961.43e-08
ConvNextV2mnum1allConvNextV2102490830.001260G1.26M10.12160.0045962.76e-08
SwinV2v3mnum2_allSwinV2_v31024108610.000708G0.71M10.21290.0041284.035e-08
SwinV2v3mnum1_allSwinV2_v31024108610.001260G1.26M10.27840.0041296.893e-08
MOATmnum2allMOAT102490830.000708G0.71M10.46620.0049981.855e-08
MOATmnum1allMOAT102490830.001260G1.26M10.78490.0049985.549e-08