Download app.py from vnarasiman/unwrap-final: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/vnarasiman/unwrap-final/resolve/main/app.py
- Command line
-
hf download hf://vnarasiman/unwrap-final/app.py
-
curl -L -o app.py https://huggingface.co/vnarasiman/unwrap-final/resolve/main/app.py
1.28 kB
| 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() |