Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(narugo): add de-normalizers for the embeddings of the wd14 taggers #126

Merged
merged 3 commits into from
Nov 17, 2024

Conversation

narugo1992
Copy link
Contributor

import numpy as np

from imgutils.tagging import get_wd14_tags, convert_wd14_emb_to_prediction, denormalize_wd14_emb
from test.testings import get_testfile

embedding, (r, g, c) = get_wd14_tags(
    get_testfile('nian.png'),
    fmt=('embedding', ('rating', 'general', 'character')),
)

# normalize embedding
embedding = embedding / np.linalg.norm(embedding)

# 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)

@narugo1992 narugo1992 added the enhancement New feature or request label Nov 17, 2024
@narugo1992 narugo1992 self-assigned this Nov 17, 2024
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.89%. Comparing base (510b6cc) to head (256758a).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   96.87%   96.89%   +0.01%     
==========================================
  Files         106      106              
  Lines        3456     3476      +20     
==========================================
+ Hits         3348     3368      +20     
  Misses        108      108              
Flag Coverage Δ
unittests 96.89% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@narugo1992 narugo1992 merged commit d43dcae into main Nov 17, 2024
20 checks passed
@narugo1992 narugo1992 deleted the dev/denormalize branch March 7, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant