-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from deepghs/dev/portrait
dev(narugo): add portrait
- Loading branch information
Showing
36 changed files
with
3,702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ imgutils.validate | |
color | ||
monochrome | ||
nsfw | ||
portrait | ||
rating | ||
teen | ||
truncate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
)() |
Oops, something went wrong.