Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build a Gradio app that summarizes text from Wikipedia articles"""
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from summarize import summarize, search_wiki, get_wiki_text
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def summarize_gradio(search_term):
|
| 8 |
+
"""Summarize text from Wikipedia articles"""
|
| 9 |
+
search_results = search_wiki(search_term)
|
| 10 |
+
page_title = search_results[0]
|
| 11 |
+
text = get_wiki_text(page_title)
|
| 12 |
+
summary = summarize(text)
|
| 13 |
+
return summary
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=summarize_gradio,
|
| 18 |
+
inputs="text",
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="Hugging Face Summarize",
|
| 21 |
+
description="Summarize text from Wikipedia articles",
|
| 22 |
+
allow_flagging=False,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
iface.launch()
|