Abijith commited on
Commit
a885c80
1 Parent(s): 0621dcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -1,3 +1,30 @@
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- gr.Interface.load("models/Abijith/Text-summarizer-t5-small").launch()
 
 
 
1
+ # import gradio as gr
2
+
3
+ # gr.Interface.load("models/Abijith/Text-summarizer-t5-small").launch()
4
+
5
+ import os
6
  import gradio as gr
7
+ from transformers import AutoTokenizer, T5ForConditionalGeneration
8
+
9
+ # Load model directly
10
+ tokenizer = AutoTokenizer.from_pretrained("Abijith/my_first_t5_billsum_model")
11
+ model = T5ForConditionalGeneration.from_pretrained("Abijith/my_first_t5_billsum_model")
12
+
13
+ def summarize_text(input_text):
14
+ summar_input = 'summarize: '+input_text
15
+ input_tokens = tokenizer(summar_input, return_tensors='pt').input_ids
16
+ outputs = model.generate(input_tokens)
17
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
18
+
19
+ # Interface for the Gradio app
20
+ iface = gr.Interface(
21
+ fn=summarize_text,
22
+ inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
23
+ outputs=gr.outputs.Textbox(label="Summary"),
24
+ title="Text Summarizer",
25
+ description="Enter a paragraph, and the app will provide a summary.",
26
+ )
27
 
28
+ # Launch the Gradio app
29
+ iface.launch()
30
+