Spaces:
Running
Running
Delete ai
Browse files- ai/app.py +0 -35
- ai/requirements.txt +0 -4
ai/app.py
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
-
import torch
|
4 |
-
|
5 |
-
# Load summarizer
|
6 |
-
device = 0 if torch.cuda.is_available() else -1
|
7 |
-
summarizer = pipeline(
|
8 |
-
"summarization",
|
9 |
-
model="csebuetnlp/mT5_multilingual_XLSum",
|
10 |
-
tokenizer="csebuetnlp/mT5_multilingual_XLSum",
|
11 |
-
device=device
|
12 |
-
)
|
13 |
-
|
14 |
-
print("✅ Model loaded on:", "GPU" if device == 0 else "CPU")
|
15 |
-
|
16 |
-
# Function for API and UI
|
17 |
-
def summarize_text(text):
|
18 |
-
if not text.strip():
|
19 |
-
return "❌ Error: No text provided."
|
20 |
-
|
21 |
-
max_len = 1000
|
22 |
-
clean_text = text.strip()[:max_len]
|
23 |
-
result = summarizer([clean_text], max_length=130, min_length=30, do_sample=False)
|
24 |
-
return result[0]["summary_text"]
|
25 |
-
|
26 |
-
# Gradio Interface (UI + API)
|
27 |
-
iface = gr.Interface(
|
28 |
-
fn=summarize_text,
|
29 |
-
inputs=gr.Textbox(lines=10, placeholder="Paste your news article here..."),
|
30 |
-
outputs="text",
|
31 |
-
title="Multilingual News Summarizer",
|
32 |
-
description="Summarizes news articles using mT5 multilingual XLSum model."
|
33 |
-
)
|
34 |
-
|
35 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ai/requirements.txt
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
transformers
|
2 |
-
sentencepiece
|
3 |
-
gradio
|
4 |
-
torch
|
|
|
|
|
|
|
|
|
|