llm-docker-demo / app.py
aysemutluay's picture
Upload app.py
7e188f1 verified
Raw
History Blame Contribute Delete
664 Bytes
import gradio as gr
from transformers import pipeline
clf = pipeline("sentiment-analysis",
model="distilbert-base-uncased-finetuned-sst-2-english")
def analyze(text):
text = (text or "").strip()
if not text: return "⚠️ Lütfen kısa bir metin girin."
out = clf(text)[0]
emo = "😊" if out["label"] == "POSITIVE" else "😞"
return f"{emo} {out['label']} (güven: {out['score']:.2f})"
demo = gr.Interface(fn=analyze,
inputs=gr.Textbox(lines=4, label="Metin"),
outputs="text",
title="Hafif LLM: Duygu Analizi")
demo.launch(server_name="0.0.0.0", server_port=7860)