File size: 896 Bytes
f575c3b
 
 
ada7bfe
f575c3b
4cc1f8a
 
 
 
 
 
 
 
 
 
f575c3b
 
4cc1f8a
 
 
 
 
 
 
f575c3b
4cc1f8a
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import PyPDF2
from PIL import Image
import streamlit as st 

def read_pdf(pdf):
    reader=PyPDF2.PdfReader(pdf)
    text=''
    for page in reader.pages:
        text+=page.extract_text()
    # text_file_name = 'text.txt'
    # text_file_path = '/content/text.txt'
    # with open(text_file_path, 'w') as text_file:
    #     text_file.write(text)
    return text


def summarizer(text):
    model = T5ForConditionalGeneration.from_pretrained("t5-base")
    tokenizer = T5TokenizerFast.from_pretrained("t5-base")
    inputs = tokenizer.encode("summarize: " + text,return_tensors="pt", max_length=1000,truncation=True)
    outputs = model.generate(inputs,max_length=1000, min_length=100,length_penalty=2.0, num_beams=4,early_stopping=True)
    summary = tokenizer.decode(outputs[0])
    return summary


st.title(':blue[Abstractive Summarizer]')
st.header('by: _Team_ _Rare_ _species_')