File size: 819 Bytes
bd36a06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline

# Load the text classification model
classifier = pipeline('text-classification', model='ardavey/bert-base-ai-generated-text')

# Define a function for text classification
def classify_text(text):
    predictions = classifier([text])
    label = 'AI Generated Text' if predictions[0]['label'] == 'LABEL_1' else 'Human Generated Text'
    score = predictions[0]['score']
    return f"Prediction: {label}, Score: {score:.4f}"

# Create a Gradio interface
interface = gr.Interface(
    fn=classify_text,
    inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
    outputs="text",
    title="AI Generated Text Detector",
    description="Enter a text to check whether the content is written by AI or Human."
)

# Launch the Gradio app
interface.launch()