Spaces:
Sleeping
Sleeping
Removed cross_language summarize button
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# app.py - Final Version
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
@@ -23,13 +23,13 @@ def summarize(text, language_choice, min_length):
|
|
23 |
if not text or not text.strip():
|
24 |
return "Please enter text to summarize."
|
25 |
|
|
|
26 |
# Set the prompt based on the language choice
|
27 |
if language_choice == "Turkish Text -> Turkish Summary":
|
28 |
prompt = f"summarize: {text}"
|
29 |
elif language_choice == "English Text -> English Summary":
|
30 |
prompt = f"summarize: {text}"
|
31 |
-
|
32 |
-
prompt = f"summarize Turkish to English: {text}"
|
33 |
|
34 |
try:
|
35 |
inputs = tokenizer(prompt, return_tensors="pt", max_length=1024, truncation=True).to(device)
|
@@ -55,7 +55,8 @@ iface = gr.Interface(
|
|
55 |
inputs=[
|
56 |
gr.Textbox(lines=15, placeholder="Paste the text you want to summarize here...", label="Text Input"),
|
57 |
gr.Radio(
|
58 |
-
|
|
|
59 |
label="Summarization Type",
|
60 |
value="Turkish Text -> Turkish Summary"
|
61 |
),
|
@@ -74,7 +75,7 @@ iface = gr.Interface(
|
|
74 |
The model was fine-tuned on 30,000 Turkish-English summary pairs using the LoRA technique,
|
75 |
based on the `google/mt5-small` model.""",
|
76 |
|
77 |
-
#
|
78 |
examples=[
|
79 |
["Güneş enerjisi kullanımı son yıllarda hızla artıyor. Evler ve iş yerleri çatılarında güneş panelleri kurarak elektrik üretiyor. Bu sayede enerji faturaları düşüyor ve çevreye zarar vermeyen temiz enerji kullanılıyor. Uzmanlar, güneş enerjisinin gelecekte elektrik ihtiyacının büyük kısmını karşılayabileceğini ve fosil yakıtlara olan bağımlılığı azaltacağını söylüyor.", "Turkish Text -> Turkish Summary", 10],
|
80 |
["Electric cars are becoming increasingly popular worldwide. People choose electric vehicles because they produce less pollution and reduce fuel costs. Governments are promoting them by offering incentives and building more charging stations. Experts believe that electric cars could eventually replace most gasoline-powered vehicles, significantly decreasing greenhouse gas emissions and contributing to a cleaner environment.", "English Text -> English Summary", 10]
|
|
|
1 |
+
# app.py - Final Version (Experimental TR->EN option removed)
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
23 |
if not text or not text.strip():
|
24 |
return "Please enter text to summarize."
|
25 |
|
26 |
+
# --- DEĞİŞİKLİK 1: "else" bloğu kaldırıldı ---
|
27 |
# Set the prompt based on the language choice
|
28 |
if language_choice == "Turkish Text -> Turkish Summary":
|
29 |
prompt = f"summarize: {text}"
|
30 |
elif language_choice == "English Text -> English Summary":
|
31 |
prompt = f"summarize: {text}"
|
32 |
+
# Deneysel seçenek kaldırıldığı için artık 'else' durumuna gerek yok.
|
|
|
33 |
|
34 |
try:
|
35 |
inputs = tokenizer(prompt, return_tensors="pt", max_length=1024, truncation=True).to(device)
|
|
|
55 |
inputs=[
|
56 |
gr.Textbox(lines=15, placeholder="Paste the text you want to summarize here...", label="Text Input"),
|
57 |
gr.Radio(
|
58 |
+
# --- DEĞİŞİKLİK 2: Deneysel seçenek listeden çıkarıldı ---
|
59 |
+
["Turkish Text -> Turkish Summary", "English Text -> English Summary"],
|
60 |
label="Summarization Type",
|
61 |
value="Turkish Text -> Turkish Summary"
|
62 |
),
|
|
|
75 |
The model was fine-tuned on 30,000 Turkish-English summary pairs using the LoRA technique,
|
76 |
based on the `google/mt5-small` model.""",
|
77 |
|
78 |
+
# --- DEĞİŞİKLİK 3: Örnekler listesi de 2 seçeneğe göre güncellendi ---
|
79 |
examples=[
|
80 |
["Güneş enerjisi kullanımı son yıllarda hızla artıyor. Evler ve iş yerleri çatılarında güneş panelleri kurarak elektrik üretiyor. Bu sayede enerji faturaları düşüyor ve çevreye zarar vermeyen temiz enerji kullanılıyor. Uzmanlar, güneş enerjisinin gelecekte elektrik ihtiyacının büyük kısmını karşılayabileceğini ve fosil yakıtlara olan bağımlılığı azaltacağını söylüyor.", "Turkish Text -> Turkish Summary", 10],
|
81 |
["Electric cars are becoming increasingly popular worldwide. People choose electric vehicles because they produce less pollution and reduce fuel costs. Governments are promoting them by offering incentives and building more charging stations. Experts believe that electric cars could eventually replace most gasoline-powered vehicles, significantly decreasing greenhouse gas emissions and contributing to a cleaner environment.", "English Text -> English Summary", 10]
|