Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_path = '.' # Assuming the model files are in the current directory
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
8 |
+
summarizer = pipeline('summarization', model=model, tokenizer=tokenizer)
|
9 |
+
|
10 |
+
def summarize_text(text):
|
11 |
+
result = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
12 |
+
return result[0]['summary_text']
|
13 |
+
|
14 |
+
gr_interface = gr.Interface(
|
15 |
+
fn=summarize_text,
|
16 |
+
inputs=gr.inputs.Textbox(lines=5, placeholder="Enter text to summarize here..."),
|
17 |
+
outputs="text",
|
18 |
+
title="Text Summarization with Fine-Tuned Model",
|
19 |
+
description="Enter text to generate a summary using the fine-tuned summarization model."
|
20 |
+
)
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
gr_interface.launch()
|