merhaba / app.py
Qptimus's picture
Update app.py
e147bc9 verified
Raw History Blame Contribute Delete
778 Bytes
# app.py
import gradio as gr
from transformers import pipeline
# Türkçe toksisite modeli
model_name = "cagrigungor/turkishtoxic-classifier"
classifier = pipeline("text-classification", model=model_name)
# Moderasyon fonksiyonu
def analyze_toxicity(text):
result = classifier(text)
# LABEL_1 veya 'toxic' etiketini al
toxic_score = max([item['score'] for item in result if item['label'].lower() in ['label_1','toxic']], default=0)
return {"toxicityScore": toxic_score, "isModerated": toxic_score < 0.7}
# Gradio Interface
demo = gr.Interface(
fn=analyze_toxicity,
inputs=gr.Textbox(),
outputs=gr.Label(),
api_name="analyze_toxicity", # Endpoint adı
api_visibility="public" # Dışarıdan POST kabul eder
)
demo.launch()