Ryan Shrott commited on
Commit
49bfda6
·
0 Parent(s):

Initial commit

Browse files
Files changed (2) hide show
  1. gradio_app.py +24 -0
  2. requirements.txt +2 -0
gradio_app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ model_name = "t5-base"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7
+ summarization = pipeline("summarization", model=model, tokenizer=tokenizer)
8
+
9
+ def generate_summary(text):
10
+ summary = summarization(text, max_length=100, min_length=25, do_sample=False)
11
+ return summary[0]["summary_text"]
12
+
13
+ input_text = gr.inputs.Textbox(lines=5, placeholder="Enter your text here...")
14
+ output_text = gr.outputs.Textbox(label="Summary")
15
+
16
+ iface = gr.Interface(
17
+ fn=generate_summary,
18
+ inputs=input_text,
19
+ outputs=output_text,
20
+ title="Text Summarization",
21
+ description="Enter your text and get a summary using the Hugging Face T5 model.",
22
+ )
23
+
24
+ iface.launch(share=True) # Set share=True to get a public link to share the app.
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==2.3.8
2
+ transformers==4.12.2