Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fafc9e1
dev(narugo): add pixai tagger x, ci skip
narugo1992 Sep 8, 2025
96ba7f9
dev(narugo): add more
narugo1992 Sep 8, 2025
77db215
dev(narugo): fix convertion bug, ci skip
narugo1992 Sep 8, 2025
02fb5b1
dev(narugo): fix convertion bug, ci skip
narugo1992 Sep 8, 2025
9fe4c39
dev(narugo): add a rough README
narugo1992 Sep 8, 2025
0ff18dd
dev(narugo): add a rough README, ci skip
narugo1992 Sep 8, 2025
4e4e0ab
dev(narugo): add a rough README, ci skip
narugo1992 Sep 8, 2025
ff0f6dc
dev(narugo): add more profiles, ci skip
narugo1992 Sep 8, 2025
22eb21d
dev(narugo): add more profiles, ci skip
narugo1992 Sep 8, 2025
82cf110
dev(narugo): add more profiles, ci skip
narugo1992 Sep 8, 2025
18a9bad
dev(narugo): add more profiles, ci skip
narugo1992 Sep 8, 2025
150b42f
dev(narugo): add some more meta information
narugo1992 Sep 9, 2025
9f266c9
dev(narugo): add some more meta information, ci skip
narugo1992 Sep 9, 2025
93bce42
dev(narugo): add some more meta information, ci skip
narugo1992 Sep 9, 2025
6c85e62
dev(narugo): try add inference code, ci skip
narugo1992 Sep 9, 2025
313a653
dev(narugo): fix known bugs
narugo1992 Sep 9, 2025
db8a1ba
dev(narugo): add pixai docs
narugo1992 Sep 9, 2025
c9ef105
dev(narugo): add pixai docs, ci skip, fix some bugs
narugo1992 Sep 9, 2025
561af44
dev(narugo): adjust some values detail
narugo1992 Sep 9, 2025
47fc385
dev(narugo): fix the docs
narugo1992 Sep 9, 2025
744b7a7
dev(narugo): add unittest for it
narugo1992 Sep 9, 2025
e7d67cd
dev(narugo): add benchmark
narugo1992 Sep 9, 2025
e1ff174
dev(narugo): add cache deletion on CI environment
narugo1992 Sep 9, 2025
e7b8cd1
dev(narugo): try fix unittest
narugo1992 Sep 9, 2025
138ada2
dev(narugo): try fix unittest, ci skip
narugo1992 Sep 9, 2025
16f0cd9
dev(narugo): try fix unittest, ci skip
narugo1992 Sep 9, 2025
4b895d6
dev(narugo): try fix unittest, ci skip
narugo1992 Sep 9, 2025
41c1a09
dev(narugo): try ignore those 2 unittests
narugo1992 Sep 9, 2025
57b797a
dev(narugo): auto sync Tue, 09 Sep 2025 10:30:51 +0000
narugo1992 Sep 9, 2025
fff6871
dev(narugo): try fix this unittest
narugo1992 Sep 9, 2025
760ddce
dev(narugo): add actual usage docs
narugo1992 Sep 9, 2025
e9af386
dev(narugo): add one more line for export function
narugo1992 Sep 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
ENV_PROD: 'true'
PLANTUML_HOST: http://localhost:18080
HF_TOKEN: ${{ secrets.HF_TOKEN }}
CI: 'true'
run: |
plantumlcli -c
make docs
Expand Down Expand Up @@ -145,6 +146,7 @@ jobs:
ENV_PROD: 'true'
PLANTUML_HOST: http://localhost:18080
HF_TOKEN: ${{ secrets.HF_TOKEN }}
CI: 'true'
run: |
git fetch --all --tags
git branch -av
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ unittest:
--cov="${RANGE_SRC_DIR}" \
$(if ${MIN_COVERAGE},--cov-fail-under=${MIN_COVERAGE},) \
$(if ${WORKERS},-n ${WORKERS},) \
--reruns 8 --reruns-delay 2 --only-rerun '(OSError|Timeout|HTTPError.*429|HTTPError.*502|HTTPError.*504|check your connection|429 error)'
--reruns 8 --reruns-delay 2 --only-rerun '(OSError|Timeout|HTTPError.*429|HTTPError.*502|HTTPError.*504|check your connection|429 error|CAS service error)'

docs:
$(MAKE) -C "${DOC_DIR}" build
Expand Down
4 changes: 4 additions & 0 deletions docs/source/_libs/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def load(self):
def unload(self):
raise NotImplementedError

def after_unload(self):
pass

def run(self):
raise NotImplementedError

Expand All @@ -60,6 +63,7 @@ def _record(name):

self.unload()
_record('<unload>')
self.after_unload()

mems = np.array([mem for _, mem, _ in logs])
mems -= mems[0]
Expand Down
1 change: 1 addition & 0 deletions docs/source/api_doc/tagging/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ imgutils.tagging
mldanbooru
wd14
camie
pixai
deepdanbooru
deepgelbooru
format
Expand Down
15 changes: 15 additions & 0 deletions docs/source/api_doc/tagging/pixai.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
imgutils.tagging.pixai
====================================

