Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Hugging Face'den modeli yükle
|
| 5 |
+
pipe = pipeline("text-classification", model="gokceuludogan/convbert-base-turkish-mc4-toxicity-uncased")
|
| 6 |
+
|
| 7 |
+
# Gradio arayüzü oluştur
|
| 8 |
+
def predict_toxicity(text):
|
| 9 |
+
result = pipe(text)[0]
|
| 10 |
+
toxicity_label = result['label']
|
| 11 |
+
toxicity_score = result['score']
|
| 12 |
+
return f"Toksisite: {toxicity_label}, Skor: {toxicity_score}"
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=predict_toxicity,
|
| 16 |
+
inputs=gr.inputs.Textbox(lines=5, label="Metin"),
|
| 17 |
+
outputs="text",
|
| 18 |
+
title="Türkçe Metin Toksisite Sınıflandırma",
|
| 19 |
+
description="Bu model, Türkçe metinlerde toksisiteyi sınıflandırmak için eğitilmiştir. Lütfen bir metin girin ve sonucu görün."
|
| 20 |
+
)
|
| 21 |
+
iface.launch()
|