Skip to content

Commit

Permalink
Merge pull request #57 from deepghs/dev/ages
Browse files Browse the repository at this point in the history
dev(narugo): init version for anime style ages
  • Loading branch information
narugo1992 authored Dec 16, 2023
2 parents c595725 + 7210bb2 commit 4f95410
Show file tree
Hide file tree
Showing 65 changed files with 4,110 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/api_doc/validate/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ imgutils.validate
nsfw
portrait
rating
style_age
teen
truncate
18 changes: 18 additions & 0 deletions docs/source/api_doc/validate/style_age.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import glob
import os.path

from natsort import natsorted

from plot import image_plot

if __name__ == '__main__':
image_plot(
*natsorted(glob.glob(os.path.join('style_age', '1970s-', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '1980s', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '1990s', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '2000s', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '2010s', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '2015s', '*.jpg'))),
*natsorted(glob.glob(os.path.join('style_age', '2020s', '*.jpg'))),
columns=4, figsize=(10, 26),
)
1,535 changes: 1,535 additions & 0 deletions docs/source/api_doc/validate/style_age.plot.py.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/source/api_doc/validate/style_age.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
imgutils.validate.style_age
=============================================

.. currentmodule:: imgutils.validate.style_age

.. automodule:: imgutils.validate.style_age


anime_style_age_score
-----------------------------

.. autofunction:: anime_style_age_score



anime_style_age
-----------------------------

.. autofunction:: anime_style_age


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions docs/source/api_doc/validate/style_age_benchmark.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import random

from huggingface_hub import HfFileSystem

from benchmark import BaseBenchmark, create_plot_cli
from imgutils.validate import anime_style_age

hf_fs = HfFileSystem()

_REPOSITORY = 'deepghs/anime_style_ages'
_MODEL_NAMES = [
os.path.relpath(file, _REPOSITORY).split('/')[0] for file in
hf_fs.glob(f'{_REPOSITORY}/*/model.onnx')
]


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

def load(self):
from imgutils.validate.style_age import _open_anime_style_age_model
_ = _open_anime_style_age_model(self.model)

def unload(self):
from imgutils.validate.style_age import _open_anime_style_age_model
_open_anime_style_age_model.cache_clear()

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


if __name__ == '__main__':
create_plot_cli(
[
(name, AnimeStyleAgeBenchmark(name))
for name in _MODEL_NAMES
],
title='Benchmark for Anime Style Age Models',
run_times=10,
try_times=20,
)()
Loading

0 comments on commit 4f95410

Please sign in to comment.