*** layout: overview slug: nemo-curator/nemo\_curator/models/nsfw title: nemo\_curator.models.nsfw -------------------------------- ## Module Contents ### Classes | Name | Description | | ---------------------------------------------------------- | ------------------------------------------------------ | | [`NSFWModel`](#nemo_curator-models-nsfw-NSFWModel) | NSFW detection model. | | [`NSFWScorer`](#nemo_curator-models-nsfw-NSFWScorer) | Public interface for NSFW scoring of image embeddings. | | [`Normalization`](#nemo_curator-models-nsfw-Normalization) | Normalization layer for NSFW model. | ### Data [`_NSFW_MODEL_ID`](#nemo_curator-models-nsfw-_NSFW_MODEL_ID) [`_URL_MAPPING`](#nemo_curator-models-nsfw-_URL_MAPPING) ### API ```python class nemo_curator.models.nsfw.NSFWModel() ``` **Bases:** `Module` NSFW detection model. A neural network that processes CLIP embeddings to predict NSFW scores. Based on LAION's CLIP-based-NSFW-Detector. ```python nemo_curator.models.nsfw.NSFWModel.forward( x: torch.Tensor ) -> torch.Tensor ``` Forward pass through the NSFW model. **Parameters:** Input embeddings tensor. **Returns:** `torch.Tensor` NSFW probability scores. ```python class nemo_curator.models.nsfw.NSFWScorer( model_dir: str ) ``` **Bases:** [ModelInterface](/nemo-curator/nemo_curator/models/base#nemo_curator-models-base-ModelInterface) Public interface for NSFW scoring of image embeddings. This class provides a standardized interface for scoring the likelihood of images containing sexually explicit material using a pre-trained model. Get the name of the conda environment required for this model. Get the model ID names associated with this NSFW scorer. ```python nemo_curator.models.nsfw.NSFWScorer.__call__( embeddings: torch.Tensor | numpy.typing.NDArray[numpy.float32] ) -> torch.Tensor ``` Score the NSFW likelihood of input embeddings. **Parameters:** Input embeddings as either a torch tensor or numpy array. **Returns:** `torch.Tensor` NSFW probability scores for each input embedding. ```python nemo_curator.models.nsfw.NSFWScorer.download_weights_on_node( model_dir: str ) -> None ``` classmethod Download NSFW model weights from LAION repository. **Parameters:** Directory to download the weights to. ```python nemo_curator.models.nsfw.NSFWScorer.setup() -> None ``` Set up the NSFW scoring model by loading weights. ```python class nemo_curator.models.nsfw.Normalization( shape: list[int] ) ``` **Bases:** `Module` Normalization layer for NSFW model. Applies normalization to input tensors using pre-computed mean and variance. ```python nemo_curator.models.nsfw.Normalization.forward( x: torch.Tensor ) -> torch.Tensor ``` Apply normalization to input tensor. **Parameters:** Input tensor to normalize. **Returns:** `torch.Tensor` Normalized tensor. ```python nemo_curator.models.nsfw._NSFW_MODEL_ID = 'laion/clip-autokeras-binary-nsfw' ``` ```python nemo_curator.models.nsfw._URL_MAPPING = {'laion/clip-autokeras-binary-nsfw': 'https://github.com/LAION-AI/CLIP-based-NSF... ```