File size: 638 Bytes
19b3da3 1bc457e 19b3da3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from internals.util.config import get_nsfw_access
class Result:
images, nsfw = None, None
def __init__(self, images, nsfw):
self.images = images
self.nsfw = nsfw
@staticmethod
def from_result(result):
if hasattr(result, "nsfw_content_detected"):
has_nsfw = result.nsfw_content_detected
else:
has_nsfw = False
if has_nsfw and isinstance(has_nsfw, list):
has_nsfw = any(has_nsfw)
has_nsfw = ~get_nsfw_access() and has_nsfw
return (result.images, bool(has_nsfw))
# return Result(result.images, result.has_nsfw_concepts)
|