Spaces:
Runtime error
Runtime error
Added block by block summarizing
Browse filesBroke longer block of text into smaller chunks for the model to summarize
app.py
CHANGED
|
@@ -4,13 +4,17 @@ import gradio as gr
|
|
| 4 |
#model
|
| 5 |
model = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") #model="sshleifer/distilbart-cnn-12-6")
|
| 6 |
|
| 7 |
-
def func(
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="InfluencerAI-Summarizer")
|
| 16 |
app.launch()
|
|
|
|
| 4 |
#model
|
| 5 |
model = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") #model="sshleifer/distilbart-cnn-12-6")
|
| 6 |
|
| 7 |
+
def func(Text):
|
| 8 |
+
words = Text.split()
|
| 9 |
+
grouped_words = [' '.join(words[i: i + 300]) for i in range(0, len(words), 300)]
|
| 10 |
+
summary_list = []
|
| 11 |
+
for i in grouped_words:
|
| 12 |
+
y = model(i, max_length=80, do_sample=False)
|
| 13 |
+
summary_list.append(y)
|
| 14 |
+
final_summary = ','.join(str(v) for v in summary_list)
|
| 15 |
+
return final_summary
|
| 16 |
+
|
| 17 |
+
import gradio as gr
|
| 18 |
|
| 19 |
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="InfluencerAI-Summarizer")
|
| 20 |
app.launch()
|