Skip to content

Commit

Permalink
Merge pull request #48 from deepghs/dev/portrait
Browse files Browse the repository at this point in the history
dev(narugo): add portrait
  • Loading branch information
narugo1992 authored Oct 13, 2023
2 parents 44f3a41 + 2968acc commit 76b5c32
Show file tree
Hide file tree
Showing 36 changed files with 3,702 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 @@ -14,6 +14,7 @@ imgutils.validate
color
monochrome
nsfw
portrait
rating
teen
truncate
14 changes: 14 additions & 0 deletions docs/source/api_doc/validate/portrait.plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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('portrait', 'person', '*.jpg'))),
*natsorted(glob.glob(os.path.join('portrait', 'halfbody', '*.jpg'))),
*natsorted(glob.glob(os.path.join('portrait', 'head', '*.jpg'))),
columns=3, figsize=(8, 9),
)
980 changes: 980 additions & 0 deletions docs/source/api_doc/validate/portrait.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/portrait.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
imgutils.validate.portrait
=============================================

.. currentmodule:: imgutils.validate.portrait

.. automodule:: imgutils.validate.portrait


anime_portrait_score
-----------------------------

.. autofunction:: anime_portrait_score



anime_portrait
-----------------------------

.. autofunction:: anime_portrait


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.
Binary file added docs/source/api_doc/validate/portrait/head/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/api_doc/validate/portrait/head/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/api_doc/validate/portrait/head/9.jpg
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/portrait_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_portrait

hf_fs = HfFileSystem()

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


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

def load(self):
from imgutils.validate.portrait import _open_anime_portrait_model
_ = _open_anime_portrait_model(self.model)

def unload(self):
from imgutils.validate.portrait import _open_anime_portrait_model
_open_anime_portrait_model.cache_clear()

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


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

0 comments on commit 76b5c32

Please sign in to comment.