fixed code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from app.ml.image.clip_classifier import ClipClassifier
|
||||
from app.ml.image.image_classifier import ImageClassifier
|
||||
from app.ml.text_classifier import TextClassifier
|
||||
from app.moderation.image.validator import ImageValidator
|
||||
@@ -8,20 +9,12 @@ from app.moderation.profanity.dictionary import ProfanityDictionary
|
||||
from app.moderation.profanity.lemmatizer import Lemmatizer
|
||||
from app.services.image_moderation_service import ImageModerationService
|
||||
from app.services.text_moderation_service import TextModerationService
|
||||
from app.ml.image.clip_classifier import ClipClassifier
|
||||
|
||||
|
||||
_clip_classifier = None
|
||||
|
||||
@lru_cache
|
||||
def get_clip_classifier():
|
||||
def get_clip_classifier() -> ClipClassifier:
|
||||
return ClipClassifier()
|
||||
|
||||
global _clip_classifier
|
||||
|
||||
if _clip_classifier is None:
|
||||
_clip_classifier = ClipClassifier()
|
||||
|
||||
return _clip_classifier
|
||||
|
||||
@lru_cache
|
||||
def get_text_classifier() -> TextClassifier:
|
||||
@@ -45,19 +38,19 @@ def get_text_moderation_service() -> TextModerationService:
|
||||
profanity_detector=get_profanity_detector()
|
||||
)
|
||||
|
||||
@lru_cache
|
||||
def get_image_validator():
|
||||
|
||||
@lru_cache
|
||||
def get_image_validator() -> ImageValidator:
|
||||
return ImageValidator()
|
||||
|
||||
|
||||
def get_image_classifier():
|
||||
@lru_cache
|
||||
def get_image_classifier() -> ImageClassifier:
|
||||
return ImageClassifier()
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_image_moderation_service():
|
||||
|
||||
def get_image_moderation_service() -> ImageModerationService:
|
||||
return ImageModerationService(
|
||||
classifier=get_image_classifier(),
|
||||
validator=get_image_validator(),
|
||||
|
||||
Reference in New Issue
Block a user