Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline, AutoTokenizer, T5ForConditionalGeneration | |
# Model ve tokenizer'ı yükle | |
model_name = "ozcangundes/mt5-small-turkish-summarization" | |
def summarize_text(text): | |
if len(text.split()) < 100: | |
return "Metin çok kısa. En az 100 kelime olmalıdır." | |
try: | |
# Pipeline oluştur | |
summarizer = pipeline( | |
"summarization", | |
model=model_name, | |
tokenizer=model_name | |
) | |
# Metni özetle | |
summary = summarizer(text, | |
max_length=150, | |
min_length=50, | |
length_penalty=2.0, | |
num_beams=4, | |
early_stopping=True) | |
return summary[0]['summary_text'] | |
except Exception as e: | |
return f"Hata oluştu: {str(e)}" | |
# Gradio arayüzünü oluştur | |
iface = gr.Interface( | |
fn=summarize_text, | |
inputs=gr.Textbox(lines=10, label="Özetlenecek Metin"), | |
outputs=gr.Textbox(label="Özet"), | |
title="Türkçe Metin Özetleme", | |
description="Türkçe metinleri özetleyen yapay zeka modeli. En az 100 kelimelik metin giriniz." | |
) | |
iface.launch() |