Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
3 |
+
|
4 |
+
# Loading summarization model
|
5 |
+
summarization_tokenizer = AutoTokenizer.from_pretrained("ieuniversity/sciencebrief_summarization")
|
6 |
+
summarization_model = AutoModelForSeq2SeqLM.from_pretrained("ieuniversity/sciencebrief_summarization")
|
7 |
+
summarizer = pipeline("summarization", tokenizer=summarization_tokenizer, model=summarization_model)
|
8 |
+
|
9 |
+
def summarize(text):
|
10 |
+
return summarizer(text, max_length=120, min_length=30, do_sample=False)[0]['summary_text']
|
11 |
+
|
12 |
+
iface_summarize = gr.Interface(
|
13 |
+
fn=summarize,
|
14 |
+
inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
|
15 |
+
outputs=gr.outputs.Textbox(label="Summary"),
|
16 |
+
title="ScienceBrief Summarization",
|
17 |
+
description="Get a summary of your text using the ScienceBrief summarization model.",
|
18 |
+
theme="compact"
|
19 |
+
)
|
20 |
+
|
21 |
+
iface_summarize.launch()
|