madankn79 commited on
Commit
d83d604
·
1 Parent(s): be7c072

Initial Version

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -1,15 +1,17 @@
1
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
 
2
 
3
- # Load the model and tokenizer
4
- tokenizer = AutoTokenizer.from_pretrained("Waris01/google-t5-finetuning-text-summarization")
5
- model = AutoModelForSeq2SeqLM.from_pretrained("Waris01/google-t5-finetuning-text-summarization")
6
 
7
- # Input text for summarization
8
- text = "Printed Round Neck Cotton Oversize Half sleeves Co-ord set Tracksuit For Men-P-MACK52845"
9
 
10
- # Tokenize and generate summary
11
- inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
12
- summary_ids = model.generate(inputs["input_ids"], max_length=65, min_length=5, early_stopping=True)
13
- summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
 
 
 
 
 
 
14
 
15
- print(summary)
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipe = pipeline("summarization", model="facebook/bart-large-cnn")
 
 
5
 
 
 
6
 
7
+ def process(text):
8
+ return pipe(text, max_length=65, min_length=10, do_sample=False, clean_up_tokenization_spaces=True, truncation=True)
9
+
10
+ demo = gr.Interface(
11
+ fn=process,
12
+ inputs=gr.Textbox(label="Input Text"),
13
+ outputs="json"
14
+ )
15
+
16
+ demo.launch(share=True)
17