| 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 | |
| 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) | |