shoukaku commited on
Commit
7b42c67
1 Parent(s): 250470d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from skk import summarizer
2
+ import torch
3
+ import gradio
4
+
5
+ CHECKPOINT = 'checkpoints/scisumm-bart-cnn.ckpt'
6
+
7
+ model = summarizer.LitModel.load_from_checkpoint(
8
+ CHECKPOINT,
9
+ model = summarizer.base_model,
10
+ tokenizer = summarizer.tokenizer
11
+ )
12
+
13
+ def summarize(s):
14
+ model.eval()
15
+ tok_s = summarizer.tokenizer(
16
+ s,
17
+ return_tensors = 'pt',
18
+ truncation = True
19
+ )
20
+ return model.generate(tok_s)[0]
21
+
22
+ # s = 'Given two images of different anime roles, anime style recognition (ASR) aims to learn abstract painting style to determine whether the two images are from the same work, which is an interesting but challenging problem. Unlike biometric recognition, such as face recognition, iris recognition, and person re-identification, ASR suffers from a much larger semantic gap but receives less attention. In this paper, we propose a challenging ASR benchmark. Firstly, we collect a large-scale ASR dataset (LSASRD), which contains 20,937 images of 190 anime works and each work at least has ten different roles. In addition to the large-scale, LSASRD contains a list of challenging factors, such as complex illuminations, various poses, theatrical colors and exaggerated compositions. Secondly, we design a cross-role protocol to evaluate ASR performance, in which query and gallery images must come from different roles to validate an ASR model is to learn abstract painting style rather than learn discriminative features of roles. Finally, we apply two powerful person re-identification methods, namely, AGW and TransReID, to construct the baseline performance on LSASRD. Surprisingly, the recent transformer model (i.e., TransReID) only acquires a 42.24% mAP on LSASRD. Therefore, we believe that the ASR task of a huge semantic gap deserves deep and long-term research.'
23
+
24
+ # print(' '.join(summarize(s).split()))
25
+
26
+ app = gradio.Interface(
27
+ fn = summarize,
28
+ inputs = gradio.Textbox(placeholder = 'Paste The Abstract Here', label = 'Abstract'),
29
+ outputs = gradio.Textbox(label = 'Summary'),
30
+ title = 'Paper Abstract Summarizer',
31
+ description = 'A text summarizer to summarize paper abstract'
32
+ )
33
+
34
+ def main():
35
+ app.launch()
36
+
37
+ if __name__ == '__main__':
38
+ main()