Rici commited on
Commit
b6c6054
1 Parent(s): 76abc58

added demo

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -1,16 +1,20 @@
1
- from transformers import pipeline
2
  import gradio as gr
 
3
 
4
- model = pipeline("summarization")
5
-
6
- def predict(prompt):
7
- summary = model(prompt)[0]['summary_text']
8
- return summary
9
 
10
- with gr.Blocks() as demo:
11
- textbox = gr.inputs.Textbox(lines=5, label="Input Text")
12
- label = gr.outputs.Textbox(label="Output Summary")
13
- gr.Interface(fn=predict, inputs=textbox, outputs=label, title="Summarizer", description="Summarize your text!").launch()
14
 
15
- # Path: Dockerfile
 
 
 
 
 
16
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the summarization model from Hugging Face
5
+ summarizer = pipeline("summarization")
 
 
 
6
 
7
+ # Define the summarization function
8
+ def summarize_text(input_text):
9
+ summarized = summarizer(input_text, max_length=100, min_length=30, do_sample=False)[0]
10
+ return summarized["summary_text"]
11
 
12
+ # Create the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=summarize_text,
15
+ inputs=gr.inputs.Textbox(lines=10, placeholder="Enter text to summarize..."),
16
+ outputs=gr.outputs.Textbox(placeholder="Summary will appear here...")
17
+ )
18
 
19
+ # Run the interface
20
+ iface.launch()