Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Load the model directly from your Hugging Face account
|
| 6 |
+
classifier = pipeline("text-classification", model="jay123jay/AI-Text-Origin-Classifier", truncation=True, max_length=512, top_k=None)
|
| 7 |
+
|
| 8 |
+
def detect_text(text):
|
| 9 |
+
if not text.strip():
|
| 10 |
+
return {}
|
| 11 |
+
results = classifier(text)
|
| 12 |
+
return {res['label']: res['score'] for res in results}
|
| 13 |
+
|
| 14 |
+
class_intro_html = "<center><h2>Text Origin & LLM Attribution Detector</h2></center>"
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.HTML(class_intro_html)
|
| 18 |
+
with gr.Row():
|
| 19 |
+
with gr.Column():
|
| 20 |
+
input_text = gr.Textbox(lines=8, placeholder="Paste the text here to analyze its origin...", label="Input Text")
|
| 21 |
+
analyze_button = gr.Button("Analyze Text")
|
| 22 |
+
with gr.Column():
|
| 23 |
+
output_labels = gr.Label(label="Attribution Probabilities")
|
| 24 |
+
|
| 25 |
+
analyze_button.click(fn=detect_text, inputs=input_text, outputs=output_labels)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|