Spaces:
Sleeping
Sleeping
Commit
·
7218a55
1
Parent(s):
8df474c
working
Browse files- app.py +8 -11
- requirements.txt +0 -4
app.py
CHANGED
@@ -12,7 +12,7 @@ HF_TOKEN = os.environ['HF_TOKEN']
|
|
12 |
|
13 |
def summarize(model_name, article):
|
14 |
API_URL = f"https://api-inference.huggingface.co/models/{model_name}"
|
15 |
-
headers = {"Authorization": "Bearer {HF_TOKEN}"}
|
16 |
|
17 |
payload = {"inputs": article}
|
18 |
response = requests.post(API_URL, headers=headers, json=payload)
|
@@ -83,25 +83,22 @@ def scrape_article(url):
|
|
83 |
except Exception as e:
|
84 |
return "Error scraping article: " + str(e), ""
|
85 |
|
86 |
-
# Using Gradio Blocks with improved layout and styling
|
87 |
with gr.Blocks() as demo:
|
88 |
-
gr.Markdown("# News Summary App"
|
89 |
gr.Markdown("Enter a news text and get its summary, or load a random article.")
|
90 |
|
91 |
with gr.Row():
|
92 |
with gr.Column():
|
93 |
-
|
94 |
-
|
95 |
-
load_news_article_button = gr.Button("Pull Random News Article from NewsAPI")
|
96 |
article_title = gr.Label() # Component to display the article title
|
97 |
-
input_text = gr.Textbox(lines=10, label="Input Text")
|
98 |
with gr.Column():
|
99 |
-
with gr.Row():
|
100 |
-
summarize_button = gr.Button("Summarize")
|
101 |
model_name = gr.Dropdown(label="Model Name", choices=["liamvbetts/bart-news-summary-v1", "liamvbetts/bart-base-cnn-v1", "liamvbetts/bart-large-cnn-v2", "liamvbetts/bart-large-cnn-v4"], value="liamvbetts/bart-news-summary-v1")
|
102 |
-
|
|
|
103 |
|
104 |
-
load_dataset_article_button.click(fn=load_article, inputs=[], outputs=input_text)
|
105 |
load_news_article_button.click(fn=get_news_article, inputs=[], outputs=[input_text, article_title])
|
106 |
summarize_button.click(fn=summarize, inputs=[model_name, input_text], outputs=output_text)
|
107 |
|
|
|
12 |
|
13 |
def summarize(model_name, article):
|
14 |
API_URL = f"https://api-inference.huggingface.co/models/{model_name}"
|
15 |
+
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
16 |
|
17 |
payload = {"inputs": article}
|
18 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
83 |
except Exception as e:
|
84 |
return "Error scraping article: " + str(e), ""
|
85 |
|
|
|
86 |
with gr.Blocks() as demo:
|
87 |
+
gr.Markdown("# News Summary App")
|
88 |
gr.Markdown("Enter a news text and get its summary, or load a random article.")
|
89 |
|
90 |
with gr.Row():
|
91 |
with gr.Column():
|
92 |
+
load_dataset_article_button = gr.Button("Load Random Article from Dataset")
|
93 |
+
load_news_article_button = gr.Button("Load News Article")
|
|
|
94 |
article_title = gr.Label() # Component to display the article title
|
95 |
+
input_text = gr.Textbox(lines=10, label="Input Text", placeholder="Enter article text or load a random article...")
|
96 |
with gr.Column():
|
|
|
|
|
97 |
model_name = gr.Dropdown(label="Model Name", choices=["liamvbetts/bart-news-summary-v1", "liamvbetts/bart-base-cnn-v1", "liamvbetts/bart-large-cnn-v2", "liamvbetts/bart-large-cnn-v4"], value="liamvbetts/bart-news-summary-v1")
|
98 |
+
summarize_button = gr.Button("Summarize")
|
99 |
+
output_text = gr.Textbox(label="Summary", placeholder="Summary will appear here...")
|
100 |
|
101 |
+
load_dataset_article_button.click(fn=load_article, inputs=[], outputs=[input_text, article_title])
|
102 |
load_news_article_button.click(fn=get_news_article, inputs=[], outputs=[input_text, article_title])
|
103 |
summarize_button.click(fn=summarize, inputs=[model_name, input_text], outputs=output_text)
|
104 |
|
requirements.txt
CHANGED
@@ -1,7 +1,3 @@
|
|
1 |
gradio
|
2 |
-
#transformers
|
3 |
datasets
|
4 |
-
evaluate
|
5 |
-
accelerate
|
6 |
-
torch
|
7 |
beautifulsoup4
|
|
|
1 |
gradio
|
|
|
2 |
datasets
|
|
|
|
|
|
|
3 |
beautifulsoup4
|