.. currentmodule:: imgutils.tagging.pixai

.. automodule:: imgutils.tagging.pixai


get_pixai_tags
----------------------

.. autofunction:: get_pixai_tags



66 changes: 54 additions & 12 deletions docs/source/api_doc/tagging/tagging_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import os
import random

from hfutils.cache import delete_cache

from benchmark import BaseBenchmark, create_plot_cli
from imgutils.tagging import get_deepdanbooru_tags, get_wd14_tags, get_mldanbooru_tags, get_deepgelbooru_tags, \
get_camie_tags
get_camie_tags, get_pixai_tags


class CleanModelStorageBenchmark(BaseBenchmark):
def after_unload(self):
if os.environ.get('CI'):
delete_cache()

class DeepdanbooruBenchmark(BaseBenchmark):

class DeepdanbooruBenchmark(CleanModelStorageBenchmark):
def load(self):
from imgutils.tagging.deepdanbooru import _get_deepdanbooru_model
from imgutils.tagging.deepdanbooru import _get_deepdanbooru_model, _get_deepdanbooru_labels
_ = _get_deepdanbooru_model()
_ = _get_deepdanbooru_labels

def unload(self):
from imgutils.tagging.deepdanbooru import _get_deepdanbooru_model
from imgutils.tagging.deepdanbooru import _get_deepdanbooru_model, _get_deepdanbooru_labels
_get_deepdanbooru_model.cache_clear()
_get_deepdanbooru_labels.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = get_deepdanbooru_tags(image_file)


class DeepgelbooruBenchmark(BaseBenchmark):
class DeepgelbooruBenchmark(CleanModelStorageBenchmark):
def load(self):
from imgutils.tagging.deepgelbooru import _open_tags, _open_model, _open_preprocessor
_ = _open_tags()
Expand All @@ -37,39 +48,43 @@ def run(self):
_ = get_deepgelbooru_tags(image_file)


class Wd14Benchmark(BaseBenchmark):
class Wd14Benchmark(CleanModelStorageBenchmark):
def __init__(self, model):
BaseBenchmark.__init__(self)
self.model = model

def load(self):
from imgutils.tagging.wd14 import _get_wd14_model
from imgutils.tagging.wd14 import _get_wd14_model, _get_wd14_labels
_ = _get_wd14_model(self.model)
_ = _get_wd14_labels(self.model)

def unload(self):
from imgutils.tagging.wd14 import _get_wd14_model
from imgutils.tagging.wd14 import _get_wd14_model, _get_wd14_labels
_get_wd14_model.cache_clear()
_get_wd14_labels.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = get_wd14_tags(image_file, model_name=self.model)


class MLDanbooruBenchmark(BaseBenchmark):
class MLDanbooruBenchmark(CleanModelStorageBenchmark):
def load(self):
from imgutils.tagging.mldanbooru import _open_mldanbooru_model
from imgutils.tagging.mldanbooru import _open_mldanbooru_model, _get_mldanbooru_labels
_ = _open_mldanbooru_model()
_ = _get_mldanbooru_labels()

def unload(self):
from imgutils.tagging.mldanbooru import _open_mldanbooru_model
from imgutils.tagging.mldanbooru import _open_mldanbooru_model, _get_mldanbooru_labels
_open_mldanbooru_model.cache_clear()
_get_mldanbooru_labels.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = get_mldanbooru_tags(image_file)


class CamieBenchmark(BaseBenchmark):
class CamieBenchmark(CleanModelStorageBenchmark):
def __init__(self, model_name):
BaseBenchmark.__init__(self)
self.model_name = model_name
Expand All @@ -95,6 +110,32 @@ def run(self):
_ = get_camie_tags(image_file, model_name=self.model_name)


class PixAITaggerBenchmark(CleanModelStorageBenchmark):
def __init__(self, model_name: str):
BaseBenchmark.__init__(self)
self.model_name = model_name

def load(self):
from imgutils.tagging.pixai import _open_tags, _open_preprocess, _open_onnx_model, \
_open_default_category_thresholds
_ = _open_tags(self.model_name)
_ = _open_preprocess(self.model_name)
_ = _open_onnx_model(self.model_name)
_ = _open_default_category_thresholds(self.model_name)

def unload(self):
from imgutils.tagging.pixai import _open_tags, _open_preprocess, _open_onnx_model, \
_open_default_category_thresholds
_open_tags.cache_clear()
_open_preprocess.cache_clear()
_open_onnx_model.cache_clear()
_open_default_category_thresholds.cache_clear()

def run(self):
image_file = random.choice(self.all_images)
_ = get_pixai_tags(image_file, model_name=self.model_name)


if __name__ == '__main__':
create_plot_cli(
[
Expand All @@ -113,6 +154,7 @@ def run(self):
('mldanbooru', MLDanbooruBenchmark()),
('camie-initial', CamieBenchmark('initial')),
('camie-refined', CamieBenchmark('refined')),
('pixai-tagger-v0.9', PixAITaggerBenchmark('v0.9')),
],
title='Benchmark for Tagging Models',
run_times=10,
Expand Down
Loading
Loading