srijanupadhyay commited on
Commit
bfa768d
·
verified ·
1 Parent(s): 12b9f99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -1,10 +1,21 @@
 
1
  import gradio as gr
 
2
 
3
- with gr.Blocks(fill_height=True) as demo:
4
- with gr.Sidebar():
5
- gr.Markdown("# Inference Provider")
6
- gr.Markdown("This Space showcases the Falconsai/text_summarization model, served by the hf-inference API. Sign in with your Hugging Face account to use this API.")
7
- button = gr.LoginButton("Sign in")
8
- gr.load("models/Falconsai/text_summarization", accept_token=button, provider="hf-inference")
9
-
10
- demo.launch()
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
  import gradio as gr
3
+ from transformers import pipeline
4
 
5
+ # Choose model (either one of the two below)
6
+ model_name = "Falconsai/text_summarization" # or "facebook/bart-large-cnn"
7
+ summarizer = pipeline("summarization", model=model_name)
8
+
9
+ def summarize(text):
10
+ summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
11
+ return summary[0]["summary_text"]
12
+
13
+ iface = gr.Interface(
14
+ fn=summarize,
15
+ inputs=gr.Textbox(lines=10, placeholder="Enter long text here..."),
16
+ outputs=gr.Textbox(label="Summary"),
17
+ allow_flagging="never",
18
+ title="Text Summarizer"
19
+ )
20
+
21
+ iface.launch()