This AI predicts if a text is roleplay or not (returns percentage). Created by NexusAI Join our discord server: https://discord.gg/7zvkzYutvF

How to use?

from tensorflow import keras

class RPClassifier:
    def __init__(self, model_path='anti_rp.h5'):
        self.model_path = model_path
        self.model = None
        self.load_model()

    def load_model(self):
        if self.model is None:
            try:
                self.model = keras.models.load_model(self.model_path)
            except (FileNotFoundError, OSError):
                raise Exception("Model file not found")

    async def predict(self, text):
        if not self.model:
            raise Exception("Model not found")
        try:
            tokenizer = keras.preprocessing.text.Tokenizer()
            tokenizer.fit_on_texts([text])
            sequence = tokenizer.texts_to_sequences([text])
            padded_sequence = keras.preprocessing.sequence.pad_sequences(sequence, maxlen=self.model.input_shape[1])
            prediction = self.model.predict(padded_sequence)[0][0]
            return prediction
        except Exception as e:
            raise Exception("Error occurred while predicting roleplay. {e}")

    async def analyze(self, input_text):
        rp_percentage = await self.predict(input_text)
        return rp_percentage

async def main():
    classifier = RPClassifier()
    while True:
        input_text = input("> ")
        if input_text.lower() == 'exit':
            break
        result = await classifier.analyze(input_text)
        print(result)

import asyncio
asyncio.run(main()) 
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Datasets used to train RICHKEED/AntiRoleplay