File size: 1,275 Bytes
8566151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
from transformers import pipeline

# Load your model
classifier = pipeline("text-classification", model="vnarasiman/unwrap-final")

def classify_post(text):
    if not text.strip():
        return "Please enter some text."
    
    results = classifier(text, top_k=None)  # get all label scores
    
    # Format output nicely
    output = ""
    for r in sorted(results, key=lambda x: x["score"], reverse=True):
        bar = "█" * int(r["score"] * 20)
        output += f"{r['label']:<20} {bar} {r['score']*100:.1f}%\n"
    
    return output

demo = gr.Interface(
    fn=classify_post,
    inputs=gr.Textbox(
        lines=6,
        placeholder="Paste a Reddit post here...",
        label="Reddit Post"
    ),
    outputs=gr.Textbox(
        label="Classification Results",
        lines=8
    ),
    title="🔍 Unwrap — Reddit Post Classifier",
    description="Paste any Reddit post to see how it gets classified.",
    examples=[
        ["I've been feeling really overwhelmed at work lately and I don't know what to do anymore."],
        ["Just hit 1000 karma on my main account, feels good!"],
        ["Does anyone know a good recipe for homemade pasta?"],
    ],
    theme=gr.themes.Soft()
)

if __name__ == "__main__":
    demo.launch()