-
Notifications
You must be signed in to change notification settings - Fork 14
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 #31 from deepghs/dev/nsfw
dev(narugo): add nsfw prediction from nsfwjs library in javascript
- Loading branch information
Showing
69 changed files
with
4,206 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 |
---|---|---|
|
@@ -13,5 +13,6 @@ imgutils.validate | |
classify | ||
color | ||
monochrome | ||
nsfw | ||
rating | ||
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,16 @@ | ||
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('nsfw', 'drawings', '*.jpg'))), | ||
*natsorted(glob.glob(os.path.join('nsfw', 'hentai', '*.jpg'))), | ||
*natsorted(glob.glob(os.path.join('nsfw', 'neutral', '*.jpg'))), | ||
*natsorted(glob.glob(os.path.join('nsfw', 'porn', '*.jpg'))), | ||
*natsorted(glob.glob(os.path.join('nsfw', 'sexy', '*.jpg'))), | ||
columns=4, figsize=(10, 18.5), | ||
) |
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,22 @@ | ||
imgutils.validate.nsfw | ||
============================================= | ||
|
||
.. currentmodule:: imgutils.validate.nsfw | ||
|
||
.. automodule:: imgutils.validate.nsfw | ||
|
||
|
||
nsfw_pred_score | ||
---------------------------------------- | ||
|
||
.. autofunction:: nsfw_pred_score | ||
|
||
|
||
|
||
nsfw_pred | ||
---------------------------------------- | ||
|
||
.. autofunction:: nsfw_pred | ||
|
||
|
||
|
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.
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,35 @@ | ||
import random | ||
|
||
from benchmark import BaseBenchmark, create_plot_cli | ||
from imgutils.validate import nsfw_pred_score | ||
from imgutils.validate.nsfw import _MODEL_NAMES | ||
|
||
|
||
class AnimeNSFWBenchmark(BaseBenchmark): | ||
def __init__(self, model): | ||
BaseBenchmark.__init__(self) | ||
self.model = model | ||
|
||
def load(self): | ||
from imgutils.validate.nsfw import _open_nsfw_model | ||
_ = _open_nsfw_model(self.model) | ||
|
||
def unload(self): | ||
from imgutils.validate.nsfw import _open_nsfw_model | ||
_open_nsfw_model.cache_clear() | ||
|
||
def run(self): | ||
image_file = random.choice(self.all_images) | ||
_ = nsfw_pred_score(image_file, self.model) | ||
|
||
|
||
if __name__ == '__main__': | ||
create_plot_cli( | ||
[ | ||
(name, AnimeNSFWBenchmark(name)) | ||
for name in _MODEL_NAMES | ||
], | ||
title='Benchmark for NSFW Models', | ||
run_times=10, | ||
try_times=20, | ||
)() |
Oops, something went wrong.