Mikael Kermorgant commited on
Commit
996ab71
1 Parent(s): 3ff5bbe

add test code

Browse files
Files changed (3) hide show
  1. app.py +52 -0
  2. data.txt +1 -0
  3. requirement.txt +3 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ @st.cache(allow_output_mutation=True)
5
+ def load_summarizer():
6
+ model = pipeline("summarization", device=0)
7
+ return model
8
+
9
+
10
+ def generate_chunks(inp_str):
11
+ max_chunk = 500
12
+ inp_str = inp_str.replace('.', '.<eos>')
13
+ inp_str = inp_str.replace('?', '?<eos>')
14
+ inp_str = inp_str.replace('!', '!<eos>')
15
+
16
+ sentences = inp_str.split('<eos>')
17
+ current_chunk = 0
18
+ chunks = []
19
+ for sentence in sentences:
20
+ if len(chunks) == current_chunk + 1:
21
+ if len(chunks[current_chunk]) + len(sentence.split(' ')) <= max_chunk:
22
+ chunks[current_chunk].extend(sentence.split(' '))
23
+ else:
24
+ current_chunk += 1
25
+ chunks.append(sentence.split(' '))
26
+ else:
27
+ chunks.append(sentence.split(' '))
28
+
29
+ for chunk_id in range(len(chunks)):
30
+ chunks[chunk_id] = ' '.join(chunks[chunk_id])
31
+ return chunks
32
+
33
+
34
+ summarizer = load_summarizer()
35
+ st.title("Summarize Text")
36
+ sentence = st.text_area('Please paste your article :', height=30)
37
+ button = st.button("Summarize")
38
+ butnn2 = st.button("koucou")
39
+
40
+ max = st.sidebar.slider('Select max', 50, 500, step=10, value=150)
41
+ min = st.sidebar.slider('Select min', 10, 450, step=10, value=50)
42
+ do_sample = st.sidebar.checkbox("Do sample", value=False)
43
+ with st.spinner("Generating Summary.."):
44
+ if button and sentence:
45
+ chunks = generate_chunks(sentence)
46
+ res = summarizer(chunks,
47
+ max_length=max,
48
+ min_length=min,
49
+ do_sample=do_sample)
50
+ text = ' '.join([summ['summary_text'] for summ in res])
51
+ # st.write(result[0]['summary_text'])
52
+ st.write(text)
data.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ One of the big AI research conferences has been NuerIPS each December, which has been doubling attendance every year. But Nvidia’s GPU Technology Conference (GTC) is also another conference that drawn big crowds. Because the conference has been turned virtual, as have all conferences during the pandemic, it’s now easier to gather AI researcher from all over the world in one event. And Nvidia has gathered the top names in AI for this year’s GTC. Those top names in AI research include Geoffrey Hinton an Emeritus Professor from the University of Toronto, VP and Engineering Fellow at Google, and Chief Scientific Adviser to the Vector Institute. He is known for his pioneering work on Artificial Neural Networks (ANNs). His research on the backpropagation algorithm brought about drastic improvements in the performance of deep learning models. Hinton won the 2018 Turing Award for his groundbreaking work around deep neural networks, which he shares with Yann LeCun and Yoshua Bengio – both of which are also speakers at GTC 2021. Yann LeCun is VP and Chief AI Scientist at Facebook and Silver Professor from New York University and considered the founding father of Convolutional Neural Networks (CNNs). He has won the 2014 IEEE Neural Network Pioneer Award and the 2015 PAMI Distinguished Researcher Award, as well as the aforementioned Turing Award. Yoshua Bengio is a Full Professor, and the Founder and Scientific Director at the University of Montreal and the Mila - Quebec Artificial Intelligence Institute. He received the prestigious award of Canada Research Chair in Statistical Learning Algorithms. Yoshua is known for his work on artificial neural networks and deep learning in the 1980s and 1990s. He co-created the prestigious International Conference on Learning Representations (ICLR) conference with Yann LeCun. These are three of the top AI researchers, but there are 23 other world-class researchers that will also be presenting at GTC and potentially thousands more in attendance. Some of the leading companies presenting at GTC include: Adobe, Arm, Audi, Autodesk, Epic Games, Facebook, Google, IBM, Industrial Light and Magic, Morgan Stanley, Pixar, Red Hat, Siemens, St. Jude Children’s Hospital, Verizon, VMWare, Walmart. Covering a very broad range of AI applications and implementations. Nvidia was the first to invest heavily in High-Performance Computing (HPC) on GPUs, originally called GPGPU. Nvidia led using CUDA platform to facilitate HPC on GPUs. That lead to researchers using GPU to accelerate digital neural networks, which lead to breakthrough performance and modern AI. This pioneering work led to Nvidia’s GPUs becoming the main research and development platform for deep learning neural nets. With Nvidia GPUs in data centers, advanced driver assistance systems (ADAS), drones, robots, workstations, and PCs, Nvidia has the most pervasive and scalable AI platform. Since then, other GPU and accelerator and software vendors have been chasing Nvidia. Being the first and widest platform means most researchers have experience using Nvidia GPUs, making GTC a conference with broad appeal in the AI, Automotive, HPC, and gaming industries. It also has strong appeal for a wide range of researchers in academia, atmospheric, biomedical, and geological to name a few. Nvidia’s GTC really is one of the conferences I look forward to every year where I learn about new uses for AI technology. The conference will begin with a keynote by Nvidia’s CEO Jensen Huang to reveal the latest Nvidia technology and designs on April 12. And did I mention it’s free? There are also instructor-led, hands-on training and workshops as part of the conference for $249 per person, but the main conference and talks you can attend for free.
requirement.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ torch
3
+ transformers