MrGanesh commited on
Commit
2960bcd
1 Parent(s): 2ccec94

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -46
app.py DELETED
@@ -1,46 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
4
-
5
- tokenizer = AutoTokenizer.from_pretrained("Armandoliv/t5-small-summarizer-scitldr")
6
-
7
- model = AutoModelForSeq2SeqLM.from_pretrained("Armandoliv/t5-small-summarizer-scitldr")
8
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
9
- model = model.to(device)
10
-
11
- def main_summarizer(text):
12
- max_input_length = 1024
13
- preprocess_text = text.strip().replace("\n"," ").replace("’", "'").strip()
14
- tokenized_text = tokenizer.encode(preprocess_text, return_tensors="pt", truncation=True, max_length=max_input_length,).to(device)
15
-
16
- summary_ids = model.generate(
17
- tokenized_text,
18
- max_length=256,
19
- num_beams=8,
20
- repetition_penalty=3.0,
21
- length_penalty=2.5,
22
- early_stopping=False
23
- )
24
-
25
- output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
26
-
27
- return output
28
-
29
- inputs = [gr.Textbox(lines=10, placeholder="Text Here...", label="Input")]
30
- outputs = gr.Text( label="Summary")
31
- title="Text summarisation app"
32
- description = "This demo uses AI Models to summarize long text.\nIt focus on scientific texts."
33
-
34
- io = gr.Interface(fn=main_summarizer, inputs=inputs, outputs=outputs, title=title, description = description,
35
-
36
- css= """.gr-button-primary { background: -webkit-linear-gradient(
37
- 90deg, #355764 0%, #55a8a1 100% ) !important; background: #355764;
38
- background: linear-gradient(
39
- 90deg, #355764 0%, #55a8a1 100% ) !important;
40
- background: -moz-linear-gradient( 90deg, #355764 0%, #55a8a1 100% ) !important;
41
- background: -webkit-linear-gradient(
42
- 90deg, #355764 0%, #55a8a1 100% ) !important;
43
- color:white !important}"""
44
- )
45
-
46
- io.launch()